Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Get semantic element of a selected Sirius element in command handler without depending on Sirius?
Get semantic element of a selected Sirius element in command handler without depending on Sirius? [message #1861388] Tue, 10 October 2023 12:52 Go to next message
Matt Windsor is currently offline Matt WindsorFriend
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.
Re: Get semantic element of a selected Sirius element in command handler without depending on Sirius [message #1861400 is a reply to message #1861388] Wed, 11 October 2023 09:53 Go to previous message
Matt Windsor is currently offline Matt WindsorFriend
Messages: 13
Registered: July 2022
Junior Member
Fixed this myself and with no Sirius-specific approaches: I've found that I can just execute the command with a custom IEvaluationContext that sets ISources.ACTIVE_CURRENT_SELECTION_NAME to the semantic object in a StructuredSelection.
Previous Topic:Tuning genmodel parameters to change XMI file
Next Topic:Invoking java services on a double click action
Goto Forum:
  


Current Time: Thu Dec 05 16:32:30 GMT 2024

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

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

Back to the top