Skip to main content



      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 09:19 Go to next message
Eclipse UserFriend
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 04:36 Go to previous messageGo to next message
Eclipse UserFriend
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,

[Updated on: Mon, 01 July 2019 04:41] by Moderator

Re: Node replace tool [message #1808995 is a reply to message #1808748] Fri, 05 July 2019 10:33 Go to previous messageGo to next message
Eclipse UserFriend
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 10:40 Go to previous messageGo to next message
Eclipse UserFriend
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,

Re: Node replace tool [message #1809214 is a reply to message #1809124] Thu, 11 July 2019 13:06 Go to previous messageGo to next message
Eclipse UserFriend
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 09:37 Go to previous message
Eclipse UserFriend
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

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


Current Time: Sun Jul 06 05:28:46 EDT 2025

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

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

Back to the top