Hi,
I have a query to call Arrange All (Arrange Selection) when creating an edge. I need to call Arrange All (Arrange Selection) when creating an edge between nodes.
I tried two ways:
1. Register NodeListener to DiagramEditPart
// node listener
getDiagramEditPart().addNodeListener(new NodeListener() {
@Override
public void targetConnectionAdded(ConnectionEditPart arg0, int arg1) {
// call Arrange Selection
}
...
});
but for some reason the targetConnectionAdded method does not call at all when creating an edge.
2. Add External Java Action to Create Edge in VSM (odesign), see picture.
And the implementation of IExternalJavaAction that calls Arrange All.
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
if (selections == null || selections.isEmpty()) {
return;
}
IEditorPart editor = EclipseUIUtil.getActiveEditor();
if (editor instanceof DiagramEditor) {
DiagramEditor diagramEditor = (DiagramEditor) editor;
DiagramEditPart diagramEditPart = diagramEditor.getDiagramEditPart();
ArrangeRequest arrangeRequest = new ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL);
List<Object> partsToArrange = new ArrayList<>(1);
partsToArrange.add(diagramEditPart);
arrangeRequest.setPartsToArrange(partsToArrange);
diagramEditPart.performRequest(arrangeRequest);
Command command = diagramEditPart.getCommand(arrangeRequest);
if (command != null) {
command.execute();
}
}
}
This works, but only for already created edges (existing in the diagram), not for the edge that is being created in the diagram.
But I need Arrange Selection to get on the edge that is being created.
I would say the problem is that GMF (Sirius) does not yet have an updated context on the new edge "does not know" when creating an edge.
Is there an option to call Arrange Selection on the edge that is being created?
Thanks for every advice.
Martin
[Updated on: Mon, 23 October 2017 08:06] by Moderator