|
Lines 23-29
Link Here
|
| 23 |
import org.eclipse.core.resources.IFile; |
23 |
import org.eclipse.core.resources.IFile; |
| 24 |
import org.eclipse.core.runtime.IAdaptable; |
24 |
import org.eclipse.core.runtime.IAdaptable; |
| 25 |
import org.eclipse.core.runtime.IProgressMonitor; |
25 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
|
26 |
import org.eclipse.core.runtime.IStatus; |
| 26 |
import org.eclipse.draw2d.IFigure; |
27 |
import org.eclipse.draw2d.IFigure; |
|
|
28 |
import org.eclipse.emf.transaction.RunnableWithResult; |
| 27 |
import org.eclipse.emf.transaction.TransactionalEditingDomain; |
29 |
import org.eclipse.emf.transaction.TransactionalEditingDomain; |
| 28 |
import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; |
30 |
import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; |
| 29 |
import org.eclipse.gef.commands.Command; |
31 |
import org.eclipse.gef.commands.Command; |
|
Lines 33-38
Link Here
|
| 33 |
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; |
35 |
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; |
| 34 |
import org.eclipse.gmf.runtime.diagram.ui.requests.ArrangeRequest; |
36 |
import org.eclipse.gmf.runtime.diagram.ui.requests.ArrangeRequest; |
| 35 |
import org.eclipse.gmf.runtime.diagram.ui.services.layout.LayoutType; |
37 |
import org.eclipse.gmf.runtime.diagram.ui.services.layout.LayoutType; |
|
|
38 |
import org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil; |
| 36 |
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; |
39 |
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; |
| 37 |
import org.eclipse.gmf.runtime.notation.View; |
40 |
import org.eclipse.gmf.runtime.notation.View; |
| 38 |
|
41 |
|
|
Lines 121-159
Link Here
|
| 121 |
IProgressMonitor progressMonitor, IAdaptable info) |
124 |
IProgressMonitor progressMonitor, IAdaptable info) |
| 122 |
throws ExecutionException { |
125 |
throws ExecutionException { |
| 123 |
|
126 |
|
| 124 |
containerEP.refresh(); |
127 |
RunnableWithResult refreshRunnable = new RunnableWithResult() { |
| 125 |
|
128 |
|
| 126 |
// The layout command requires that the figure world is updated. |
129 |
private IStatus status; |
| 127 |
getContainerFigure().invalidate(); |
130 |
private Object result; |
| 128 |
getContainerFigure().validate(); |
131 |
|
| 129 |
|
132 |
public Object getResult() { |
| 130 |
List editParts = new ArrayList(viewAdapters.size()); |
133 |
return result; |
| 131 |
Map epRegistry = containerEP.getRoot().getViewer() |
134 |
} |
| 132 |
.getEditPartRegistry(); |
135 |
|
| 133 |
for (Iterator iter = viewAdapters.iterator(); iter.hasNext();) { |
136 |
public void setStatus(IStatus status) { |
| 134 |
IAdaptable ad = (IAdaptable) iter.next(); |
137 |
this.status = status; |
| 135 |
View view = (View) ad.getAdapter(View.class); |
138 |
} |
| 136 |
Object ep = epRegistry.get(view); |
139 |
|
| 137 |
if (ep != null) { |
140 |
public IStatus getStatus() { |
| 138 |
editParts.add(ep); |
141 |
return status; |
|
|
142 |
} |
| 143 |
|
| 144 |
public void run() { |
| 145 |
containerEP.refresh(); |
| 146 |
|
| 147 |
// The layout command requires that the figure world is updated. |
| 148 |
getContainerFigure().invalidate(); |
| 149 |
getContainerFigure().validate(); |
| 150 |
|
| 151 |
List editParts = new ArrayList(viewAdapters.size()); |
| 152 |
Map epRegistry = containerEP.getRoot().getViewer() |
| 153 |
.getEditPartRegistry(); |
| 154 |
for (Iterator iter = viewAdapters.iterator(); iter.hasNext();) { |
| 155 |
IAdaptable ad = (IAdaptable) iter.next(); |
| 156 |
View view = (View) ad.getAdapter(View.class); |
| 157 |
Object ep = epRegistry.get(view); |
| 158 |
if (ep != null) { |
| 159 |
editParts.add(ep); |
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
if (editParts.isEmpty()) { |
| 164 |
result = editParts; |
| 165 |
return; |
| 166 |
} |
| 167 |
|
| 168 |
Set layoutSet = new HashSet(editParts.size()); |
| 169 |
layoutSet.addAll(editParts); |
| 170 |
|
| 171 |
// refresh source and target connections of any shapes in the container not being considered for layout |
| 172 |
Iterator iter = containerEP.getChildren().iterator(); |
| 173 |
while (iter.hasNext()) { |
| 174 |
Object obj = iter.next(); |
| 175 |
if (!layoutSet.contains(obj) && obj instanceof IGraphicalEditPart) { |
| 176 |
IGraphicalEditPart ep = (IGraphicalEditPart)obj; |
| 177 |
ep.refresh(); |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
result = editParts; |
| 139 |
} |
182 |
} |
| 140 |
} |
183 |
}; |
| 141 |
|
|
|
| 142 |
if (editParts.isEmpty()) { |
| 143 |
return CommandResult.newOKCommandResult(); |
| 144 |
} |
| 145 |
|
| 146 |
Set layoutSet = new HashSet(editParts.size()); |
| 147 |
layoutSet.addAll(editParts); |
| 148 |
|
184 |
|
| 149 |
// refresh source and target connections of any shapes in the container not being considered for layout |
185 |
EditPartUtil.synchronizeRunnableToMainThread(containerEP, refreshRunnable); |
| 150 |
Iterator iter = containerEP.getChildren().iterator(); |
186 |
List editParts = (List)refreshRunnable.getResult(); |
| 151 |
while (iter.hasNext()) { |
187 |
if (editParts == null || editParts.isEmpty()) { |
| 152 |
Object obj = iter.next(); |
188 |
return CommandResult.newOKCommandResult(); |
| 153 |
if (!layoutSet.contains(obj) && obj instanceof IGraphicalEditPart) { |
|
|
| 154 |
IGraphicalEditPart ep = (IGraphicalEditPart)obj; |
| 155 |
ep.refresh(); |
| 156 |
} |
| 157 |
} |
189 |
} |
| 158 |
|
190 |
|
| 159 |
// add an arrange command, to layout the related shapes |
191 |
// add an arrange command, to layout the related shapes |