Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Node replace tool(Creation of a tool in the diagram to replace a node for another)
Node replace tool [message #1808677] Fri, 28 June 2019 13:19 Go to next message
Federico Ranzato is currently offline Federico RanzatoFriend
Messages: 6
Registered: February 2019
Junior Member
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 #1808748 is a reply to message #1808677] Mon, 01 July 2019 08:36 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
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 #1808995 is a reply to message #1808748] Fri, 05 July 2019 14:33 Go to previous messageGo to next message
Federico Ranzato is currently offline Federico RanzatoFriend
Messages: 6
Registered: February 2019
Junior Member
Hi Pier,

thanks for your answer. Can you be more specific with this steps?
I mean, I am not very expert with Sirius and I need more information about what tool should I use and how...

Regards, Fede
Re: Node replace tool [message #1809124 is a reply to message #1808995] Tue, 09 July 2019 14:40 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hi,

I answered too quickly.
1-Use a creation tool
2-under begin use a change context operation
3- in this change context operation make a call to a java service like aql:container.doTheChange()
4- in your java service create the new instance and replace the old one represented by the container variable by the new one.
5-Set the coordinates with the method from the cookbook.
Then you should be good.

Regards,



Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Node replace tool [message #1809214 is a reply to message #1809124] Thu, 11 July 2019 17:06 Go to previous messageGo to next message
Federico Ranzato is currently offline Federico RanzatoFriend
Messages: 6
Registered: February 2019
Junior Member
Hi Pierre,

I did understend good until the point 3 but then on point 4 I don´t know how write the metod of java service. Can you tell me more about that point or give me a link with an example please?

Regards, Fede
Re: Node replace tool [message #1809462 is a reply to message #1809214] Tue, 16 July 2019 13:37 Go to previous message
Pierre Guilet is currently offline Pierre GuiletFriend
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

Previous Topic:Double-edged nodes/links
Next Topic:Question about edges
Goto Forum:
  


Current Time: Fri Apr 26 19:11:53 GMT 2024

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

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

Back to the top