Node replace tool [message #1808677] |
Fri, 28 June 2019 09:19  |
Eclipse User |
|
|
|
Hi everyone,
I'm looking for a way to create a tool in the diagram to replace one node with another node. I already tried with the default tools in the design of the project, but nothing is useful in this case.
I also tried the Java service, but I can not find a good model. If someone can help me, I really appreciate it :)
P.d: The goal is to create a tool for the end user to replace an Or-Node with an And-Node. You can see the diagram in the attached image.
Regards, Fede
|
|
|
|
|
|
|
Re: Node replace tool [message #1809462 is a reply to message #1809214] |
Tue, 16 July 2019 09:37  |
Eclipse User |
|
|
|
Hi,
You have to understand EMF concepts. Either you buy EMF books or read online doc or tutorials : https://www.eclipse.org/modeling/emf/docs/#overviews
In fact you have to pass another parameter to the service to know if what kind of tool is used like an int or a string : aql:container.doTheChange("andTool")
Lets say And and Or tool inherit the same class that is Tool. And containers like AO1 are called Action and contains the tool by a reference called tool.
public void doTheChange(EObject target, String toolType){
//target is the clicked object that will be replaced
Tool tool=(Tool)target;
if("andTool".equals(toolType){
//we create new instance
AndTool andTool=MyMetamodelFactory.createAndTool();
//we retrieve the parent Action
Action action=(Action)target.eContainer();
//we replace the tool
action.setTool(andTool)
}else{
... do the same for or tool
}
Then Set the coordinate
}
Regards,
[Updated on: Tue, 16 July 2019 10:02] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03778 seconds