Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 127205

Summary: BorderLayout doesn't position child figure in the center
Product: [Tools] GEF Reporter: Svetoslav Rusev <sv_rusev>
Component: GEF-Legacy Draw2dAssignee: gef-inbox <gef-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: ppshah
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Svetoslav Rusev CLA 2006-02-09 20:14:40 EST
Hello,
I had a problem which I think is a bug in the implementation of the BorderLayout.The problem is the positioning of a child figure in the Center of  the parent figure with org.eclipse.draw2d.BorderLayout. Here is the exampe code: 

		BorderLayout layout = new BorderLayout();
		parent.setLayoutManager(layout );
		IFigure child = new Label("Test");
		parent.add(child , BorderLayout.CENTER);

The child figure is positioned in the horizontal Center but not in the Vertical one. The child figure stays in the Top of the parent as the same as I have been given BorderLayout.TOP. If I give a constraint BorderLayout.BOTTOM it goes to the Bottom of the parent figure and all other constraints work only the Center constraint doesnot work. I'm using GEF 3.2.0 with GMF 1.0.0. My parent figure is: org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure, but I tried with also with org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure and couple of others extending from NodeFigure.


Thank you!
Comment 1 Randy Hudson CLA 2006-02-09 22:52:18 EST
Pratik, is this the behavior before or after your recent change?
Comment 2 Pratik Shah CLA 2006-02-10 11:05:04 EST
Before.  That was fixed a while back though.  Svetoslav, what GEF build are you using?  See bug 113008.
Comment 3 Svetoslav Rusev CLA 2006-02-10 12:16:08 EST
(In reply to comment #2)
> Before.  That was fixed a while back though.  Svetoslav, what GEF build are you
> using?  See bug 113008.
> 

Hello,

I'm using GEF 3.2 M4.

Svet Rusev
Comment 4 Pratik Shah CLA 2006-02-10 13:26:13 EST
I think you might be confusing the border layout's positioning with the positioning of the text in the label.  Add a border to the label to see what its exact size is.  Label has its own methods to align the text.  If you still think this is a bug, provide a complete snippet showing the problem.
Comment 5 Randy Hudson CLA 2006-02-10 13:41:09 EST
So, this is actually the behavior after the change. We are now stretching the center figure to fill the available space.

Were you relying on the old behavior? We could support the old behavior by default and make 3.2 clients request the 3.2 behavior.

As Pratik said, you can call setLabelAlignment() to get the text in the middle.
Comment 6 Svetoslav Rusev CLA 2006-02-17 12:43:41 EST
Sorry - my mistake, I'm using GMF Framework and it generates a org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure with 3 containers inside one another the top 2 containers are with org.eclipse.draw2d.BorderLayout but the last one (the inner one) is with org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout and the Label which I wanted to be in the Center is added to this container. I needed to rewrite the layout(IFigure) method so that the Label goes in the Center. Do you know any other Layout that can be used instead of ConstrainedToolbarLayout in GMF? Because if I change it with BorderLayout the Label doesn't appear probably it needs to be another Constraint Layout.
Sorry for the mistake!

Svet
Comment 7 Svetoslav Rusev CLA 2006-04-26 17:20:57 EDT
The submitted bug report is not a bug but complex implmentation see Comment  #6.
I'm Sorry for your time!

Svetoslav Rusev