/*
 * Perfclispe
 * 
 * 
 * Copyright (c) 2013 Jakub Knetl
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.perfclipse.ui.gef.figures;


import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FlowLayout;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Dimension;


public class PerfCakeTwoPartRectangle extends PerfCakeRoundedRectangle {
	
	private Figure headerLayer;
	private Figure contentLayer;
	private Label headerLabel;

	public PerfCakeTwoPartRectangle(String name, Dimension defaultSize) {
		super(name);
		FlowLayout layout = new FlowLayout();
		layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
		setLayoutManager(layout);
		
		headerLayer = new Figure();
		contentLayer = new Figure();
		
		/* This code was used to set maximum width of content layer, but this
		 * intervention to layout manager caused that layout manager stopped
		 * resizing component automatically. So manual resizing for content 
		 * layer needs to be implemented when the setPreferredSize is used.
		contentLayer.setPreferredSize(defaultSize.width - PerfCakeRoundedRectangle.getClientAreaInsets().getWidth(), 0);
		 */

		FlowLayout headerLayout = new FlowLayout();
		headerLayout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
		FlowLayout contentLayout = new FlowLayout();
		
		headerLayer.setLayoutManager(headerLayout);
		contentLayer.setLayoutManager(contentLayout);
		
		add(headerLayer);
		add(contentLayer);
		
		headerLabel = new Label();
		headerLabel.setText(name);
		headerLayer.add(headerLabel);
		
	}

	public Figure getHeaderLayer() {
		return headerLayer;
	}

	public Figure getContentLayer() {
		return contentLayer;
	}
	
	public String getHeaderLabelText(){
		return headerLabel.getText();
	}
	
	public void setHeaderLabelText(String text){
		headerLabel.setText(text);
	}
}

@@ -761,16 +761,57 @@
 .Label;%0A
+import org.eclipse.draw2d.ToolbarLayout;%0A
 import o
@@ -848,16 +848,16 @@
 ension;%0A
-
 %0A%0Apublic
@@ -925,16 +925,64 @@
 gle %7B%0A%09%0A
+%09private static final int SECTION_SPACING = 8;%0A%0A
 %09private
@@ -1145,28 +1145,31 @@
 er(name);%0A%09%09
-Flow
+Toolbar
 Layout layou
@@ -1168,36 +1168,39 @@
 ut layout = new 
-Flow
+Toolbar
 Layout();%0A%09%09layo
@@ -1198,34 +1198,34 @@
 );%0A%09%09layout.setM
-aj
+in
 orAlignment(Flow
@@ -1212,36 +1212,39 @@
 tMinorAlignment(
-Flow
+Toolbar
 Layout.ALIGN_CEN
@@ -1249,16 +1249,54 @@
 ENTER);%0A
+%09%09layout.setSpacing(SECTION_SPACING);%0A
 %09%09setLay
@@ -1936,24 +1936,67 @@
 owLayout();%0A
+%09%09contentLayout.setStretchMinorAxis(true);%0A
 %09%09%0A%09%09headerL

Change layout manager