Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Using a Java Service in a TreeItemStyleDescription
Using a Java Service in a TreeItemStyleDescription [message #1549644] Tue, 06 January 2015 17:01 Go to next message
Frédéric Botron is currently offline Frédéric BotronFriend
Messages: 9
Registered: December 2014
Junior Member
It's me again Smile

Still using Sirius 1.0.1, I would like to display the elements of my tree-based editor using an unified format: eClass name <space> object id (the same format as in EMF's generated editor).

So I defined a Java Service, which is a public class with an empty public zero-argument constructor. Inside this Java Service I implemented the following method:

public String getDisplayName(EObject eObject) {
    EAttribute eAttribute = eObject.eClass().getEIDAttribute();
    if (eAttribute == null) {
        return eObject.eClass().getName();
    } else {
        return eObject.eClass().getName() + ' ' + eObject.eGet(eAttribute);
    }
}


I then added a <JavaExtension> as a child of my <Viewpoint> element, using the FQN of my Java Service.

But when I use expression [self.getDisplayName() /] or [getDisplayName() /] as a <TreeItemStyleDescription> label, I get the following error in the console:
org.eclipse.acceleo.engine.AcceleoEvaluationException: Argument types mismatch for module element dynamicModuleQuery80.
	at org.eclipse.acceleo.engine.generation.AcceleoEngine.doEvaluate(AcceleoEngine.java:401)
	at org.eclipse.acceleo.engine.generation.AcceleoEngine.evaluate(AcceleoEngine.java:203)
	at org.eclipse.acceleo.engine.service.AcceleoEvaluationTask.evaluateQuery(AcceleoEvaluationTask.java:122)
	at org.eclipse.acceleo.engine.service.AcceleoEvaluationTask.call(AcceleoEvaluationTask.java:291)
	at org.eclipse.sirius.common.acceleo.mtl.business.internal.interpreter.DynamicAcceleoModule.evaluate(DynamicAcceleoModule.java:531)
[...]


The name of the Java Service method seems to be correctly resolved, because when I change the label expression with a non-existing method name, I get the following error in the console:

!MESSAGE Compilation error for expression [getDisplayNamez() /] : Cannot find operation (getDisplayNamez()) for the type (ConfigurationDataFile)

(ConfigurationDataFile is the EMF class corresponding to the root object displayed in my tree)

What did I do wrong ?
Re: Using a Java Service in a TreeItemStyleDescription [message #1550783 is a reply to message #1549644] Wed, 07 January 2015 08:07 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi Frédéric,

To use Acceleo 3 expression in your odesign, you must reference the
metamodels on which your representations works. You can add these
references on Viewpoint through the properties view in the Metamodels
tab. These references must be of the form
"platform:/plugin/ProjectName/..." then you must have your metamodels
plugins deployed before. Finally when testing your odesign, it must also
be deployed to avoid kind of errors like you have. Then when using
Acceleo 3 you must works with 3 instances :

- one for your metamodels plugins
- one for your odesign plugin
- and a last one for your model on which you test your odesign.

Is it the case?

Best Regards.

Le 06/01/2015 18:01, Frédéric Botron a écrit :
> I then added a <JavaExtension> as a child of my <Viewpoint> element,
> using the FQN of my Java Service.
> But when I use expression [self.getDisplayName() /] or [getDisplayName()
> /] as a <TreeItemStyleDescription> label, I get the following error in
> the console:



--
Esteban Dugueperoux - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Using a Java Service in a TreeItemStyleDescription [message #1551417 is a reply to message #1550783] Wed, 07 January 2015 16:10 Go to previous messageGo to next message
Frédéric Botron is currently offline Frédéric BotronFriend
Messages: 9
Registered: December 2014
Junior Member
Hi and thank you for your support,

I am not able to make the 3-instance solution work. To sum up, I have :


    One main Eclipse instance with the 3 plugins generated by EMF:

      com.mycompany.siriustest.model
      com.mycompany.siriustest.model.edit
      com.mycompany.siriustest.model.editor

    One second Eclipse instance (launched by the first one) with the following plugin:

      com.mycompany.siriustest.design containing my .odesign file and the Java Service

    One third Eclipse instance (launched by the second one) with the following plugin:

      com.mycompany.siriustest.sample



I referenced the meta-model in my Viewpoint, as you told me. But:
- when I edit the .odesign file, the methods of the Java Service never appear when I try to use completion in an expression (using the service:method syntax or the [ method() /] syntax)
- when I test my .odesign with an EMF model, no label appears. With the second syntax, I get the following error message in the console:
Cannot find operation (method()) for the type (ConfigurationDataFile)
With the first syntax, no error message is displayed.

BUT

If I keep my 2-instance initial setup with:

    The main Eclipse instance

      com.mycompany.siriustest.model
      com.mycompany.siriustest.model.edit
      com.mycompany.siriustest.model.editor
      com.mycompany.siriustest.design.service
      : contains a Java Service

    A second Eclipse instance launched from the first one

      com.mycompany.siriustest.design: contains an empty Java Service extending the one in com.mycompany.siriustest.design.service
      com.mycompany.siriustest.sample



THEN I can use Java Service in labels, with syntax service: (the second one does not work). And the completion works fine too. I just have to restart the second instance once I modify the implementation of my Java Service, which seems normal.

The only remaining problem with this setup is the following: Java Services do not seem to work in pre-conditions, for example in a <TreeItemCreationTool>. My method (whose return type is a boolean), is never invoked and the corresponding creation tool appears in the context menu whatever the case. Nevertheless the method, with the right signature, appears as a suggestion completion in the "precondition" field of the Sirius editor.

Is there a limitation with preconditions, or did I do something wrong with my precondition method ?

Its signature is:
public boolean canCreateSiblingInContainer(EObject self, EClass container);

and the syntax of my precondition is:
service:canCreateSiblingInContainer(container)
Re: Using a Java Service in a TreeItemStyleDescription [message #1552996 is a reply to message #1551417] Thu, 08 January 2015 12:43 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi Frédéric,

I think that your second solution with only 2 Eclipse instances work
because you have your java service in the first one while it was not the
case with the first proposed solution.

After about your issue on precondition evaluation with java service
call, I'm not aware of this kind of issue and this should works. Could
you raise a bugzilla about this issue with a test case and a scenario?

Best Regards.

Le 07/01/2015 17:10, Frédéric Botron a écrit :
> Hi and thank you for your support,
>
> I am not able to make the 3-instance solution work. To sum up, I have :
>
>
> One main Eclipse instance with the 3 plugins generated by EMF:
>
> com.mycompany.siriustest.model
> com.mycompany.siriustest.model.edit
> com.mycompany.siriustest.model.editor
>
> One second Eclipse instance (launched by the first one) with the
> following plugin:
>
> com.mycompany.siriustest.design containing my .odesign file and the Java
> Service
>
> One third Eclipse instance (launched by the second one) with the
> following plugin:
>
> com.mycompany.siriustest.sample
>
>
>
> I referenced the meta-model in my Viewpoint, as you told me. But:
> - when I edit the .odesign file, the methods of the Java Service never
> appear when I try to use completion in an expression (using the
> service:method syntax or the [ method() /] syntax)
> - when I test my .odesign with an EMF model, no label appears. With the
> second syntax, I get the following error message in the console:
> Cannot find operation (method()) for the type (ConfigurationDataFile)
> With the first syntax, no error message is displayed.
>
> BUT
>
> If I keep my 2-instance initial setup with:
>
> The main Eclipse instance
>
> com.mycompany.siriustest.model
> com.mycompany.siriustest.model.edit
> com.mycompany.siriustest.model.editor
> com.mycompany.siriustest.design.service: contains a Java Service
>
> A second Eclipse instance launched from the first one
>
> com.mycompany.siriustest.design: contains an empty Java Service
> extending the one in com.mycompany.siriustest.design.service
> com.mycompany.siriustest.sample
>
>
>
> THEN I can use Java Service in labels, with syntax service: (the second
> one does not work). And the completion works fine too. I just have to
> restart the second instance once I modify the implementation of my Java
> Service, which seems normal.
>
> The only remaining problem with this setup is the following: Java
> Services do not seem to work in pre-conditions, for example in a
> <TreeItemCreationTool>. My method (whose return type is a boolean), is
> never invoked and the corresponding creation tool appears in the context
> menu whatever the case. Nevertheless the method, with the right
> signature, appears as a suggestion completion in the "precondition"
> field of the Sirius editor.
>
> Is there a limitation with preconditions, or did I do something wrong
> with my precondition method ?
>
> Its signature is:
>
> public boolean canCreateSiblingInContainer(EObject self, EClass container);
>
> and the syntax of my precondition is:
> service:canCreateSiblingInContainer(container)
>



--
Esteban Dugueperoux - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Using a Java Service in a TreeItemStyleDescription [message #1553346 is a reply to message #1552996] Thu, 08 January 2015 16:53 Go to previous messageGo to next message
Frédéric Botron is currently offline Frédéric BotronFriend
Messages: 9
Registered: December 2014
Junior Member
Sorry, I made a mistake in my precondition by using a literal, which is not supported as explained in your documentation. There is no bug there.

Nevertheless, I don't understand why the service:operation / service:operation() syntax works, but not the [self.operation() /] one. My modeling .sample project is opened in an Eclipse instance where my Java Service has been deployed (in the .design project).
Re: Using a Java Service in a TreeItemStyleDescription [message #1565343 is a reply to message #1553346] Thu, 15 January 2015 08:11 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi Frédéric,

[self.operation() /] should work as service:operation /
service:operation() , do you have added
"org.eclipse.sirius.common.acceleo.mtl" plugin as dependency of you
plugin where you have you odesign and java service?

Best Regards.

Le 08/01/2015 17:53, Frédéric Botron a écrit :
> Sorry, I made a mistake in my precondition by using a literal, which
> is not supported as explained in your documentation. There is no bug there.
>
> Nevertheless, I don't understand why the service:operation /
> service:operation() syntax works, but not the [self.operation() /] one.
> My modeling .sample project is opened in an Eclipse instance where my
> Java Service has been deployed (in the .design project).



--
Esteban Dugueperoux - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Using a Java Service in a TreeItemStyleDescription [message #1706160 is a reply to message #1565343] Mon, 24 August 2015 09:46 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Hi!

I can't understand the purpose of the second Eclipse instance.

It seems that everithing except Acceleo interpreter works in the one Eclipse instance.

The only thing that doesn't work is Acceleo interpreter:
https://www.eclipse.org/forums/index.php/t/1066702/
https://www.eclipse.org/forums/index.php/t/781784/

But I don't understand why it needs a second intstance.
I've deployed the sample metamodel as Eclipse plugin:

  • org.eclipse.sirius.sample.basicfamily_1.0.0.201508241127.jar
  • org.eclipse.sirius.sample.basicfamily.edit_1.0.0.201508241127.jar
  • org.eclipse.sirius.sample.basicfamily.editor_1.0.0.201508241127.jar

After that I run the first Eclipse instance with two projects

  • org.eclipse.sirius.sample.basicfamily.design
  • basicfamily.sample

Acceleo interpreter doesn't work.

But! When I run first Eclipse instance with empty workspace, and after that I run second Eclipse instance from the first one with the same projects, Acceleo interpreter works!!! What is the purpose of that intermediate Eclipse instance with empty workspace?
Re: Using a Java Service in a TreeItemStyleDescription [message #1706190 is a reply to message #1706160] Mon, 24 August 2015 14:55 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi Denis,

Can you try using the latest release of Sirius, i.e. 3.0 [1] and using
service interpreter instead of Acceleo 3 ?

[1] https://wiki.eclipse.org/Sirius

Best Regards.

Le 24/08/2015 11:46, Denis Nikiforov a écrit :
> Hi!
>
> I can't understand the purpose of the second Eclipse instance.
>
> It seems that everithing except Acceleo interpreter works in the one
> Eclipse instance.
>
> The only thing that doesn't work is Acceleo interpreter:
> https://www.eclipse.org/forums/index.php/t/1066702/
> https://www.eclipse.org/forums/index.php/t/781784/
>
> But I don't understand why it needs a second intstance.
> I've deployed the sample metamodel as Eclipse plugin:
>
> org.eclipse.sirius.sample.basicfamily_1.0.0.201508241127.jar
> org.eclipse.sirius.sample.basicfamily.edit_1.0.0.201508241127.jar
> org.eclipse.sirius.sample.basicfamily.editor_1.0.0.201508241127.jar
>
> After that I run the first Eclipse instance with two projects
>
> org.eclipse.sirius.sample.basicfamily.design
> basicfamily.sample
>
> Acceleo interpreter doesn't work.
>
> But! When I run first Eclipse instance with empty workspace, and after
> that I run second Eclipse instance from the first one with the same
> projects, Acceleo interpreter works!!! What is the purpose of that
> intermediate Eclipse instance with empty workspace?



--
Esteban Dugueperoux - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Using a Java Service in a TreeItemStyleDescription [message #1706216 is a reply to message #1706190] Tue, 25 August 2015 05:57 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Hi

It works in both scenarios: with single Eclipse instance and with two instances!

1) I started single Eclipse instance.
2) After that I've added two projects into workspace "org.eclipse.sirius.sample.basicfamily.design" and "basicfamily.sample".
3) I've added Java Extension into basicfamily.odesign with class "org.eclipse.sirius.sample.basicfamily.services.FamilyServices".
4) And set label of the ManNode to "service:getMembersWithoutMother".

And it works! It shows list of persons.
Re: Using a Java Service in a TreeItemStyleDescription [message #1706255 is a reply to message #1706216] Tue, 25 August 2015 11:34 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Is it possible to let Acceleo interpreter work in a single Eclipse instance? I think it will simplify a development process.

UPDATE: Sorry for flood. Acceleo interpreter works now in a single Eclipse instance too. I don't understand what was changed in my Eclipse settings or projects, but it works.

[Updated on: Tue, 25 August 2015 13:12]

Report message to a moderator

Re: Using a Java Service in a TreeItemStyleDescription [message #1706282 is a reply to message #1706255] Tue, 25 August 2015 13:10 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Sorry for flood. Acceleo interpreter works now in a single Eclipse instance too. I don't understand what was changed in my Eclipse settings or projects, but it works.
Re: Using a Java Service in a TreeItemStyleDescription [message #1706283 is a reply to message #1706255] Tue, 25 August 2015 13:11 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Sorry for flood. Acceleo interpreter works now in a single Eclipse instance too. I don't understand what was changed in my Eclipse settings or projects, but it works.
Re: Using a Java Service in a TreeItemStyleDescription [message #1706284 is a reply to message #1706255] Tue, 25 August 2015 13:12 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Sorry for flood. Acceleo interpreter works now in a single Eclipse instance too. I don't understand what was changed in my Eclipse settings or projects, but it works.
Re: Using a Java Service in a TreeItemStyleDescription [message #1706289 is a reply to message #1706255] Tue, 25 August 2015 13:21 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi,

From Sirius 3.0, there is the new AQL interpreter [1] and the existing
service interpreter [2] has been improved. With this 3.0 release, with
your metamodel plugins deployed you can have java service in workspace
called from the VSM in this same workspace. Then only 2 Eclipse
instances are needed, a first one for your metamodel plugins and a
second one for your viewpoint specification project and your modeling
projet to test your modeler.

[1] http://cedric.brun.io/eclipse/introducing-aql/
[2]
https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html#specialized

Best Regards.

Le 25/08/2015 13:34, Denis Nikiforov a écrit :
> Is it possible to let Acceleo interpreter work in a single Eclipse
> instance? I think it will simplify a development process.



--
Esteban Dugueperoux - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Using a Java Service in a TreeItemStyleDescription [message #1706364 is a reply to message #1706289] Wed, 26 August 2015 09:40 Go to previous message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 344
Registered: August 2013
Senior Member
Hi

Thanks! That's really cool! I think in most cases ocl will be enough for me.

PS: Oops, I didn't want to send so many messages
Previous Topic:What should I use for UI and user actions?
Next Topic:Compilation error for expression XYZ, headless mode
Goto Forum:
  


Current Time: Wed Apr 24 15:03:50 GMT 2024

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

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

Back to the top