Reconnect Edge with ReconnectSourceNodeCommand [message #1745380] |
Sun, 09 October 2016 14:07  |
Eclipse User |
|
|
|
Hey,
I try to programmatically reconnect an DEdge with an org.eclipse.sirius.diagram.tools.internal.command.reconnect.ReconnectSourceNodeCommand
From the doExecute() method of the command I can see, that this command just sets the DEdge's SourceNode and it's target.
Now I tried to implement this via a JavaService which is triggered when I delete an DEdge in my Diagram (using an "Delete Element" tool in the viewpoint).
In my JavaService I then search my DDiagram for the new EdgeTarget (the reconnectionTarget of my DEdge).
When I got it, I create a new ReconnectSourceNodeCommand, since the EdgeTarget is indeed an org.eclipse.sirius.diagram.DNode I create the command like this:
ReconnectSourceNodeCommand cmd = new ReconnectSourceNodeCommand(TransactionUtil.getEditingDomain(diagram),
edge, edgeTarget, edgeTarget.getTarget());
After I executed it, everything looks just fine. The edge.getTarget() returns exactly the desired new source EObject.
But somehow this does not last. In the diagram there is zero change for the DEdge's source after all, it seems the command gets redone anywhere.
I'm stuck right now.
Does anyone know how to properly reconnect source/target EObject of an DEdge programmatically?
Thanks in advance.
|
|
|
Re: Reconnect Edge with ReconnectSourceNodeCommand [message #1745434 is a reply to message #1745380] |
Mon, 10 October 2016 11:55  |
Eclipse User |
|
|
|
Hi.
The ReconnectSourceNodeCommand is internal and should not be used by client code. The DEdge and related model elements are the internal data model used by Sirius, and as a general rule you should not modify them directly (there are exceptions, but it doesn't look like your use case would involve that). They correspond to the application of the rules you have defined in your VSM (the .odesign) to the current state of you semantic model, and Sirius makes sure they are always in sync. This is why the change you made does not last: on the next refresh (the internal synchronization process) Sirius re-applies the rules defined in your VSM (which have not changed) on your semantic model (which has not changed), and updates the DEdge (and DNodes, etc.) to match.
If you want to simulate programmatically the effect of an end-user graphically reconnecting an edge, all you have to do is to modify your semantic model itself to perform the same change your reconnect tool was configured to do. Depending on your VSM this may be simply changing a single reference, or it may involve more complex model changes. Once the change is applied, the next Sirius refresh will re-appply the rules defined in your VSM (which have not changed) on your semantic model, which this time has changed, and will update the DEdge (technically it will create a new one, but the visual effect is the same).
Regards,
Pierre-Charles
--
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Powered by
FUDForum. Page generated in 0.02887 seconds