Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Set Coordinates/Position from Node Creation Tool ?
Set Coordinates/Position from Node Creation Tool ? [message #1726538] Mon, 14 March 2016 14:07 Go to next message
Nikolay Manolov is currently offline Nikolay ManolovFriend
Messages: 24
Registered: June 2012
Junior Member
Hi,

Is it possible to set the position of a new element from a Node Creation or a generic tool?
I have a Node Creation Tool that creates a new element instance inside a container and the new element is placed where I clicked. I have defined additional behavior to that tool so that if you click on an existing node in that container the clicked node is replicated. In that case, however, the new node is placed "randomly" somewhere on the diagram. I would like, if possible, in addition to creating an instance to also create the graphical representation and set the position to be where I clicked (on another node inside a container) + some offset.

Looked in the Sirius code for anything about setting the position but It seems this may be delegated to gmf along with the click event.

So, the question is if it is possible to set/affect the position of a graphical representation directly from a Node Creation Tool/Diagram Specification. If not, would it be possible from an external JavaAction or any other way?

Regards,
Nik

Re: Set Coordinates/Position from Node Creation Tool ? [message #1726632 is a reply to message #1726538] Tue, 15 March 2016 09:40 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi Nikolay,

You can define the location and size of additional created nodes/edges
by using the "CreateView/CreateEdgeView" operation in your creation tool
and calling a java service to use
org.eclipse.sirius.diagram.ui.business.api.view.SiriusLayoutDataManager
API. Sirius will use this singleton to know with which location and size
create the nodes/edges.
After having called CreateView operation to get the DDiagramElement
created, you can call a java service as sub operation (a ChangeContext
for example). And in this java service call :

LayoutData layoutData =
SiriusLayoutDataManager.INSTANCE.getData(createdView, true);
layoutData = new RootLayoutData(layoutData.getTarget(), newLocation,
newSize);
SiriusLayoutDataManager.INSTANCE.addData(layoutData);

Best Regards.

Le 14/03/2016 15:07, Nikolay Manolov a écrit :
> Hi,
>
> Is it possible to set the position of a new element from a Node Creation
> or a generic tool? I have a Node Creation Tool that creates a new
> element instance inside a container and the new element is placed where
> I clicked. I have defined additional behavior to that tool so that if
> you click on an existing node in that container the clicked node is
> replicated. In that case, however, the new node is placed "randomly"
> somewhere on the diagram. I would like, if possible, in addition to
> creating an instance to also create the graphical representation and set
> the position to be where I clicked (on another node inside a container)
> + some offset.
>
> Looked in the Sirius code for anything about setting the position but It
> seems this may be delegated to gmf along with the click event.
>
> So, the question is if it is possible to set/affect the position of a
> graphical representation directly from a Node Creation Tool/Diagram
> Specification. If not, would it be possible from an external JavaAction
> or any other way?
>
> Regards,
> Nik
>
>



--
Esteban Dugueperoux - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Set Coordinates/Position from Node Creation Tool ? [message #1727591 is a reply to message #1726632] Thu, 24 March 2016 09:12 Go to previous messageGo to next message
Alx Hvx is currently offline Alx HvxFriend
Messages: 40
Registered: March 2016
Member
Hi,
I have the a problem with the command : SiriusLayoutDataManager.INSTANCE.getData(createdView, true);
I use it with a DDiagramElement that I retrieve programatically

The problem is that It always return null.

Thanks.
Re: Set Coordinates/Position from Node Creation Tool ? [message #1727693 is a reply to message #1727591] Fri, 25 March 2016 11:35 Go to previous messageGo to next message
Bailey Trenton is currently offline Bailey TrentonFriend
Messages: 31
Registered: May 2015
Member
Hello,
I had a similar use case in my project. We have border nodes with a double click action on them that creates a new node floating right off the border node when double clicked. I solved the location issue by creating and registering a ModelChangeTrigger that listens for the creation of the new node in the model and then sets its location. It seems works for us. You have to be careful about matching the notification because you can get some unintended side effects if your filter matches notifications caused by other changes.

Hope this helps

Bailey
Re: Set Coordinates/Position from Node Creation Tool ? [message #1760185 is a reply to message #1727693] Mon, 24 April 2017 12:32 Go to previous message
Jens Lidestrom is currently offline Jens LidestromFriend
Messages: 11
Registered: April 2017
Location: Göteborg, Sweden
Junior Member
@Bailey Trenton

Quote:

listens for the creation of the new node in the model and then sets its location.


How do you set the location of an object that are newly created in the model?

Previous Topic:Use External EMF Resource
Next Topic:expression
Goto Forum:
  


Current Time: Thu May 09 18:58:53 GMT 2024

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

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

Back to the top