|
Re: Node replace tool [message #1808748 is a reply to message #1808677] |
Mon, 01 July 2019 08:36 |
Pierre Guilet Messages: 250 Registered: June 2017 |
Senior Member |
|
|
Hi,
You have the methods to do that described in https://wiki.eclipse.org/Sirius/Cookbook.
So in your tool:
1 - Use a delete operation calling a services with the node to remove.
Then in this service:
2 - Create the new node and replace the older one by it by updating its model relations(edges).
3 - Remove the older one.
4- Set the coordinates of the removed element to the new one by calling the method setGraphicalHintsFromExistingNode described in the cookbook and its related method getEditPart also described in it.
Then you should be good.
Regards,
Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
[Updated on: Mon, 01 July 2019 08:41] Report message to a moderator
|
|
|
|
|
|
Re: Node replace tool [message #1809462 is a reply to message #1809214] |
Tue, 16 July 2019 13:37 |
Pierre Guilet Messages: 250 Registered: June 2017 |
Senior Member |
|
|
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,
Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
[Updated on: Tue, 16 July 2019 14:02] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03526 seconds