Initail position of a node & palette changed at runtime [message #697040] |
Fri, 15 July 2011 07:33  |
Eclipse User |
|
|
|
Hi all.
I've got 2 problem with my editor.
First i would like to set initial position of a node in the diagram when the diagram is created and when the diagram is refreshed.
User must still be abele to move and resize nodes
I'v tryed diffrent solution like:
h**p://wiki.eclipse.org/Graphical_Modeling_Framework/Tips#Setting_Initial_Position_of_a_Node
and other post on the eclipse forum, but always without achive my goal.
When i try to set the node constraint, i still get the "cannot write in Read Only Transaction" also using editingDomain and command.
I need a hint on how solve this.
My second question ia about plaette. Is possible to change it at runtime? i need to hide/unide tool at runtime.
Tanks in advance.
Mauro P.
|
|
|
|
Re: Initail position of a node & palette changed at runtime [message #700167 is a reply to message #697043] |
Fri, 22 July 2011 19:25  |
Eclipse User |
|
|
|
For who will have the same problem and he/she will still need an easy solution, i've found it.
The big mistake is trying to set the LayoutConstraint on the node...
you should set the constraint on the parent of the node like this(I will post my few and easy line of code):
//here we are in the EditPart of the node we want set the initial position
@Override
public void activate() {
super.activate();
//The new rectangle rapresenting the new position and size of the node
//size to -1 means "use preferredSize"
Rectangle r = new Rectangle(0, 0, -1, -1);
((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), r);
}
That is my code. has you can see no need to use command to do that, like suggest in other posts or tutorial.
You need to set the object constraint only on the parent (the diagram EditPart)
Hope this could help someone.
|
|
|
Powered by
FUDForum. Page generated in 0.05061 seconds