/*
 * 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;

	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);
		
		Label nameLabel = new Label();
		nameLabel.setText(name);
		headerLayer.add(nameLabel);
		
	}

	public Figure getHeaderLayer() {
		return headerLayer;
	}

	public Figure getContentLayer() {
		return contentLayer;
	}
}

@@ -942,16 +942,44 @@
 ntLayer;
+%0A%09private Label headerLabel;
 %0A%0A%09publi
@@ -1954,18 +1954,14 @@
 %09%0A%09%09
-Label name
+header
 Labe
@@ -1979,20 +1979,22 @@
 el();%0A%09%09
-name
+header
 Label.se
@@ -2024,20 +2024,22 @@
 yer.add(
-name
+header
 Label);%0A
@@ -2132,32 +2132,32 @@
 ontentLayer() %7B%0A
-
 %09%09return content
@@ -2166,10 +2166,164 @@
 yer;%0A%09%7D%0A
+%09%0A%09public String getHeaderLabelText()%7B%0A%09%09return headerLabel.getText();%0A%09%7D%0A%09%0A%09public void setHeaderLabelText(String text)%7B%0A%09%09headerLabel.setText(text);%0A%09%7D%0A
 %7D%0A

Add set and get methods to set header in TwoPartFigure