Command in EditHelperAdvice [message #1782835] |
Fri, 02 March 2018 05:55  |
Eclipse User |
|
|
|
Hello everyone,
I created a new elementtype (derived from InvariantState) and I can add it to a sequence diagram. Well.
First, a stereotype is applied (thanks to a "Specialization Type Configuration"). Then, through an EditHelperAdvice class, a popup dialog box is opened to set an attribute of the stereotype. As a side option in the popup, I put a button to enable an easy access to another diagram.
What I want to obtain is the following behavior:
When the user click on the button:
- The pop up box is closed,
- The element is not created on the diagram (or delete immediately)
- And the wanted diagram is opened.
Unfortunately, I can't obtain this full behavior. Here is my simplified code (see comments in code)
@Override
protected ICommand getAfterConfigureCommand(final ConfigureRequest request) {
Shell shell = Display.getCurrent().getActiveShell();
EObject elementToConfigure = request.getElementToConfigure();
/*
* some tests
*/
CompositeCommand compositeCommand = new CompositeCommand("Configure created element");
// Create the dialogbox function of StateInvariant present on the lifeline
DialogBox dialog = new DialogBox(shell, elementToConfigure);
dialog.open();
if (IDialogConstants.OK_ID == dialog.getReturnCode()) {
//This is the standard case, not the problematic one
ICommand configureCommand = new ConfigureStateInvariantCommand(request, dialog.getSelectedEObject());
compositeCommand.add(configureCommand);
} else if (IDialogConstants.ABORT_ID == dialog.getReturnCode()) {
// the dialog box returns the ABORT_ID code when the famous button is clicked
ModelSet modelSet = getCurrentModelSet();
Resource notationResource = NotationUtils.getNotationResource(modelSet);
List<Diagram> diagramList = NotationUtils.getDiagrams(notationResource, dialog.getService());
for (Diagram diagram : diagramList) {
OpenDiagramCommand openDiagramCommand = new OpenDiagramCommand(modelSet.getTransactionalEditingDomain(), diagram);
compositeCommand.add(openDiagramCommand);
}
IElementEditService service = ElementEditServiceUtils.getCommandProvider(elementToConfigure);
DestroyElementRequest destroyRequest = new DestroyElementRequest(elementToConfigure, false);
compositeCommand.add(service.getEditCommand(destroyRequest));
}
return compositeCommand;
}
When I test this code and click on the famous button, the diagram that I want to open is opened but the element to create is not well destroyed. It is destroyed in the model but not in the diagram and I have an error message when reopening the model (dangling stereotype).
Is it a bug of the DestroyElementCommand or anything else?
What could be the workaround for this use case? I already tried to open directly the diagram in the listener of the button without success. Help would be greatly appreciated.
Thank you for reading.
Yoann.
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07797 seconds