Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsAuto Resizing Containers
https://www.eclipse.org/forums/index.php/mv/msg/1086159/1761693/#msg_1761693
I am currently using Sirius to create my own editor.
I need a node to display two labels, and I found out the only way is to create Containers instead of Nodes.
So I created Containers, and created two sub-nodes inside the container to display the contents that I want.
I have two questions if you could please answer:
1. How to automatically position the nodes (one at the top left corner, one at the centre of the container) and resize the nodes based on the content they displays
2. How to resize the container based on the size of the sub-nodes
The style of the Container uses an image that I provided.
Thank you very much
William ]]>Ran Wei2017-05-11T14:21:24-00:00Re: Auto Resizing Containers
https://www.eclipse.org/forums/index.php/mv/msg/1086159/1761908/#msg_1761908
To answer:
1- You should define your own GMF layout. It's really difficult and contribute this layout in Sirius.
2- The "Auto Size" function do that automatically. The Auto Size is available in the tabbar on the right when your container is selected.
Regards,]]>Julien Dupont2017-05-11T16:10:16-00:00Re: Auto Resizing Containers
https://www.eclipse.org/forums/index.php/mv/msg/1086159/1769998/#msg_1769998
Regarding your answer on the second question: The auto-resizing functionality actually resizes the width of the container to fit the contained element without wrapping the content (see 1st screenshot). Is it possible to wrap the contents (like in 2nd screenshot)?
Thanks,
Thanos
Screenshot 1:
Screenshot 2:
]]>Athanasios Zolotas2017-08-07T12:14:57-00:00Re: Auto Resizing Containers
https://www.eclipse.org/forums/index.php/mv/msg/1086159/1770636/#msg_1770636
In the localChangesAboutToCommit(Collection<Notification>), I collect all the container nodes (those that are instances of Bounds) and then in the doExecute method I call the setWidth() and setHeight() methods to set the specific dimensions I need (I also tried to create a new setCommand like this: Command setCommand = new SetCommand(domain, myBound, NotationPackage.eINSTANCE.getSize_Width(), 200);).
When I create a new container node, it is created with the custom dimensions I set, the contained subnodes' labels are wrapped as they should be however, after a second or so the dimensions are reset to fit the subnodes' labels in one line. I guess that another command is called after mine in the doExecute method that resets the dimensions.
I tried to debug this, it must be something happening inside the someAreVisible(List<MWindow> windows) method of the PartRendering class however, there is no chance to identify what is that, as the loop in there is executed hundereds of times. Any idea?]]>Athanasios Zolotas2017-08-15T12:12:56-00:00Re: Auto Resizing Containers
https://www.eclipse.org/forums/index.php/mv/msg/1086159/1770683/#msg_1770683
It seems you might put some breakpoints in:
- org.eclipse.gmf.runtime.notation.impl.NodeImpl.setLayoutConstraint(LayoutConstraint)
- org.eclipse.gmf.runtime.notation.impl.BoundsImpl.setWidth(int)
- org.eclipse.gmf.runtime.notation.impl.BoundsImpl.setHeight(int)
If you enable them just after your SetCommand creation from localChangesAboutToCommit, you should be able to see you bounds update and then who cancels your changes.