How to delete / remove a connection ? [message #1415360] |
Tue, 02 September 2014 11:49  |
Eclipse User |
|
|
|
Hi all,
Graphiti provides support for creating a connection like AbstractCreateConnectionFeature.
But I found no AbstractDelete/RemoveConnectionFeature. Is there a reason ?
Am I supposed to use DefaultDeleteFeature or DefaultRemoveFeature instead ?
Kind regards,
Laurent
|
|
|
|
|
|
|
|
|
Re: How to delete / remove a connection ? [message #1439793 is a reply to message #1438815] |
Tue, 07 October 2014 10:15   |
Eclipse User |
|
|
|
Except for the custom features, the feature provider is not queried when I select and right-click on a connection.
As a result, I get a context menu with inactive update, remove and delete actions.
Moreover, if I select nothing in the menu and click on my editor background, the context menu normally disappears and, only then, my feature provider is queried.
And only for the update feature (with a free form connection as picture element in the update context).
In debug mode, DiagramEditorContextMenuProvider.addDefaultMenuGroupRest calls addActionToMenuIfAvailable for update, remove and delete actions.
For the update action, isEnabled() calls UpdateAction.calculateEnabled() which surprisingly returns false because no selected pictogram element is found...
Therefore, the feature provider is not queried...
To sum up, it looks as if the free form connection selection is taken into account only after the context menu has been built, displayed and has disappeared...
And, even then, the remove and delete features are still not called.
|
|
|
|
Re: How to delete / remove a connection ? [message #1443918 is a reply to message #1441182] |
Mon, 13 October 2014 07:55  |
Eclipse User |
|
|
|
Hi Michael,
I finally found the cause... It is due to the workaround I set up, in relation with bug 428227, to filter out "selection changed" event to avoid NPE when closing editor.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=428227
As side effect, there was no picture element selected when calling isAvailable or calculatedEnabled methods in the delete, remove or any other action...
So I changed the initial workaround based on adding a part listener and simply adapted DiagramBehavior.selectPictogramElements to catch the NPE.
...
if (editParts.size() > 0) {
final EditPart editpart = editParts.get(0);
// if the editPart is newly created it is possible that his
// figure has not a valid bounds. Hence we have to wait for
// the UI update (for the validation of the figure tree).
// Otherwise the reveal method can't work correctly.
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
getDiagramContainer().getGraphicalViewer().reveal(editpart);
} catch (NullPointerException e) {
// Simply catch NPE as workaround for bug 428227
}
}
});
}
...
I'll update the bug details with a link to this topic...
Regards,
Laurent
|
|
|
Powered by
FUDForum. Page generated in 0.04706 seconds