|
Re: Moving elements to the back on creation [message #1861659 is a reply to message #1861524] |
Wed, 25 October 2023 14:47 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03060 seconds