|
Re: Change colour of specific node from code [message #1798908 is a reply to message #1798850] |
Tue, 27 November 2018 10:38 |
Pierre Guilet Messages: 250 Registered: June 2017 |
Senior Member |
|
|
Hi Florian,
Regarding your context I suggest the following:
- You create a Style customization https://www.eclipse.org/sirius/doc/specifier/diagrams/Diagrams.html#customization with a selection property customization on color property that will apply to all mappings that can have their color changed.
- In the predicate expression you call a service with aql:self.doChangeColor('red'). In the service doChangeColor you test that you have a graph pattern matching result somewhere in a singleton for example. If so you check if the color provided as parameter must be applied and return true if so. False otherwise
- You do a custom style for each color that can be used and call the service with the right color.
- Then either you do a tool that will call the pattern matching from a service. In this case the color refresh will be done automatically. Or if your pattern matching algorithm is triggered outside of Sirius, either you do manual refresh of the diagram or you call a refresh from Sirius API directly at the end of the algorithm execution.
Is this solution ok for you?
Regards,
Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
[Updated on: Tue, 27 November 2018 10:41] Report message to a moderator
|
|
|
|
Re: Change colour of specific node from code [message #1799040 is a reply to message #1798998] |
Thu, 29 November 2018 09:33 |
Pierre Guilet Messages: 250 Registered: June 2017 |
Senior Member |
|
|
Hi,
I don't understand why you want to use a service from outside the Sirius Editor. You don't need to with the solution I propose.
What service do you want to call outside of Sirius editor?
Service is a concept specific to odesign that call be called in mappings and tools defined. If you are outside you just have to use java code and do what you want.
Do you mean you don't know how to set a java class containing services in the odesign? In this case you have to add a new java extension under your viewpoint item in the odesign with the qualified name of your class containing the service. Then you will have access to its services in interpreted expressions of your VSM
Regards,
Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
[Updated on: Thu, 29 November 2018 09:34] Report message to a moderator
|
|
|
|
Re: Change colour of specific node from code [message #1799089 is a reply to message #1799047] |
Thu, 29 November 2018 16:20 |
Pierre Guilet Messages: 250 Registered: June 2017 |
Senior Member |
|
|
A question is never stupid ;)
The service changing color to red in the customization must be base on existing graph pattern matching result.
I.e your service mustRedColorBeAppliedToElement(EObject semanticElement) in the color customization expression will look like this:
public boolean mustRedColorBeAppliedToElement(EObject semanticElement){
if(PatternMathingResult.instance.getResults()!=null){
//if semanticElement should be red regarding the results then return true else return false.
}
}
where PatternMathingResult is a singleton java instance where you put the result of your matching algorithm when executed.
If no results are present, then it will return false and the color will not be changed.
At the end of the execution you also must refresh your diagram with Sirius APIorg.eclipse.sirius.ui.business.api.dialect.DialectUIServices.refreshEditor(DialectEditor, IProgressMonitor)
Then your element will turn to red automatically. If you want to remove the red color you just have to clear the results in the singleton.
Regards,
Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
[Updated on: Thu, 29 November 2018 16:21] Report message to a moderator
|
|
|
Re: Change colour of specific node from code [message #1799143 is a reply to message #1799089] |
Fri, 30 November 2018 12:41 |
Florian Kunz Messages: 21 Registered: September 2018 |
Junior Member |
|
|
Hi,
I didn't know about singletons, so I had to read up a little about the concept. It seems quite fitting for my purposes but there is a problem I couldn't solve. How can the editor and the external java class (which is looking for risk patterns) access this singleton class?
Right now I have two runtimes (like in the tutorial). In the first one I created the ecore model. The second one is started through running the .editor project as another eclipse instance. In the second instance is the sirius editor with the .odesign file. The singleton class is supposed to be in the same project as the pattern matching class in the first runtime, right?
For better understanding:
1. Runtime: Ecore model, .edit project, .editor project, pattern matching project
2. Runtime: Sirius editor project (with .odesign file), project with models for testing purposes
The problem is, that I can't place the singleton class in the sirius project nor in the pattern matching project because of the accessibility.
Regards,
Florian
|
|
|
|
Re: Change colour of specific node from code [message #1799246 is a reply to message #1799143] |
Mon, 03 December 2018 13:21 |
Pierre Guilet Messages: 250 Registered: June 2017 |
Senior Member |
|
|
Hi Florian,
I don't understand why the singleton could not be in the pattern matching project?
For me you should have Sirius editor project depending on pattern matching project because you are using its results. Am I right?
If so, then you should put the result in the pattern matching project singleton that should already exists.
This is the plugin activator you can specify in the MANIFEST.MF of the plugin. If it does not exist you can create it. It is a singleton where you can put some information.
It will look like :
public class TestClass implements BundleActivator {
public static TestClass INSTANCE;
@Override
public void start(BundleContext context) throws Exception {
INSTANCE = this;
}
@Override
public void stop(BundleContext context) throws Exception {
}
}
You can put the result here (TestClass.INSTANCE.setResults(...)). This is the easier option. Then it is accessible by using TestClass.INSTANCE.getResults() in odesign project and services.
Regards,
Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
[Updated on: Mon, 03 December 2018 13:22] Report message to a moderator
|
|
|
|
|
|
|
|
Re: Change colour of specific node from code [message #1799263 is a reply to message #1799262] |
Mon, 03 December 2018 16:17 |
Pierre Guilet Messages: 250 Registered: June 2017 |
Senior Member |
|
|
The steps to use a class C from a project A in a class C2 in a project B are the following:
- In A export package containing the class and make it visible to all plugins
- In B add a dependency to A
- Import C in C2
If all previous are done and the class cannot be found it means the plugin containing it is not loaded either because it is not selected in the runtime configuration to be launched. Or because the plugin had an error while loading (you will see this kind of information in the console of your first eclipse that had launched the runtime where sirius project is).
Check the section" plug-ins" of your launched Eclipse application to see if either "all" option is selected or the plugin pattern matching is checked.
Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
[Updated on: Mon, 03 December 2018 16:18] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05353 seconds