Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Custom Layout for Containers
Custom Layout for Containers [message #1403830] Mon, 28 July 2014 08:03 Go to next message
Aleksandar Kanchev is currently offline Aleksandar KanchevFriend
Messages: 4
Registered: July 2014
Junior Member
Hello, I'm new to creating diagram editors using frameworks like GMF and Sirius. However it looks quite easy creating diagram editors with Sirius, so we're giving it a try in our project. Currently we have a problem where we need a container with an advanced layout. Our goal could be achieved by chaining small containers together with the currently available layouts but this will complicate the graphical model and there are concerns about maintainability and performance.

One very nice solution would be if we could define our own layout manager, which would take care of the positions of the contained child nodes. Since we're new to Sirius (and GMF) we couldn't easily find the place where we could just plug our custom layout provider. I was hoping that someone with more experience might point us to the right direction or even better provide us with an example. Thanks!
Re: Custom Layout for Containers [message #1404011 is a reply to message #1403830] Tue, 29 July 2014 07:25 Go to previous messageGo to next message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 270
Registered: August 2010
Senior Member
Hi Aleksandar,

Take a look on this post which is similar to your need:
https://www.eclipse.org/forums/index.php/mv/msg/639946/1234795/#msg_1234795

Regards,

Florian

On 07/28/2014 07:02 PM, Aleksandar Kanchev wrote:
> Hello, I'm new to creating diagram editors using frameworks like GMF and
> Sirius. However it looks quite easy creating diagram editors with
> Sirius, so we're giving it a try in our project. Currently we have a
> problem where we need a container with an advanced layout. Our goal
> could be achieved by chaining small containers together with the
> currently available layouts but this will complicate the graphical model
> and there are concerns about maintainability and performance.
>
> One very nice solution would be if we could define our own layout
> manager, which would take care of the positions of the contained child
> nodes. Since we're new to Sirius (and GMF) we couldn't easily find the
> place where we could just plug our custom layout provider. I was hoping
> that someone with more experience might point us to the right direction
> or even better provide us with an example. Thanks!
Re: Custom Layout for Containers [message #1404376 is a reply to message #1404011] Thu, 31 July 2014 17:01 Go to previous messageGo to next message
Aleksandar Kanchev is currently offline Aleksandar KanchevFriend
Messages: 4
Registered: July 2014
Junior Member
Hi Florian,

thanks a lot for the quick answer. So far I found a nice documentation about layout providers and view ordering:

h_ttp://docs.obeonetwork.com/obeodesigner/6.2/viewpoint/developer/general/extensions-provide_custom_arrange-all.html

The concept seems quite easy to understand but I'm stuck at arranging the child views of a container. I'm trying to use the GridLayoutProvider for my diagram but it seems that it won't go down the hierarchy and order the views of containers.

For example the DefaultLayoutProvider would check if the current action is "Arrange All" i.e. it has the Diagram view itself, then it'll check if there's a custom layout provider registered for that diagram and it'll discover the GridLayoutProvider that I registered. Then it'll always call the GridLayoutProvider with the children of the diagram which would be the single root element of the diagram. The logic at that point is always the same: arrange the current elements as grid (so 1x1 grid in this case) and layout the container of those elements (so the diagram itself). In another words:

DefaultLayoutProvider.layoutEditParts(GraphicalEditPart diagramEditPart, IAdaptable layoutHint):
-> GridLayoutProvider.layoutEditParts(diagramEditPart.getChildren(), layoutHint):
->-> childrenGrid = myViewOrdering.getSortedViewsAsGrid(diagramEditPart.getChildren())
->-> buildGridCommand(childrenGrid)
->-> buildContainerCommand(diagramEditPart)

Am I missing something important here?

Regards,
Aleksandar
Re: Custom Layout for Containers [message #1404458 is a reply to message #1404376] Fri, 01 August 2014 13:50 Go to previous messageGo to next message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 270
Registered: August 2010
Senior Member
Hi Aleksandar,

The GridLayoutProvider doesn't handle the container hierarchy. The
GridLayoutProvider is actually used as part of the
OrderedTreeLayoutProvider but not as a "ready to use" layout provider.
You could use it as your main structural layout in the case of your own
layout provider that will deal with the hierarchy.

Regards,

Florian



On 07/31/2014 07:01 PM, Aleksandar Kanchev wrote:
> Hi Florian,
>
> thanks a lot for the quick answer. So far I found a nice documentation
> about layout providers and view ordering:
>
> h_ttp://docs.obeonetwork.com/obeodesigner/6.2/viewpoint/developer/general/extensions-provide_custom_arrange-all.html
>
>
> The concept seems quite easy to understand but I'm stuck at arranging
> the child views of a container. I'm trying to use the GridLayoutProvider
> for my diagram but it seems that it won't go down the hierarchy and
> order the views of containers.
>
> For example the DefaultLayoutProvider would check if the current action
> is "Arrange All" i.e. it has the Diagram view itself, then it'll check
> if there's a custom layout provider registered for that diagram and
> it'll discover the GridLayoutProvider that I registered. Then it'll
> always call the GridLayoutProvider with the children of the diagram
> which would be the single root element of the diagram. The logic at that
> point is always the same: arrange the current elements as grid (so 1x1
> grid in this case) and layout the container of those elements (so the
> diagram itself). In another words:
>
> DefaultLayoutProvider.layoutEditParts(GraphicalEditPart diagramEditPart,
> IAdaptable layoutHint):
> -> GridLayoutProvider.layoutEditParts(diagramEditPart.getChildren(),
> layoutHint):
> ->-> childrenGrid =
> myViewOrdering.getSortedViewsAsGrid(diagramEditPart.getChildren())
> ->-> buildGridCommand(childrenGrid)
> ->-> buildContainerCommand(diagramEditPart)
>
> Am I missing something important here?
>
> Regards,
> Aleksandar
Re: Custom Layout for Containers [message #1404688 is a reply to message #1404458] Tue, 05 August 2014 06:08 Go to previous message
Aleksandar Kanchev is currently offline Aleksandar KanchevFriend
Messages: 4
Registered: July 2014
Junior Member
Hi Florian,

thanks again for your prompt reply! I kind of figured that out after digging through the code and trying to make sense out of it. For someone who's new to GEF, GMF and Sirius this wasn't quite an easy task. I have to say that looking through the implementation of ecoretools 2.0 provided me some clarity about alternative solution.

In our case we must support a diagram with up to 3000 container nodes directly attached to the root diagram node. Within each of them 6 small lists and around 20 editable labels have to be displayed. At first I was thinking about providing inline editing but for this the VSM (.odesign) is getting quite complicated and hence my concern about performance. While looking at ecoretools 2.0 I saw that it's possible to render the string representation of EMF feature via custom service. Editing isn't inline but with the help of wizards which support validation. Such implementation is very lightweight and easy for me to understand. I think I'll go for it. Smile

Nevertheless we'll need to use different layout manager for some Containers/Compartments than the default RegionContainerLayoutManager. I saw that it's possible to provide a different EditPart instance based on a VISUAL_ID. That's how nodes with transparency are implemented within ecoretools 2.0. I tried that approach and provided my own version of DNodeContainerViewNodeContainerCompartment2EditPart to sirius. I tried overriding the getLayoutManager() method and providing GridLayout for the figure but it didn't work. The diagram won't open at all and I'll get a very long stack trace which get's stuck at validation() and isMirrored() methods. Google gave me a hint that it might be something with a XYLayout but it makes no sense to me. Do you know what might be the cause or can you give me a reference to some documentation or examples about using different layouts within containers/compartments?

Cheers
Aleksandar

Previous Topic:Dynamic editor palette customization?
Next Topic:4 minute tutorial - empty diagram?
Goto Forum:
  


Current Time: Thu Apr 25 11:40:18 GMT 2024

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

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

Back to the top