Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » How to call own Java Method in Sirius
How to call own Java Method in Sirius [message #1847407] Tue, 26 October 2021 11:21 Go to next message
Hakan  Yüksek is currently offline Hakan YüksekFriend
Messages: 22
Registered: October 2021
Junior Member
Hi, I want to call my own java method when the user clicked to the diagram element. How can I do it? I can not use Services class in VSP. What should I do? Should I use the External Java Actions? Is there any tutorial for external java actions?
Re: How to call own Java Method in Sirius [message #1847498 is a reply to message #1847407] Fri, 29 October 2021 07:47 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 651
Registered: July 2009
Senior Member
You mention "when the user clicked to the diagram element". Do you mean a single click? There is no action triggered by Sirius in this case, a single click simply sets the selection.
If you mean double-click, you can define a "Double Click Tool" on the corresponding mapping, and perform whatever action you want in the body of the too.

External Java Actions are documented here: https://www.eclipse.org/sirius/doc/specifier/general/Model_Operations.html#external_java_action

Why can't you use Java services? They have pretty minimal requirements (especially compared to External Java Actions) and can be used anywhere an interpreted expression is used.


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: How to call own Java Method in Sirius [message #1847609 is a reply to message #1847498] Tue, 02 November 2021 10:17 Go to previous messageGo to next message
Hakan  Yüksek is currently offline Hakan YüksekFriend
Messages: 22
Registered: October 2021
Junior Member
Pierre-Charles David wrote on Fri, 29 October 2021 07:47
You mention "when the user clicked to the diagram element". Do you mean a single click? There is no action triggered by Sirius in this case, a single click simply sets the selection.
If you mean double-click, you can define a "Double Click Tool" on the corresponding mapping, and perform whatever action you want in the body of the too.

External Java Actions are documented here: https://www.eclipse.org/sirius/doc/specifier/general/Model_Operations.html#external_java_action

Why can't you use Java services? They have pretty minimal requirements (especially compared to External Java Actions) and can be used anywhere an interpreted expression is used.


I mean double click, I can't use the Java Services. Because I have a problem to call my services. I don't know why but I can't access to my service methods from odesign file.
Re: How to call own Java Method in Sirius [message #1847804 is a reply to message #1847609] Mon, 08 November 2021 23:20 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 570
Registered: May 2011
Senior Member
Hello,

Indeed, you should use a double click tool in the end, but before that fix the problem with your java services. You don't have to use java services, but it quickly become an easy solution with more complex tools. When you created your Viewpoint Specification Project (project with the .odesign), it should have created a class with the name of your viewpoint and ending by services (if you called your odesign project "AwesomeProject" the java service class will be named "AwesomeProjectServices"). Each public java method you add to this class is accessible from your odesign, in the "interpreted expression" fields like "semantic candidate expression" (all the text fileds with a yellow background). If you have a java service named "myJavaService", in the odesign you can call it with the expression aql:self.myJavaService. Remember that the class of the first parameter of the java service should match the class of the context where the expression will be executed. For instance, if you make a double click tool for a node mapping with the domain class "MyClass", then the java service should have as first argument a "MyClass" element. You can have your service with a first element as an EObject as a first test, but you will probably want to switch it to a proper type later in order to only have the service for the good context when you are working in your odesign.

Best regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: How to call own Java Method in Sirius [message #1848011 is a reply to message #1847804] Wed, 17 November 2021 12:07 Go to previous message
Hakan  Yüksek is currently offline Hakan YüksekFriend
Messages: 22
Registered: October 2021
Junior Member
Steve Monnier wrote on Mon, 08 November 2021 23:20
Hello,

Indeed, you should use a double click tool in the end, but before that fix the problem with your java services. You don't have to use java services, but it quickly become an easy solution with more complex tools. When you created your Viewpoint Specification Project (project with the .odesign), it should have created a class with the name of your viewpoint and ending by services (if you called your odesign project "AwesomeProject" the java service class will be named "AwesomeProjectServices"). Each public java method you add to this class is accessible from your odesign, in the "interpreted expression" fields like "semantic candidate expression" (all the text fileds with a yellow background). If you have a java service named "myJavaService", in the odesign you can call it with the expression aql:self.myJavaService. Remember that the class of the first parameter of the java service should match the class of the context where the expression will be executed. For instance, if you make a double click tool for a node mapping with the domain class "MyClass", then the java service should have as first argument a "MyClass" element. You can have your service with a first element as an EObject as a first test, but you will probably want to switch it to a proper type later in order to only have the service for the good context when you are working in your odesign.

Best regards,
Steve



Thank you
Previous Topic:Model changed during edition warning for numeric attributes
Next Topic:Format exception handling in property views
Goto Forum:
  


Current Time: Sat Dec 03 00:34:10 GMT 2022

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

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

Back to the top