Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Moving elements to the back on creation
Moving elements to the back on creation [message #1861524] Tue, 17 October 2023 10:45 Go to next message
Lukas-Angelo Meier is currently offline Lukas-Angelo MeierFriend
Messages: 8
Registered: May 2023
Junior Member
Hello,

I made a tool to create an element and now i would like these elements to always be in the back behind other elements. I can manually do this in the context menu for each element, but i would like this to be done automatically on creation.

How can i achieve this behavior?

What i found so far is "org.eclipse.sirius.diagram.tools.api.command.view.SendElementsToBack", however i am unsure if this is for edges only and how to implement it properly.

I thought of using a IExternalJavaAction, but i don't know how to get the view required by this (SendElementsToBack) class.

Any help is appreciated.
Re: Moving elements to the back on creation [message #1861659 is a reply to message #1861524] Wed, 25 October 2023 14:47 Go to previous message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Hi.

You cant't do it directly inside the body of your creation tool, as you need to manipulate the order of the GMF View element for the new node, which will only exist after Sirius has refreshed the state of the diagram, which happens after your tool has executed.

You *may* be able to do it using a ModelChangeTrigger, which can perform changes in the model before a change is commited (it's a pre-commit listener in EMF Transaction parlance).
It's quite involved if you're not familiar with all the APIs involved, but some pointers:

* Ecore Tools has examples of https://github.com/eclipse-ecoretools/ecoretools/blob/master/org.eclipse.emf.ecoretools.design/plugin.xml#L24, for example https://github.com/eclipse-ecoretools/ecoretools/blob/master/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/service/AutosizeTrigger.java
* You'll need to have a SessionListener to install your ModelChangeTrigger, see https://github.com/eclipse-ecoretools/ecoretools/blob/master/org.eclipse.emf.ecoretools.design/src/org/eclipse/emf/ecoretools/design/internal/EcoreToolsSessionListener.java for an example
* The SessionListener itself needs to be registered with an extension point. See https://github.com/eclipse-ecoretools/ecoretools/blob/master/org.eclipse.emf.ecoretools.design/plugin.xml#L24.
* Assuming all of this is properly setup, your ModelChangeTrigger will need to identify changes which correspond to the invocation of your tool/creation of the new element, find the GMF Node that Sirius/GMF will have created to represent it, and use code similar to "ViewUtil.repositionChildAt(containerView, view, 0)" (found in SendElementsToBack) to move the new Node as the first of its siblings (which corresponds to placing it below all of them).



Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Domain/Element-based edge issue
Next Topic:How to bundle a Sirius modeler after creating the .aird
Goto Forum:
  


Current Time: Thu May 09 11:20:49 GMT 2024

Powered by FUDForum. Page generated in 0.03060 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top