Files
Brainstorm/Foundation SWT View Builder/src/com/foundation/view/swt/builder/FillLayoutDataBuilder.java
2014-05-30 10:31:51 -07:00

48 lines
2.1 KiB
Java

/*
* Copyright (c) 2009 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 FillLayoutDataBuilder extends AbstractLayoutBuilder {
protected static final String PROPERTY_DEFAULT_WIDTH = "default-width";
protected static final String PROPERTY_DEFAULT_HEIGHT = "default-height";
/**
* FillLayoutDataBuilder constructor.
*/
public FillLayoutDataBuilder() {
super();
}//FillLayoutDataBuilder()//
/* (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 defaultWidth = (Integer) data.getPropertyValue(PROPERTY_DEFAULT_WIDTH);
Integer defaultHeight = (Integer) data.getPropertyValue(PROPERTY_DEFAULT_HEIGHT);
buffer.append("\t\t" + getComponentClassName() + " layoutData = new " + getComponentClassName() + "();\r\n");
buffer.append("\t\t\r\n");
if(defaultWidth != null) {
buffer.append("\t\tlayoutData.defaultWidth = " + (defaultWidth.intValue() < 0 ? -1 : defaultWidth.intValue()) + ";\r\n");
}//if//
if(defaultHeight != null) {
buffer.append("\t\tlayoutData.defaultHeight = " + (defaultHeight.intValue() < 0 ? -1 : defaultHeight.intValue()) + ";\r\n");
}//if//
buffer.append("\t\t" + viewBuilder.getComponentAttributeName(data.getParent()) + ".setLayoutData(layoutData);\r\n");
}//appendInitializationHead()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.layout.FillData";
}//getComponentClassName()//
}//FillLayoutDataBuilder//