Bug 213696

Summary: ToolbarLayout and hidden figures
Product: [Tools] GEF Reporter: Alexey Markevich <a_markevich>
Component: GEF-Legacy GEF (MVC)Assignee: gef-inbox <gef-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: 3.3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Alexey Markevich CLA 2007-12-21 09:29:08 EST
I implement collapsible composite control and found problems with hidden figures:

class MyEditPart extends AbstractGraphicalEditPart {

boolean isExpanded = true;

protected IFigure createFigure() {
	Figure figure = new Figure();
	ToolbarLayout toolbarLayout = new ToolbarLayout(false);   
	figure.setLayoutManager(toolbarLayout);
	
	Figure contentPane = new Figure();
	figure.add(contentPane);
	...
	return figure;
}
...
public void performRequest(Request request) {  
	if (request.getType() == equestConstants.REQ_OPEN) {
		isExpanded = !isExpanded;
		contentPane.setVisible(isExpanded);
		refresh();
	}
}
};	

If figure is collapsed it still have space as if its visible.
I found 2 solutions:

1) Override getMinimumSize and getPreferredSize in contentPane figure:
contentPane = new Figure() {
public Dimension getMinimumSize(int hint, int hint2) {
	Dimension d = new Dimension(super.getMinimumSize(hint, hint2));
	if(!isVisible()) {
		d.height = 0;
	}
	return d;
}
public Dimension getPreferredSize(int hint, int hint2) {
	Dimension d = new Dimension(super.getPreferredSize(hint, hint2));
	if(!isVisible()) {
		d.height = 0;
	}
	return d;
}
};

2) Override ToolbarLayout methods layout and calculateChildrenSize - check children visibility before calculation.

Is this a bug or 'by design'?