|
|
|
solution found [message #540307 is a reply to message #539966] |
Tue, 15 June 2010 15:13 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
emil salageanu![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=salageanuemil%40yahoo.fr) Messages: 94 Registered: June 2010 Location: Nice, France |
Member |
|
|
I found a solution for the issue described above.
I'll write it here hoping that someone will take advantage of my several hours of searching the solution.
Id did it in java altough it is possible to do it in OCL.
I think the problem is rather important so, if someone could add the OCL solution to this topic it might be good for the GMF comunity. I'll stick to java ![Smile](images/smiley_icons/icon_smile.gif)
So, let me rephrase the problem :
We need to use the same ECORE class with different creation tools.
We have an Ecore class Task, referencing class Script twice: via EReference "pre" and "post".
We have one graphical node and two creation tools (PRE and POST) in tooling model.
Solution:
We create, in the *.gmfmap file, 2 mappings:
one mapping for task.pre:Script
one mapping for task.post:Script
For each NodeMapping (script/pre and script/post), we add a java constraint. No need to fill-in the body.
When we generate the code, in the diagram.part.XXXVisualIDRegistry.java file we have 2 methods looking like this:
private static boolean isModelElement_XXXX(ModelElement domainElement)
We need to add a condition on the containment feature:
private static boolean isScript_3009(Script domainElement) {
EReference ref = domainElement.eContainmentFeature();
if (ref.getName()=="post")
{
return true;
}
else
return false;
}
You can also take a look at
http://wiki.eclipse.org/GMF_Constraints
This is it. Now it works.
Although I'll stick to the java solution anywats (i'm more confident) I'm curios to see the OCL solution.
[Updated on: Tue, 15 June 2010 15:14] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03342 seconds