Get semantic element of a selected Sirius element in command handler without depending on Sirius? [message #1861388] |
Tue, 10 October 2023 12:52 |
Matt Windsor Messages: 13 Registered: July 2022 |
Junior Member |
|
|
Hi,
I have a command handler in a plugin that is expecting a semantic EMF element to be the most recent selection in the Eclipse selection service, and a separate Sirius plugin. Everything works fine when the handler is invoked on the element directly e.g. through its node in the project explorer, but if a Sirius diagrammatic representation of that element is selected (i.e. I'm invoking the command handler from a service called in a Sirius-specified popup menu) then the selection service receives the Sirius metamodel representation (for instance, in Sirius 6 I'm seeing a DNodeContainerEditPart appear).
Is there any way to retrieve the semantic element from the diagrammatic representation, or get the semantic element to broadcast through the selection service, without inducing a hard dependency on Sirius in the plugin containing the command? I'd rather not have such a dependency as the command plugin is not graphical in any way, it's just being invoked from a graphical context.
I tried seeing if the representation can be retrieved through the Eclipse adapter pattern (i.e. seeing whether the diagram node could be adaptable to the semantic element) but that didn't seem to work. And I imagine that, to know that the object has a semantic element I can access, I'd need to cast it to a Sirius class, which would presumably require a Sirius dependency.
So far my solution is to have the Sirius popup menu action that calls the command stuff the semantic element into a variable through a source provider, and then have the command handler check for the variable. This means neither side is aware of the other, but is very ugly.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02600 seconds