Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Border items and layout manager
Border items and layout manager [message #636129] Fri, 29 October 2010 12:34 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello,

I am trying to design an editor that will let users create blocks on the diagram. These blocks have input ports (on the WEST border) and output ports (on the EAST border).

I am struggling with a problem for days and days and can't find a solution for it. I would like the ports to be positioned properly on the borders (and the user won't be able to move the ports). The ports should be equaly spaced and take up the full height of the border. So, when the figure is resized, the ports are moved accordingly.

I tried with several different approaches without success.
With a LayoutManager is would be fairly easy to do but unfortunately it is not that easy Sad . I tried to add my custom layout manager in the constructor of my edit part:
		getBorderedFigure().getBorderItemContainer().setLayoutManager(new BorderItemLayoutManager());


but the hierarchy of border items and children is so complex that it is impossible to solve this way.

I also tried to create my own custom border item locator but apparently those are used as a hint only (so, when the figure is resized, they are not used anymore). Furthermore, it is more complex wihtout having a layout manager that knows about the container and the ports which are already present on the border.

So, I am completely stuck with this problem which is kind of basic.
I would really appreciate any pointers or help to get me started in the good direction.
Thanks.
Re: Border items and layout manager [message #636595 is a reply to message #636129] Tue, 02 November 2010 07:02 Go to previous message
Asiri Rathnayake is currently offline Asiri RathnayakeFriend
Messages: 80
Registered: September 2010
Location: Colombo, Sri Lanka.
Member
Hi Cedric,

I solved a kind of similar problem on my editor using an approach like below:

- Have a node defined to represent the block element.

- The figure of this block element is a composite with a rectangular container pane (no fill or outline) with a grid layout. This composite shape contains other rectangular panes which are meant to hold port figures when they are added dynamically. I have defined child access methods that allows me to retrieve these container panes as needed. Here you need to compose this block figure corresponding to your layout requirements (with GridLayout you can easily achieve this).

- Have nodes defined for each port.

- When mapping the block element, add child references which refer to node mappings of ports.

- Above setting will give rise to BlockEditPart and PortEditPart(s).

- On the BlockEditPart class, override the addChildVisual(EditPart childEditPart, int index) method and depending on the type of the childEditPart, add the child edit part figure to corresponding container pane of the BlockEditPart figure.

This approach worked out for me so far really well but I'm not sure if there is a better way...

- Asiri
Previous Topic:Forbid anchor being reused
Next Topic:Change the appearance of outgoing connections when clicking on a specific node
Goto Forum:
  


Current Time: Fri Apr 19 16:45:20 GMT 2024

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

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

Back to the top