Search code examples
ecoreeclipse-siriussirius

Can I invoke an Ecore Operation from Sirius


Is there any way within Sirius to have a user interaction (say, a double click) to invoke an Ecore-defined operation on the semantic element? Further details below.

I am using Xcore to define my metamodel. I have a situation like this:

enum Status
{
    Default
    Foo
    Bar
}

class ThingWithStatus
{
    Status status
}

class ContainerForThings
{
    contains ThingWithStatus[] thingList
    op void resetAllThingsStatus()
    {
        for (ThingWithStatus thing : thingList)
        {
            thing.status = Status::DEFAULT
        }
    }
}

Currently I have a diagram in Sirius with container nodes for ContainerForThings, with subnodes for ThingWithStatus. What I'd like to be able to do is to doubleclick on the container node in the diagram, and have the resetAllThingsStatus() operation run on the semantic element.

If there is no way to do this directly, is my best option to turn the EMF-generated Java code for resetAllThingsStatus() into an External Java Action that Sirius then calls?

Thanks in advance for your help. - SJ


Solution

  • If there is no way to do this directly, is my best option to turn the EMF-generated Java code for resetAllThingsStatus() into an External Java Action that Sirius then calls?

    Yes. If you have many EOperations you may want to do a generic service e.g. callEOperation(EObject onElement, String operationName), otherwise you will have as many methods as you have EOperations.