|Reconnect tool Precondition : I can't access to otherEnd and edgeView variables [message #1853006]
||Tue, 14 June 2022 14:45
Hello everybody, |
I'm developing a Reconnect tool for the UML ContainmentLink in a Sirius based UML ClassDiagram for Papyrus). I would like to write a precondition to be able to check the enablement of the tool.
On the previous image, the link means that Package_TARGET is owned by Package_SOURCE.
I want to create a precondition to forbid the reconnection on the source side from Package_SOURCE to Class_SOURCE, because a such containment is forbidden (Class_SOURCE can't contain Package_TARGET).
Firstly, in the precondition field I declared a service like that:
//target is the new source!
and in my java class, I declared a method like that:
public boolean reconnectContainmentLinkPrecondition(Element context, Element target)
//context is the old source
//target is the new source
-> it works fine, the method is called.
Now I want to add a validation of the target (Package_TARGET side), so I need to access to the other end (the target) of the link. I tried "otherEnd" like proposed in the documentation (and I also tried "edgeView" to try to access to the other end, like proposed here :, but without success, I never enter in my java method with this new argument.
Debugging, I saw that these variables are not registered in the IInterpreter (org.eclipse.sirius.diagram.ui.graphical.edit.policies.SiriusGraphicalNodeEditPolicy.getBestTool(EdgeMapping, boolean, EdgeTarget, EdgeTarget, DEdge, boolean).
I also found this bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=476523 and its associated draft : https://git.eclipse.org/r/c/sirius/org.eclipse.sirius/+/55181.
Please could you indicate me if there is another way to access to the otherEnd ?
|Re: Reconnect tool Precondition : I can't access to otherEnd and edgeView variables [message #1853265 is a reply to message #1853006]
||Fri, 24 June 2022 13:31
Firstly, as explained in the bug you noticed, https://bugs.eclipse.org/bugs/show_bug.cgi?id=476523, the variable otherEnd is not available during precondition evaluation. It is only available in execution of the reconnect tool. So currently, there is no way to use this variable in precondition. Except if the enhancement 476523 is implemented in a future version of Sirius.
A workaround is to call the method "reconnectContainmentLinkPrecondition" during the reconnection execution.
The only problem with this solution is that the end user will feel like they can do the reconnect (no forbidden sign). However, the tool will actually do nothing.
It is possible to throw an OperationCanceledException instead of returning false. Therby, a message will be display in the error log to explain why the tool does nothing.
throw new OperationCanceledException("This message explains why nothing is happening...");
For information, we will try to investigate the bugzilla to integrate it in a future version.
Laurent Redor - Obeo
Need training or professional services for Sirius?
Powered by FUDForum
. Page generated in 0.01952 seconds