53 lines
2.5 KiB
Java
53 lines
2.5 KiB
Java
/*
|
|
* Copyright (c) 2004,2007 Declarative Engineering LLC.
|
|
* All rights reserved. This program and the accompanying materials
|
|
* are made available under the terms of the Declarative Engineering LLC
|
|
* verson 1 which accompanies this distribution, and is available at
|
|
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
|
*/
|
|
package com.foundation.view.swt.builder;
|
|
|
|
import com.foundation.view.builder.*;
|
|
import com.foundation.view.definition.*;
|
|
|
|
public class CardLayoutBuilder extends AbstractLayoutBuilder {
|
|
protected static final String PROPERTY_MARGIN_WIDTH = "margin-width";
|
|
protected static final String PROPERTY_MARGIN_HEIGHT = "margin-height";
|
|
protected static final String ASSOCIATION_TOP_INDEX = "top-index";
|
|
/**
|
|
* CardLayoutBuilder constructor.
|
|
*/
|
|
public CardLayoutBuilder() {
|
|
super();
|
|
}//CardLayoutBuilder()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData)
|
|
*/
|
|
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
|
|
Integer marginWidth = (Integer) data.getPropertyValue(PROPERTY_MARGIN_WIDTH);
|
|
Integer marginHeight = (Integer) data.getPropertyValue(PROPERTY_MARGIN_HEIGHT);
|
|
String parentName = viewBuilder.formatIdentifier(viewBuilder.getComponentAttributeName(data.getParent()));
|
|
|
|
buffer.append("\t" + getComponentClassName() + " layout = new " + getComponentClassName() + "(" + viewBuilder.getComponentAttributeName(data.getParent()) + ");\r\n");
|
|
buffer.append("\t\r\n");
|
|
|
|
if(marginHeight != null) {
|
|
buffer.append("\tlayout.setMarginHeight(" + marginHeight + ");\r\n");
|
|
}//if//
|
|
|
|
if(marginWidth != null) {
|
|
buffer.append("\tlayout.setMarginWidth(" + marginWidth + ");\r\n");
|
|
}//if//
|
|
|
|
//Note: We are using the parent's name as a way of making the association identifier unique - since the parent cannot have more than one card layout.//
|
|
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_TOP_INDEX, "layout", "setTopIndexAssociation", parentName + "_ASSOC_TOP_INDEX", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
|
|
buffer.append("\t" + viewBuilder.getComponentAttributeName(data.getParent()) + ".setLayout(layout);\r\n");
|
|
}//appendInitializationHead()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
|
|
*/
|
|
public String getComponentClassName() {
|
|
return "com.foundation.view.swt.CardLayout";
|
|
}//getComponentClassName()//
|
|
}//CardLayoutBuilder// |