Diagram tools create node location [message #1848497] |
Sun, 05 December 2021 12:51  |
Eclipse User |
|
|
|
Hi, I have a diagram with a few tools to create nodes. When a node is dropped on the diagram I want to trigger an arrange-all action.
The issue is that with my current implementation, the placement of the node happens after my layout is triggered. So the node is moved back to the cursor location.
Is there a way to either disable the action that moves the node to where it was dropped, or to add something like a post execution to happen after the node is fully placed?
Thanks in advance!
|
|
|
|
|
|
|
Re: Diagram tools create node location [message #1848713 is a reply to message #1848685] |
Tue, 14 December 2021 14:12   |
Eclipse User |
|
|
|
Hi Erik,
Oh right, I replied yesterday without reading again the previous posts and I forgot about the context, sorry. Indeed that explains the "blinking effect" that you have. Now that I think of it, I have an idea for a workaround that might be stupid (unless it works, then its genius), in your creation tool, before the "create instance" task (or equivalent you may have), have a set task (or java servce) that changes the DDiagram.setSynchronized to false. If a diagram is not syncrhonized, it will not display new semantic element, unless a view element is created for it. Normaly we would use a task "create view" for that, but we would end up with the same bliking effect. Instead, in your code that trigger the arrange request, just before that call, you set back DDiagram.setSynchronized to true. Hopefully that will sync the diagram and immediately trigger your custom ELK layout. If the new node is created to late, you may have to create it manually though. You can look at org.eclipse.sirius.diagram.business.internal.helper.task.operations.CreateViewTask for an example.
I do not guaranty that it will work, but it should be quick to give it a try. Either way, I am interested in your feedback on this :).
Best regards,
Steve
|
|
|
|
|
Re: Diagram tools create node location [message #1848955 is a reply to message #1848811] |
Sun, 26 December 2021 22:30   |
Eclipse User |
|
|
|
Hi again, sorry for the delay.
I think maybe something is wrong with using a set operation, or maybe I just misunderstood? The service is being called correctly, which sets synchronized to false on the diagram. But then the rollback happens because it is trying to find an eStructualFeature of the target of the diagram with whatever name I put in the set operation in the .odesign. But the target of the diagram is just a node from our model, which doesn't have any features with whatever name I give, so the rollback happens. I also tried it as a change context instead of a set operation, which throws:
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
I attached an image of the relevant parts in the odesign.
Thanks, and happy holidays!
Regards,
Erik
Attachment: odesign.jpg
(Size: 213.80KB, Downloaded 134 times)
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04236 seconds