92 lines
3.3 KiB
Java
92 lines
3.3 KiB
Java
|
|
/*
|
||
|
|
* Copyright (c) 2004,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 RowLayoutDataBuilder extends AbstractLayoutBuilder {
|
||
|
|
protected static final String ALIGNMENT_BEGINNING = "beginning";
|
||
|
|
protected static final String ALIGNMENT_CENTER = "center";
|
||
|
|
protected static final String ALIGNMENT_END = "end";
|
||
|
|
protected static final String ALIGNMENT_FILL = "fill";
|
||
|
|
|
||
|
|
protected static final String PROPERTY_WIDTH = "width";
|
||
|
|
protected static final String PROPERTY_HEIGHT = "height";
|
||
|
|
protected static final String PROPERTY_EXCLUDE = "exclude";
|
||
|
|
protected static final String PROPERTY_ALIGNMENT = "horizontal-alignment";
|
||
|
|
/**
|
||
|
|
* RowLayoutDataBuilder constructor.
|
||
|
|
*/
|
||
|
|
public RowLayoutDataBuilder() {
|
||
|
|
super();
|
||
|
|
}//RowLayoutDataBuilder()//
|
||
|
|
/* (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 width = (Integer) data.getPropertyValue(PROPERTY_WIDTH);
|
||
|
|
Integer height = (Integer) data.getPropertyValue(PROPERTY_HEIGHT);
|
||
|
|
Boolean exclude = (Boolean) data.getPropertyValue(PROPERTY_EXCLUDE);
|
||
|
|
String alignment = (String) data.getPropertyValue(PROPERTY_ALIGNMENT);
|
||
|
|
|
||
|
|
buffer.append("\t\t" + getComponentClassName() + " layoutData = new " + getComponentClassName() + "();\r\n");
|
||
|
|
buffer.append("\t\t\r\n");
|
||
|
|
|
||
|
|
if(height != null) {
|
||
|
|
buffer.append("\t\tlayoutData.height = " + height + ";\r\n");
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
if(width != null) {
|
||
|
|
buffer.append("\t\tlayoutData.width = " + width + ";\r\n");
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
if(exclude != null) {
|
||
|
|
buffer.append("\tlayout.exclude = " + exclude + ";\r\n");
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
if(alignment != null) {
|
||
|
|
alignment = getAlignmentSource(alignment);
|
||
|
|
|
||
|
|
if(alignment != null) {
|
||
|
|
buffer.append("\t\tlayoutData.alignment = " + getComponentClassName() + "." + alignment + ";\r\n");
|
||
|
|
}//if//
|
||
|
|
}//if//
|
||
|
|
|
||
|
|
buffer.append("\t\t" + viewBuilder.getComponentAttributeName(data.getParent()) + ".setLayoutData(layoutData);\r\n");
|
||
|
|
}//appendInitializationHead()//
|
||
|
|
/**
|
||
|
|
* Converts the alignment identifier string into the necessary source code.
|
||
|
|
* @param alignment The string identifying which alignment to use.
|
||
|
|
* @return The source code specifying which alignment.
|
||
|
|
*/
|
||
|
|
protected String getAlignmentSource(String alignment) {
|
||
|
|
String source = null;
|
||
|
|
|
||
|
|
if(ALIGNMENT_BEGINNING.equals(alignment)) {
|
||
|
|
source = "BEGINNING";
|
||
|
|
}//if//
|
||
|
|
else if(ALIGNMENT_CENTER.equals(alignment)) {
|
||
|
|
source = "CENTER";
|
||
|
|
}//else if//
|
||
|
|
else if(ALIGNMENT_END.equals(alignment)) {
|
||
|
|
source = "END";
|
||
|
|
}//else if//
|
||
|
|
else if(ALIGNMENT_FILL.equals(alignment)) {
|
||
|
|
source = "FILL";
|
||
|
|
}//else if//
|
||
|
|
|
||
|
|
return source;
|
||
|
|
}//getAlignmentSource()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
|
||
|
|
*/
|
||
|
|
public String getComponentClassName() {
|
||
|
|
return "com.foundation.view.swt.layout.RowData";
|
||
|
|
}//getComponentClassName()//
|
||
|
|
}//RowLayoutDataBuilder//
|