Deleting the root element from a child representation corrupts the session [message #1768912] |
Mon, 24 July 2017 17:29  |
Eclipse User |
|
|
|
In my VSM I have:
Diagram type A: semantic root element = parent
Diagram type B: semantic root element = child
Diagram B can be created and navigated to from Diagram A if "parent" contains "child".
If I delete "child" from within diagram A without creating or navigating to Diagram B, the semantic model is updated appropriately and everything works as expected. If, however, I create/navigate to diagram B and then later delete the "child" from the semantic model (change is triggered from an another view), I get the following error:
java.lang.NullPointerException
at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.getAllMandatoriesAdditionalLayers(DDiagramSynchronizer.java:343)
at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.activateNewMandatoryAdditionalLayers(DDiagramSynchronizer.java:310)
at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.refreshOperation(DDiagramSynchronizer.java:372)
at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.refresh(DDiagramSynchronizer.java:355)
at org.eclipse.sirius.diagram.business.internal.sync.DDiagramSynchronizer.refresh(DDiagramSynchronizer.java:91)
at org.eclipse.sirius.diagram.business.internal.dialect.DiagramDialectServices.refresh(DiagramDialectServices.java:254)
at org.eclipse.sirius.business.internal.dialect.DialectManagerImpl.refresh(DialectManagerImpl.java:123)
In my experience this error indicates a decoupling between the session and its resources. But I don't understand why this happens when a nested representation is created under the parent representation. I assumed that deleting the child from the semantic model would be gracefully handled by Sirius when multiple representations exist because other model add or change events seem to be handled ok. Even worse - when this delete error occurs it is not recoverable and the only resort is to shut down and start a new session.
Is there a "delete representation" command that I need to be using? I catch the "delete child" notification and promptly close the diagram editor before this NPE error occurs, but the outcome is unchanged.
[Updated on: Mon, 24 July 2017 17:32] by Moderator
|
|
|
|
|
Re: Deleting the root element from a child representation corrupts the session [message #1768990 is a reply to message #1768982] |
Tue, 25 July 2017 09:33   |
Eclipse User |
|
|
|
Hello,
Indeed, the fact that you remove the child element in another editing domain is important. I removed the element out of Eclipse, using a text editor, and the representation did not close by itself. Furthermore, if I refreshed the modeling project and switch back to the child representation it threw some exception but not like yours.
As a matter of fact, when you delete the child semantic element, even in the same editing domain, the child representation is not deleted, only closed. In your case, DiagramDialectServices#deleteRepresentation may do the trick, but you may need org.eclipse.sirius.ui.business.api.dialect.DialectUIServices.closeEditor(IEditorPart, boolean) instead.
Regards,
Steve
|
|
|
Re: Deleting the root element from a child representation corrupts the session [message #1769020 is a reply to message #1768990] |
Tue, 25 July 2017 14:12  |
Eclipse User |
|
|
|
Steve,
Thanks for the added perspective. DialectUIManager.INSTANCE#closeEditor does close the affected editor, but there seems to be a problem with DialectManger.INSTANCE#deleteRepresentation which does not return successfully. This is verified when I iterate through the representations via DialectManager.INSTANCE.getAllRepresentations. The affected representation still exists with its semantic target, although now the semantic child is orphaned from its parent (e.g. the child container is null). Maybe the #deleteRepresentation fails when the semantic target of a representation cannot be linked back to the model?
At this point I am having better luck just not calling the #deleteRepresentation command. Upon saving and reopening the session, the "dangling" representation will still exist, but at least at this point its semantic target is now null, so saving and reloading seems to at least perform the necessary model cleanup. I might be able to get by with my workaround but I would much prefer to figure out why representations cannot be purged. Is there something else I can try? Perhaps the repair script that I linked to earlier?
|
|
|
Powered by
FUDForum. Page generated in 0.07838 seconds