Delete Connection of a Node Programmatically [message #1006664] |
Fri, 01 February 2013 06:13  |
Eclipse User |
|
|
|
Hello!
I have a structure like this:
Node A ---(1)---> Node B ---(2)---> Node C
If I delete connection (1) I would like to also delete connection (2) between node B and C. The connections are of a different type.
Does anybody know a solution how to access and delete connection (2)?
Thank you very much!
Here is the remove of Connection (1) (after the confirmation of a dialog):
protected Command getDestroyElementCommand(DestroyElementRequest req) {
DestroyElementCommand cmd = new DestroyElementCommand(req) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
Shell shell = new Shell(SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
boolean result = MessageDialog.openQuestion(shell, Messages.StateTransitionDeleteQuestionTitle, Messages.StateTransitionDeleteQuestion);
if (result) {
// OK Button selected
return super.doExecuteWithResult(monitor, info);
} else {
// Cancel Button selected
return CommandResult.newCancelledCommandResult();
}
}
};
return getGEFWrapper(cmd);
}
|
|
|
|
Re: Delete Connection of a Node Programmatically [message #1014460 is a reply to message #1007104] |
Mon, 25 February 2013 16:45  |
Eclipse User |
|
|
|
Hi Daniel,
Check the generated policies package.
There should be a class named StateTransitionContinuousSemanticEditPolicy (just a guess based on the code above).
There you will find
/**
* @generated
*/
protected Command getDestroyElementCommand(DestroyElementRequest req) {
return getGEFWrapper(new DestroyElementCommand(req));
}
You could override this method by traversing to connection (2) via Node (B) and chain another Command with the corresponding DestroyElementRequest for connection (2) to the Command provided by this method.
This way, you would delete connection (1) and (2), but preserve the nodes.
Regards Thomas
[Updated on: Mon, 25 February 2013 16:45] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03876 seconds