ELK Auto Layout - Get Class names of ELKNodes [message #1848460] |
Thu, 02 December 2021 17:18  |
Eclipse User |
|
|
|
Is it possible to get the class names of the object that an ELKNode is representing? For example, in the picture Element1 and Element2 have class names of Data Element which extends org.eclipse.emf.ecore.EObject. Any way to extract this information inside my auto-layout algorithm that extends org.eclipse.elk.core.AbstractLayoutProvider.
My model has different objects that I want to group together during auto layout
[Updated on: Thu, 02 December 2021 17:36] by Moderator
|
|
|
|
Re: ELK Auto Layout - Get Class names of ELKNodes [message #1848467 is a reply to message #1848464] |
Fri, 03 December 2021 03:24   |
Eclipse User |
|
|
|
Hi Jonathan,
I'm not sure to understand. Do you want to have access to the class name of the semantic element representing by the DDiagramElement? When you are in the "ELK world", this is the case when you are doing your own layout by extending AbstractLayoutProvider, there is no link between ELK Node and GMF/Sirius elements.
If your algorithm needs this kind of information, I think there is a way. You have to add specific properties to ELKNode before the algorithm is called, through org.eclipse.elk.graph.properties.IPropertyHolder.setProperty(IProperty<? super T>, T). For example : node.setProperty(MyIPropertyForSemanticName, stringRepresentingTheSemanticClassName).
And for that, you can use the extension point "org.eclipse.sirius.diagram.elk.layout.extension" to add this property with the method org.eclipse.sirius.diagram.elk.IELKLayoutExtension.beforeELKLayout(LayoutMapping). This extension point is experimental but I think this is the only way to do what you expect (if I understand correctly).
Best regards,
Laurent
|
|
|
|
|
|
|
|
|
Re: ELK Auto Layout - Get Class names of ELKNodes [message #1849294 is a reply to message #1848467] |
Tue, 11 January 2022 15:08  |
Eclipse User |
|
|
|
I've successfully added a new property to the respective nodes.
String elementName = siriusDiagramElement.eClass().getName();
IProperty<String> property = new Property("ObjectName");
entry.getKey().setProperty(property, elementName);
Now inside, my LayoutProvider, I would like to retrieve the property. From the documentation it seems I'm supposed to use the auto-generated LayoutOptions file for provided properties. How would I retrieve this custom property that I've added?
[Updated on: Tue, 11 January 2022 15:09] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.07057 seconds