Initial commit from SVN.

This commit is contained in:
wcrisman
2014-05-30 10:31:51 -07:00
commit b45e56b890
1968 changed files with 370949 additions and 0 deletions

View File

@@ -0,0 +1,195 @@
/*
* Copyright (c) 2006,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.cell;
import com.common.util.IHashMap;
import com.common.util.IIterator;
import com.common.util.ISet;
import com.common.util.LiteHashMap;
import com.common.util.LiteList;
import com.foundation.view.JefImage;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.definition.IMethodPart;
import com.foundation.view.resource.ResourceReference;
public class CellButtonBuilder extends CellComponentBuilder {
protected static final String STYLE_FLAT = "flat";
//These styles cannot be used in conjunction with the arrow styles.//
protected static final String STYLE_LEFT = "left";
protected static final String STYLE_RIGHT = "right";
protected static final String STYLE_CENTER = "center";
//These styles are only for push type buttons.//
protected static final String STYLE_UP_ARROW = "up-arrow";
protected static final String STYLE_DOWN_ARROW = "down-arrow";
protected static final String STYLE_RIGHT_ARROW = "right-arrow";
protected static final String STYLE_LEFT_ARROW = "left-arrow";
protected static final String STYLE_PUSH = "push";
//These styles are only for toggle type buttons.//
protected static final String STYLE_CHECK = "check";
protected static final String STYLE_RADIO = "radio";
protected static final String STYLE_TOGGLE = "toggle";
protected static final String PROPERTY_TEXT = "text";
protected static final String PROPERTY_IMAGE = "image";
protected static final String PROPERTY_IS_SELECTED = "is-selected";
protected static final String PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY = "auto-synchronize-selection-delay";
protected static final String ASSOCIATION_TEXT = "text";
protected static final String ASSOCIATION_IMAGE = "image";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String METHOD_SELECTION = "selection";
protected static final IHashMap styleMap = new LiteHashMap(CellComponentBuilder.styleMap);
static {
styleMap.put(STYLE_FLAT, "STYLE_FLAT");
styleMap.put(STYLE_LEFT, "STYLE_LEFT");
styleMap.put(STYLE_RIGHT, "STYLE_RIGHT");
styleMap.put(STYLE_CENTER, "STYLE_CENTER");
//These styles are only for push type buttons.//
styleMap.put(STYLE_PUSH, "STYLE_PUSH");
styleMap.put("arrow", "STYLE_ARROW");
styleMap.put("up", "STYLE_UP");
styleMap.put("down", "STYLE_DOWN");
//These styles are only for toggle type buttons.//
styleMap.put(STYLE_CHECK, "STYLE_CHECK");
styleMap.put(STYLE_RADIO, "STYLE_RADIO");
styleMap.put(STYLE_TOGGLE, "STYLE_TOGGLE");
}//static//
/**
* CellButtonBuilder constructor.
*/
public CellButtonBuilder() {
}//CellButtonBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData) {
String typeName = componentData.getComponentType().getName();
String variableName = viewBuilder.getComponentAttributeName(componentData);
ISet styles = componentData.getStyles();
boolean isPush = typeName.equals("button");
boolean isToggle = typeName.equals("button-toggle");
if(isPush) {
IIterator iterator = styles.iterator();
LiteList newStyles = new LiteList(10, 20);
while(iterator.hasNext()) {
String style = (String) iterator.next();
if(style.equals(STYLE_UP_ARROW)) {
newStyles.add("arrow");
newStyles.add("up");
}//if//
else if(style.equals(STYLE_DOWN_ARROW)) {
newStyles.add("arrow");
newStyles.add("down");
}//else if//
else if(style.equals(STYLE_RIGHT_ARROW)) {
newStyles.add("arrow");
newStyles.add("right");
}//else if//
else if(style.equals(STYLE_LEFT_ARROW)) {
newStyles.add("arrow");
newStyles.add("left");
}//else if//
else {
newStyles.add(style);
}//else//
}//while//
styles.removeAll();
styles.addAll(newStyles);
}//if//
else if(isToggle) {
//Default the style to check.//
if(!styles.containsValue(STYLE_RADIO) && !styles.containsValue(STYLE_CHECK) && !styles.containsValue(STYLE_TOGGLE)) {
styles.add(STYLE_CHECK);
}//if//
}//else if//
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, componentData, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
appendInitializationBody(viewBuilder, buffer, componentData, variableName);
}//appendInitializationHead()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
String typeName = data.getComponentType().getName();
Object text = (Object) data.getPropertyValue(PROPERTY_TEXT);
Object image = (Object) data.getPropertyValue(PROPERTY_IMAGE);
Boolean isSelected = (Boolean) data.getPropertyValue(PROPERTY_IS_SELECTED);
Long autoSynchronizeSelectionDelay = (Long) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY);
IMethodPart selectionMethod = data.getMethod(METHOD_SELECTION);
boolean isPush = typeName.equals("cell-button");
boolean isToggle = typeName.equals("cell-button-toggle");
if(text != null) {
if(text instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) text).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setText(\"" + text + "\");\r\n");
}//else//
}//if//
if(image != null) {
if(image instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) image).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setImage(new " + JefImage.class.getName() + "(\"" + image + "\"));\r\n");
}//else//
}//if//
if((isToggle) && (isSelected != null)) {
buffer.append("\t" + variableName + ".setIsSelected(" + (((Boolean) isSelected).booleanValue() ? "Boolean.TRUE" : "Boolean.FALSE") + ");\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_TEXT, variableName, "setTextAssociation", "ASSOCIATION_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IMAGE, variableName, "setImageAssociation", "ASSOCIATION_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
if(isToggle && autoSynchronizeSelectionDelay != null) {
buffer.append("\t" + variableName + ".setAutoSynchronizeSelectionDelay(" + autoSynchronizeSelectionDelay + "l);\r\n");
}//if//
if(isToggle) {
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_SELECTION, variableName, "setSelectionAssociation", "ASSOCIATION_SELECTION", IViewSourceBuilder.ACCESS_TYPE_BOTH);
}//if//
if((isPush) && (selectionMethod != null)) {
String associationIdentifier = viewBuilder.addMethodAssociationIdentifier(data.getDocumentElement(), variableName, METHOD_SELECTION);
viewBuilder.addDirectMethodHandler(data, associationIdentifier, selectionMethod);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".setSelectionMethod(");
viewBuilder.appendMethodAssociation(buffer, variableName, selectionMethod, associationIdentifier);
buffer.append(");\r\n");
}//if//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.cell.CellButton";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
}//CellButtonBuilder//

View File

@@ -0,0 +1,96 @@
/*
* Copyright (c) 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.cell;
import com.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public class CellComboBuilder extends CellComponentBuilder {
protected static final String STYLE_READ_ONLY = "read only";
protected static final String STYLE_SIMPLE = "simple";
protected static final String STYLE_DROP_DOWN = "drop down";
protected static final String PROPERTY_AUTO_SYNCHRONIZE_SELECTION = "auto-synchronize-selection";
protected static final String PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY = "auto-synchronize-selection-delay";
protected static final String PROPERTY_TEXT_LIMIT = "textLimit";
protected static final String ASSOCIATION_COLLECTION = "collection";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String ASSOCIATION_ITEM_TEXT = "item-text";
protected static final IHashMap styleMap = new LiteHashMap(CellComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(CellComponentBuilder.linkMap);
static {
styleMap.put(STYLE_DROP_DOWN, "STYLE_DROP_DOWN");
styleMap.put(STYLE_READ_ONLY, "STYLE_READ_ONLY");
styleMap.put(STYLE_SIMPLE, "STYLE_SIMPLE");
}//static//
/**
* ComboBuilder constructor.
*/
public CellComboBuilder() {
}//ComboBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationHead()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.cell.CellComponentBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
Long autoSynchronizeSelectionDelay = (Long) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY);
String textLimit = (String) data.getPropertyValue(PROPERTY_TEXT_LIMIT);
if(autoSynchronizeSelection != null) {
buffer.append("\t" + variableName + ".setAutoSynchronizeSelection(" + autoSynchronizeSelection + ");\r\n");
}//if//
if(autoSynchronizeSelectionDelay != null) {
buffer.append("\t" + variableName + ".setAutoSynchronizeSelectionDelay(" + autoSynchronizeSelectionDelay + "l);\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_COLLECTION, variableName, "setCollectionAssociation", "ASSOCIATION_COLLECTION", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_SELECTION, variableName, "setSelectionAssociation", "ASSOCIATION_SELECTION", IViewSourceBuilder.ACCESS_TYPE_BOTH);
if(textLimit != null) {
buffer.append("\t");
buffer.append(variableName);
buffer.append(".setTextLimit(");
buffer.append(textLimit);
buffer.append(");\r\n");
}//if//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ITEM_TEXT, variableName, "setItemTextAssociation", "ASSOCIATION_ITEM_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.cell.CellComboBox";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
}//ComboBuilder()//

View File

@@ -0,0 +1,150 @@
/*
* Copyright (c) 2006,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.cell;
import com.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.view.JefColor;
import com.foundation.view.JefFont;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.resource.ResourceReference;
import com.foundation.view.swt.builder.AbstractBuilder;
/*
* The base class for the cell component builders. A cell component is one that resides in zero or more cells of another component, such as a table.
*/
public abstract class CellComponentBuilder extends AbstractBuilder {
protected static final String STYLE_BORDER = "border";
protected static final String STYLE_LEFT_TO_RIGHT = "left to right";
protected static final String STYLE_RIGHT_TO_LEFT = "right to left";
protected static final String PROPERTY_NAME = "name";
protected static final String PROPERTY_IS_ENABLED = "is-enabled";
protected static final String PROPERTY_TOOL_TIP_TEXT = "tool-tip-text";
protected static final String PROPERTY_BACKGROUND_COLOR = "background-color";
protected static final String PROPERTY_FOREGROUND_COLOR = "foreground-color";
protected static final String PROPERTY_FONT = "font";
protected static final String PROPERTY_DECIMAL_SCALE = "decimal-scale";
protected static final String PROPERTY_TAB_ORDER = "tab-order";
protected static final String ASSOCIATION_IS_ENABLED = "is-enabled";
protected static final String ASSOCIATION_TOOL_TIP_TEXT = "tool-tip-text";
protected static final String ASSOCIATION_BACKGROUND_COLOR = "background-color";
protected static final String ASSOCIATION_FOREGROUND_COLOR = "foreground-color";
protected static final String ASSOCIATION_FONT = "font";
protected static final String COMPONENT_MENU_FLOATING = "menu-floating";
protected static final IHashMap styleMap = new LiteHashMap(AbstractBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(AbstractBuilder.linkMap);
static {
styleMap.put(STYLE_BORDER, "STYLE_BORDER");
styleMap.put(STYLE_LEFT_TO_RIGHT, "STYLE_LEFT_TO_RIGHT");
styleMap.put(STYLE_RIGHT_TO_LEFT, "STYLE_RIGHT_TO_LEFT");
}//static//
/**
* CellComponentBuilder constructor.
*/
public CellComponentBuilder() {
}//CellComponentBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String variableName) {
Object isEnabled = (Object) componentData.getPropertyValue(PROPERTY_IS_ENABLED);
Object toolTipText = (Object) componentData.getPropertyValue(PROPERTY_TOOL_TIP_TEXT);
Object backgroundColor = (Object) componentData.getPropertyValue(PROPERTY_BACKGROUND_COLOR);
Object foregroundColor = (Object) componentData.getPropertyValue(PROPERTY_FOREGROUND_COLOR);
Object font = (Object) componentData.getPropertyValue(PROPERTY_FONT);
Integer decimalScale = (Integer) componentData.getPropertyValue(PROPERTY_DECIMAL_SCALE);
IComponentData floatingMenu = componentData.getComponent(COMPONENT_MENU_FLOATING, true);
if(isEnabled != null) {
if(isEnabled instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setIsEnabled(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) isEnabled).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setIsEnabled(" + ((Boolean) isEnabled).booleanValue() + ");\r\n");
}//else//
}//if//
if(toolTipText != null) {
if(toolTipText instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setToolTipText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) toolTipText).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setToolTipText(\"" + toolTipText + "\");\r\n");
}//else//
}//if//
if(backgroundColor != null) {
if(backgroundColor instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setBackgroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) backgroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setBackgroundColor(new " + JefColor.class.getName() + "(\"" + backgroundColor + "\"));\r\n");
}//else//
}//if//
if(foregroundColor != null) {
if(foregroundColor instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setForegroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) foregroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setForegroundColor(new " + JefColor.class.getName() + "(\"" + foregroundColor + "\"));\r\n");
}//else//
}//if//
if(font != null) {
if(font instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setFont(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) font).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setFont(" + JefFont.class.getName() + ".getJefFonts(\"" + JefFont.getJefFontsString((JefFont[]) font) + "\"));\r\n");
}//else//
}//if//
if(decimalScale != null) {
buffer.append("\t" + variableName + ".setDecimalScale(new Integer(" + decimalScale + "));\r\n");
}//if//
appendAssociation(viewBuilder, buffer, componentData, ASSOCIATION_IS_ENABLED, variableName, "setIsEnabledAssociation", "ASSOCIATION_IS_ENABLED", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, componentData, ASSOCIATION_TOOL_TIP_TEXT, variableName, "setToolTipTextAssociation", "ASSOCIATION_TOOL_TIP_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, componentData, ASSOCIATION_FOREGROUND_COLOR, variableName, "setForegroundColorAssociation", "ASSOCIATION_FOREGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, componentData, ASSOCIATION_BACKGROUND_COLOR, variableName, "setBackgroundColorAssociation", "ASSOCIATION_BACKGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, componentData, ASSOCIATION_FONT, variableName, "setFontAssociation", "ASSOCIATION_FONT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
if(floatingMenu != null) {
String initializeMethodName = viewBuilder.addInitializeMenuMethod(componentData, floatingMenu, "PopupMenu");
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
}//if//
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendLinks(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public final void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String variableName) {
//Links are not allowed for cell-components.//
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public final IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
}//CellComponentBuilder//

View File

@@ -0,0 +1,144 @@
/*
* Copyright (c) 2007,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.cell;
import com.common.comparison.Comparator;
import com.common.util.IHashMap;
import com.common.util.IIterator;
import com.common.util.IList;
import com.common.util.LiteHashMap;
import com.common.util.LiteList;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public abstract class CellContainerBuilder extends CellComponentBuilder {
protected static final String STYLE_H_SCROLL = "horizontal scroll";
protected static final String STYLE_V_SCROLL = "vertical scroll";
protected static final String STYLE_NO_BACKGROUND = "no background";
protected static final String STYLE_NO_FOCUS = "no focus";
protected static final String STYLE_NO_MERGE_PAINTS = "no merge paints";
protected static final String STYLE_NO_REDRAW_RESIZE = "no redraw resize";
protected static final String STYLE_NO_RADIO_GROUP = "no radio group";
protected static final String STYLE_EMBEDDED = "embedded";
protected static final String STYLE_DOUBLE_BUFFERED = "double buffered";
protected static final String OPTION_INHERIT_NONE = "none";
protected static final String OPTION_INHERIT_SOME = "some";
protected static final String OPTION_INHERIT_ALL = "all";
protected static final String PROPERTY_INHERIT_BACKGROUND = "inherit-background";
protected static final String COMPONENT_CELL_COMPONENT = "cell-component";
protected static final IHashMap styleMap = new LiteHashMap(CellComponentBuilder.styleMap);
static {
styleMap.put(STYLE_H_SCROLL, "STYLE_H_SCROLL");
styleMap.put(STYLE_V_SCROLL, "STYLE_V_SCROLL");
styleMap.put(STYLE_NO_BACKGROUND, "STYLE_NO_BACKGROUND");
styleMap.put(STYLE_NO_FOCUS, "STYLE_NO_FOCUS");
styleMap.put(STYLE_NO_MERGE_PAINTS, "STYLE_NO_MERGE_PAINTS");
styleMap.put(STYLE_NO_REDRAW_RESIZE, "STYLE_NO_REDRAW_RESIZE");
styleMap.put(STYLE_NO_RADIO_GROUP, "STYLE_NO_RADIO_GROUP");
styleMap.put(STYLE_EMBEDDED, "STYLE_EMBEDDED");
styleMap.put(STYLE_DOUBLE_BUFFERED, "STYLE_DOUBLE_BUFFERED");
}//static//
/**
* CellContainerBuilder constructor.
*/
public CellContainerBuilder() {
}//CellContainerBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
String inheritBackground = (String) data.getPropertyValue(PROPERTY_INHERIT_BACKGROUND);
LiteList orderedComponents = new LiteList(data.getComponents().getSize());
IList components = new LiteList(10, 20);
IIterator componentIterator = null;
if(inheritBackground != null) {
buffer.append("\t" + variableName + ".setInheritBackground(" + getComponentClassName() + "." + (inheritBackground.equalsIgnoreCase(OPTION_INHERIT_SOME) ? "INHERIT_DEFAULT" : inheritBackground.equalsIgnoreCase(OPTION_INHERIT_ALL) ? "INHERIT_FORCE" : "INERIT_NONE") + ");\r\n");
}//if//
//Search for all sub-parts that extend the component type.//
data.getComponents(components, COMPONENT_CELL_COMPONENT, true);
//Order the ordered components by the tab order number such that same numbered items are ordered by definition order.//
orderedComponents.setOrderComparator(new Comparator() {
public int compare(Object value1, Object value2) {
Integer tabOrder1 = (Integer) ((IComponentData) value1).getPropertyValue(PROPERTY_TAB_ORDER);
Integer tabOrder2 = (Integer) ((IComponentData) value2).getPropertyValue(PROPERTY_TAB_ORDER);
return (tabOrder1.intValue() < tabOrder2.intValue()) ? Comparator.LESS_THAN : Comparator.GREATER_THAN;
}//compare()//
});
componentIterator = components.iterator();
//Call the initialize method on the contained components.//
while(componentIterator.hasNext()) {
IComponentData next = (IComponentData) componentIterator.next();
String initializeMethodName = viewBuilder.addInitializeComponentMethod(next, getContainerClassName());
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
if(next.getPropertyValue(PROPERTY_TAB_ORDER) != null) {
orderedComponents.add(next);
}//if//
}//while//
//Write the layout.//
viewBuilder.appendLayout(buffer, data);
//Setup the tab list.//
buffer.append("\t" + variableName + ".setTabOrder(new " + getContainedClassName() + "[] {");
componentIterator = orderedComponents.iterator();
//Iterate over the tab-able controls and add them to the tab list.//
while(componentIterator.hasNext()) {
IComponentData next = (IComponentData) componentIterator.next();
buffer.append(viewBuilder.getComponentAttributeName(next));
if(componentIterator.hasNext()) {
buffer.append(", ");
}//if//
}//while//
buffer.append("});\r\n");
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/**
* Gets the container class name for use in the source generation.
* @return The qualified name of the class that will contain other components.
*/
protected abstract String getContainerClassName();
/**
* Gets the contained class name for use in the source generation.
* @return The qualified name of the class that will be contained within the container.
*/
protected abstract String getContainedClassName();
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.cell.CellButton";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
}//CellContainerBuilder//

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 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.cell;
import com.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public class CellDateTimeBuilder extends CellComponentBuilder {
protected static final String STYLE_SHORT = "short";
protected static final String STYLE_MEDIUM = "medium";
protected static final String STYLE_LONG = "long";
protected static final String STYLE_DATE = "date";
protected static final String STYLE_TIME = "time";
protected static final String STYLE_CALENDAR = "calendar";
protected static final String ASSOCIATION_SELECTION = "selection";
//protected static final String PROPERTY_AUTO_SYNCHRONIZE_SELECTION = "auto-synchronize-selection";
protected static final String PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY = "auto-synchronize-selection-delay";
protected static final IHashMap styleMap = new LiteHashMap(CellComponentBuilder.styleMap);
static {
styleMap.put(STYLE_SHORT, "STYLE_SHORT");
styleMap.put(STYLE_MEDIUM, "STYLE_MEDIUM");
styleMap.put(STYLE_LONG, "STYLE_LONG");
styleMap.put(STYLE_DATE, "STYLE_DATE");
styleMap.put(STYLE_TIME, "STYLE_TIME");
styleMap.put(STYLE_CALENDAR, "STYLE_CALENDAR");
}//static//
/**
* CellDateTimeBuilder constructor.
*/
public CellDateTimeBuilder() {
}//CellDateTimeBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData) {
String variableName = viewBuilder.getComponentAttributeName(componentData);
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, componentData, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
appendInitializationBody(viewBuilder, buffer, componentData, variableName);
}//appendInitializationHead()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.cell.CellComponentBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
//Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
Long autoSynchronizeSelectionDelay = (Long) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY);
//if(autoSynchronizeSelection != null) {
// buffer.append("\t" + variableName + ".setAutoSynchronizeSelection(" + autoSynchronizeSelection + ");\r\n");
//}//if//
if(autoSynchronizeSelectionDelay != null) {
buffer.append("\t" + variableName + ".setAutoSynchronizeSelectionDelay(" + autoSynchronizeSelectionDelay + "l);\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_SELECTION, variableName, "setSelectionAssociation", "ASSOCIATION_SELECTION", IViewSourceBuilder.ACCESS_TYPE_BOTH);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.cell.CellDateTime";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.cell.CellComponentBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
}//CellDateTimeBuilder//

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 2007,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.cell;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public class CellPanelBuilder extends CellContainerBuilder {
/**
* CellPanelBuilder constructor.
*/
public CellPanelBuilder() {
}//CellPanelBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData) {
String variableName = viewBuilder.getComponentAttributeName(componentData);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(componentData)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, componentData, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, componentData, variableName);
}//appendInitializationHead()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.cell.CellComponentBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String variableName) {
super.appendInitializationBody(viewBuilder, buffer, componentData, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.cell.CellContainerBuilder#getContainerClassName()
*/
protected String getContainerClassName() {
return "com.foundation.view.swt.cell.CellPanel";
}//getContainerClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.cell.CellContainerBuilder#getContainedClassName()
*/
protected String getContainedClassName() {
return "com.foundation.view.swt.cell.CellComponent";
}//getContainerClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.cell.CellPanel";
}//getComponentClassName()//
}//CellPanelBuilder//

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 2007,2008 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.cell;
import java.math.BigDecimal;
import com.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public class CellProgressBuilder extends CellComponentBuilder {
protected static final String PROPERTY_MINIMUM = "minimum";
protected static final String PROPERTY_MAXIMUM = "maximum";
protected static final String PROPERTY_PROGRESS = "progress";
protected static final String PROPERTY_MULTIPLIER = "multiplier";
protected static final String ASSOCIATION_MINIMUM = "minimum";
protected static final String ASSOCIATION_MAXIMUM = "maximum";
protected static final String ASSOCIATION_PROGRESS = "progress";
protected static final IHashMap styleMap = new LiteHashMap(CellComponentBuilder.styleMap);
static {
//styleMap.put(STYLE_, "STYLE_");
}//static//
/**
* ProgressBuilder constructor.
*/
public CellProgressBuilder() {
}//ProgressBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData) {
String variableName = viewBuilder.getComponentAttributeName(componentData);
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, componentData, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
appendInitializationBody(viewBuilder, buffer, componentData, variableName);
}//appendInitializationHead()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.cell.CellComponentBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
Integer minimum = (Integer) data.getPropertyValue(PROPERTY_MINIMUM);
Integer maximum = (Integer) data.getPropertyValue(PROPERTY_MAXIMUM);
BigDecimal progress = (BigDecimal) data.getPropertyValue(PROPERTY_PROGRESS);
BigDecimal multiplier = (BigDecimal) data.getPropertyValue(PROPERTY_MULTIPLIER);
if(minimum == null) {
minimum = new Integer(0);
}//if//
if((maximum == null) || (maximum.intValue() <= minimum.intValue())) {
maximum = new Integer(minimum.intValue() + 1);
}//if//
if((progress == null) || (progress.intValue() < minimum.intValue()) || (progress.intValue() > maximum.intValue())) {
progress = new BigDecimal(minimum.longValue());
}//if//
if(progress != null) {
buffer.append("\t" + variableName + ".setProgress(new java.math.BigDecimal(\"" + progress + "\"));\r\n");
}//if//
if(minimum != null) {
buffer.append("\t" + variableName + ".setMinimum(new Integer(" + minimum + "));\r\n");
}//if//
if(maximum != null) {
buffer.append("\t" + variableName + ".setMaximum(new Integer(" + maximum + "));\r\n");
}//if//
if(multiplier != null) {
buffer.append("\t" + variableName + ".setMultiplier(new java.math.BigDecimal(\"" + multiplier + "\"));\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_MINIMUM, variableName, "setMinimumAssociation", "ASSOCIATION_MINIMUM", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_MAXIMUM, variableName, "setMaximumAssociation", "ASSOCIATION_MAXIMUM", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_PROGRESS, variableName, "setProgressAssociation", "ASSOCIATION_PROGRESS", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.cell.CellProgress";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.cell.CellComponentBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
}//ProgressBuilder//

View File

@@ -0,0 +1,558 @@
/*
* Copyright (c) 2007,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.cell;
import java.math.BigDecimal;
import com.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.util.xml.IAttribute;
import com.foundation.util.xml.INode;
import com.foundation.util.xml.Node;
import com.foundation.view.JefColor;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.builder.ViewBuilderException;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.definition.IComponentType;
import com.foundation.view.definition.IViewModel;
import com.foundation.view.resource.ResourceReference;
public class CellTextBuilder extends CellComponentBuilder {
protected static final String STYLE_MULTI = "multi line";
protected static final String STYLE_SINGLE = "single line";
protected static final String STYLE_READ_ONLY = "read only";
protected static final String STYLE_WRAP = "wrap";
protected static final String STYLE_LEFT = "left";
protected static final String STYLE_RIGHT = "right";
protected static final String STYLE_CENTER = "center";
//Properties//
protected static final String PROPERTY_AUTO_SYNCHRONIZE_TEXT = "auto-synchronize-text";
protected static final String PROPERTY_AUTO_SYNCHRONIZE_TEXT_DELAY = "auto-synchronize-text-delay";
protected static final String PROPERTY_SHADOW_TEXT = "ghost-text";
protected static final String PROPERTY_SHADOW_TEXT_COLOR = "ghost-text-color";
protected static final String PROPERTY_SELECT_ON_FOCUS = "select-on-focus";
protected static final String PROPERTY_AUTO_VALIDATE = "auto-validate";
//Associations//
protected static final String ASSOCIATION_SHADOW_TEXT_COLOR = "ghost-text-color";
/** The base type for the different data type metadata. */
protected static final String COMPONENT_FORMAT = "format";
//Format Properties//
protected static final String FORMAT_PROPERTY_TEXT = "text";
protected static final String FORMAT_PROPERTY_USE_NULL = "use-null";
protected static final String FORMAT_PROPERTY_ECHO_CHAR = "echo-char";
protected static final String FORMAT_PROPERTY_LOCALE = "locale";
protected static final String FORMAT_PROPERTY_MAX_VALUE = "max-value";
protected static final String FORMAT_PROPERTY_MIN_VALUE = "min-value";
protected static final String FORMAT_PROPERTY_MAX_INTEGER_DIGITS = "max-integer-digits";
protected static final String FORMAT_PROPERTY_MIN_INTEGER_DIGITS = "min-integer-digits";
protected static final String FORMAT_PROPERTY_MAX_FRACTION_DIGITS = "max-fraction-digits";
protected static final String FORMAT_PROPERTY_MIN_FRACTION_DIGITS = "min-fraction-digits";
protected static final String FORMAT_PROPERTY_GROUP = "group";
protected static final String FORMAT_PROPERTY_MODEL_TYPE = "model-type";
protected static final String FORMAT_PROPERTY_MULTIPLIER = "multiplier";
protected static final String FORMAT_PROPERTY_FORMAT = "format";
protected static final String FORMAT_PROPERTY_REALTIME = "realtime";
protected static final String FORMAT_PROPERTY_NEGATIVE_COLOR = "negative-color";
protected static final String FORMAT_PROPERTY_DEFAULT_VALUE = "default-value";
//Format Associations//
protected static final String FORMAT_ASSOCIATION_TEXT = "text";
protected static final String FORMAT_ASSOCIATION_VALUE = "value";
protected static final String FORMAT_ASSOCIATION_LOCALE = "locale";
protected static final String FORMAT_ASSOCIATION_MAX_VALUE = "max-value";
protected static final String FORMAT_ASSOCIATION_MIN_VALUE = "min-value";
protected static final String FORMAT_ASSOCIATION_FORMAT = "format";
protected static final String FORMAT_ASSOCIATION_NEGATIVE_COLOR = "negative-color";
protected static final IHashMap styleMap = new LiteHashMap(CellComponentBuilder.styleMap);
static {
styleMap.put(STYLE_MULTI, "STYLE_MULTI");
styleMap.put(STYLE_SINGLE, "STYLE_SINGLE");
styleMap.put(STYLE_READ_ONLY, "STYLE_READ_ONLY");
styleMap.put(STYLE_WRAP, "STYLE_WRAP");
styleMap.put(STYLE_LEFT, "STYLE_LEFT");
styleMap.put(STYLE_CENTER, "STYLE_CENTER");
styleMap.put(STYLE_RIGHT, "STYLE_RIGHT");
}//static//
/**
* TextBuilder constructor.
*/
public CellTextBuilder() {
}//TextBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationHead()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.cell.CellComponentBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
boolean isReadOnly = data.getStyles().containsValue(STYLE_READ_ONLY);
Boolean autoSynchronizeText = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_TEXT);
Long autoSynchronizeTextDelay = (Long) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_TEXT_DELAY);
Boolean autoValidate = (Boolean) data.getPropertyValue(PROPERTY_AUTO_VALIDATE);
Object shadowText = (Object) data.getPropertyValue(PROPERTY_SHADOW_TEXT);
Object shadowTextColor = (Object) data.getPropertyValue(PROPERTY_SHADOW_TEXT_COLOR);
Boolean selectOnFocus = (Boolean) data.getPropertyValue(PROPERTY_SELECT_ON_FOCUS);
Integer typeNumber = null;
IComponentData formatComponent = data.getComponent(COMPONENT_FORMAT, true);
if(formatComponent != null) {
appendFormat(viewBuilder, buffer, variableName, formatComponent, isReadOnly);
}//if//
if(typeNumber == null) {
typeNumber = IViewSourceBuilder.TYPE_STRING;
}//if//
//if(shadowText == null && shadowTextColor == null) {
// buffer.append("\t" + variableName + ".setAutoGenerateShadowTextColor(true);\r\n");
//}//if//
if((!isReadOnly) && (autoSynchronizeText != null)) {
buffer.append("\t" + variableName + ".setAutoSynchronizeValue(" + autoSynchronizeText + ");\r\n");
}//if//
if((!isReadOnly) && (autoSynchronizeTextDelay != null)) {
buffer.append("\t" + variableName + ".setAutoSynchronizeValueDelay(" + autoSynchronizeTextDelay + "l);\r\n");
}//if//
if((!isReadOnly) && (autoValidate != null)) {
buffer.append("\t" + variableName + ".setAutoValidate(" + autoValidate + ");\r\n");
}//if//
if(shadowText != null) {
if(shadowText instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setShadowText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) shadowText).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setShadowText(\"" + shadowText + "\");\r\n");
}//else//
}//if//
if(shadowTextColor != null) {
if(shadowTextColor instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setShadowTextColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) shadowTextColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setShadowTextColor(new " + JefColor.class.getName() + "(\"" + shadowTextColor + "\"));\r\n");
}//else//
}//if//
if(selectOnFocus != null) {
buffer.append("\t" + variableName + ".setSelectOnFocus(" + selectOnFocus + ");\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_SHADOW_TEXT_COLOR, variableName, "setShadowTextColorAssociation", "ASSOCIATION_SHADOW_TEXT_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/**
* Gets the class name for the format class based on the given format name as defined in the cml file.
* @param formatName The cml file format name.
* @return The format class name.
*/
protected String getFormatTypeName(String formatName, IComponentData formatComponent) {
String result;
if(formatName.equals("integer-format")) {
result = getComponentClassName() + ".IntegerFormat";
}//if//
else if(formatName.equals("decimal-format")) {
result = getComponentClassName() + ".FloatFormat";
}//else if//
else if(formatName.equals("percent-format")) {
result = getComponentClassName() + ".PercentFormat";
}//else if//
else if(formatName.equals("currency-format")) {
result = getComponentClassName() + ".CurrencyFormat";
}//else if//
else if(formatName.equals("text-format")) {
//Use the text format by default.//
result = getComponentClassName() + ".TextFormat";
}//else if//
else {
throw new ViewBuilderException("Unknown format type: " + formatName, formatComponent.getDocumentElement());
}//else//
return result;
}//getFormatTypeName()//
/**
* Appends the content for the format based on the format name.
* @param viewBuilder
* @param buffer
* @param variableName
* @param formatComponent
* @param formatName
* @param isReadOnly
*/
protected void appendFormatContent(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData formatComponent, String formatName, boolean isReadOnly) {
if(formatName.equals("integer-format")) {
appendIntegerFormat(viewBuilder, buffer, variableName, formatComponent, isReadOnly);
}//if//
else if(formatName.equals("decimal-format")) {
appendDecimalFormat(viewBuilder, buffer, variableName, formatComponent, isReadOnly);
}//else if//
else if(formatName.equals("percent-format")) {
appendPercentFormat(viewBuilder, buffer, variableName, formatComponent, isReadOnly);
}//else if//
else if(formatName.equals("currency-format")) {
appendCurrencyFormat(viewBuilder, buffer, variableName, formatComponent, isReadOnly);
}//else if//
else if(formatName.equals("text-format")) {
appendTextFormat(viewBuilder, buffer, variableName, formatComponent, isReadOnly);
}//else if//
}//appendFormatContent()//
/**
* Appends the setFormat method to the view source.
* @param viewBuilder
* @param buffer
* @param variableName
* @param formatComponent The component metadata for the format.
* @param isReadOnly
*/
public void appendFormat(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData formatComponent, boolean isReadOnly) {
String formatName = formatComponent.getComponentType().getName();
String temporaryVariableName = variableName + "Format";
String formatTypeName = getFormatTypeName(formatName, formatComponent);
buffer.append('\t');
buffer.append(formatTypeName);
buffer.append(' ');
buffer.append(temporaryVariableName);
buffer.append(" = (");
buffer.append(formatTypeName);
buffer.append(") ");
buffer.append(variableName);
buffer.append(".initializeFormat(");
buffer.append(formatTypeName);
buffer.append(".class);\r\n");
appendFormatContent(viewBuilder, buffer, temporaryVariableName, formatComponent, formatName, isReadOnly);
}//appendFormat()//
/**
* Appends the integer (whole number) format parameters to the format constructor.
* @param viewBuilder
* @param buffer
* @param variableName
* @param formatComponent The component metadata for the format.
* @param isReadOnly
*/
public void appendIntegerFormat(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData formatComponent, boolean isReadOnly) {
String locale = (String) formatComponent.getPropertyValue(FORMAT_PROPERTY_LOCALE);
BigDecimal maxValue = (BigDecimal) formatComponent.getPropertyValue(FORMAT_PROPERTY_MAX_VALUE);
BigDecimal minValue = (BigDecimal) formatComponent.getPropertyValue(FORMAT_PROPERTY_MIN_VALUE);
Integer maxIntegerDigits = (Integer) formatComponent.getPropertyValue(FORMAT_PROPERTY_MAX_INTEGER_DIGITS);
Integer minIntegerDigits = (Integer) formatComponent.getPropertyValue(FORMAT_PROPERTY_MIN_INTEGER_DIGITS);
BigDecimal defaultValue = (BigDecimal) formatComponent.getPropertyValue(FORMAT_PROPERTY_DEFAULT_VALUE);
Boolean group = (Boolean) formatComponent.getPropertyValue(FORMAT_PROPERTY_GROUP);
String modelType = (String) formatComponent.getPropertyValue(FORMAT_PROPERTY_MODEL_TYPE);
String format = (String) formatComponent.getPropertyValue(FORMAT_PROPERTY_FORMAT);
Boolean realtime = (Boolean) formatComponent.getPropertyValue(FORMAT_PROPERTY_REALTIME);
Object negativeColor = (Object) formatComponent.getPropertyValue(FORMAT_PROPERTY_NEGATIVE_COLOR);
if(locale != null) {
buffer.append("\t" + variableName + ".setLocale(\"" + locale + "\");\r\n");
}//if//
if(maxIntegerDigits != null) {
buffer.append("\t" + variableName + ".setMaxValue(new BigDecimal(\"" + maxValue.toString() + "\"));\r\n");
}//if//
if(minIntegerDigits != null) {
buffer.append("\t" + variableName + ".setMinValue(new BigDecimal(\"" + minValue.toString() + "\"));\r\n");
}//if//
if(maxIntegerDigits != null) {
buffer.append("\t" + variableName + ".setMaxIntegerDigits(new Integer(" + maxIntegerDigits + "));\r\n");
}//if//
if(minIntegerDigits != null) {
buffer.append("\t" + variableName + ".setMinIntegerDigits(new Integer(" + minIntegerDigits + "));\r\n");
}//if//
if(group != null) {
buffer.append("\t" + variableName + ".setGroup(" + (group.booleanValue() ? "Boolean.TRUE" : "Boolean.FALSE") + ");\r\n");
}//if//
if(realtime != null) {
buffer.append("\t" + variableName + ".setRealtime(" + realtime.booleanValue() + ");\r\n");
}//if//
if(format != null) {
buffer.append("\t" + variableName + ".setFormat(\"" + format + "\");\r\n");
}//if//
if(negativeColor != null) {
if(negativeColor instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setNegativeColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) negativeColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setNegativeColor(new " + JefColor.class.getName() + "(\"" + negativeColor + "\"));\r\n");
}//else//
}//if//
if(modelType != null) {
String typeIdentifier = null;
if(modelType.equals("byte")) {
typeIdentifier = "DATA_TYPE_BYTE";
if(maxValue == null) {
maxValue = new BigDecimal(Byte.MAX_VALUE);
}//if//
if(minValue == null) {
minValue = new BigDecimal(Byte.MIN_VALUE);
}//if//
}//if//
else if(modelType.equals("short")) {
typeIdentifier = "DATA_TYPE_SHORT";
if(maxValue == null) {
maxValue = new BigDecimal(Short.MAX_VALUE);
}//if//
if(minValue == null) {
minValue = new BigDecimal(Short.MIN_VALUE);
}//if//
}//else if//
else if(modelType.equals("long")) {
typeIdentifier = "DATA_TYPE_LONG";
if(maxValue == null) {
maxValue = new BigDecimal(Long.MAX_VALUE);
}//if//
if(minValue == null) {
minValue = new BigDecimal(Long.MIN_VALUE);
}//if//
}//else if//
else if(modelType.equals("float")) {
typeIdentifier = "DATA_TYPE_FLOAT";
if(maxValue == null) {
maxValue = new BigDecimal(Float.MAX_VALUE);
}//if//
if(minValue == null) {
//minValue = new BigDecimal(Float.MIN_VALUE);
minValue = new BigDecimal(-Float.MAX_VALUE);
}//if//
}//else if//
else if(modelType.equals("double")) {
typeIdentifier = "DATA_TYPE_DOUBLE";
if(maxValue == null) {
maxValue = new BigDecimal(Double.MAX_VALUE);
}//if//
if(minValue == null) {
//minValue = new BigDecimal(Double.MIN_VALUE);
minValue = new BigDecimal(-Double.MAX_VALUE);
}//if//
}//else if//
else if(modelType.equals("integer")) {
typeIdentifier = "DATA_TYPE_INTEGER";
if(maxValue == null) {
maxValue = new BigDecimal(Integer.MAX_VALUE);
}//if//
if(minValue == null) {
minValue = new BigDecimal(Integer.MIN_VALUE);
}//if//
}//else if//
else if(modelType.equals("big-decimal")) {
typeIdentifier = "DATA_TYPE_BIG_DECIMAL";
}//else if//
else {
throw new ViewBuilderException("Unexpected model-type found: " + modelType, formatComponent.getDocumentElement());
}//else//
if(typeIdentifier != null) {
buffer.append("\t" + variableName + ".setModelType(" + getComponentClassName() + ".IntegerFormat." + typeIdentifier + ");\r\n");
}//if//
}//if//
if(maxValue != null) {
buffer.append("\t" + variableName + ".setMaxValue(new java.math.BigDecimal(\"" + maxValue.toString() + "\"));\r\n");
}//if//
if(minValue != null) {
buffer.append("\t" + variableName + ".setMinValue(new java.math.BigDecimal(\"" + minValue.toString() + "\"));\r\n");
}//if//
if(defaultValue != null) {
buffer.append("\t" + variableName + ".setDefaultValue(new java.math.BigDecimal(\"" + defaultValue.toString() + "\"));\r\n");
}//if//
appendAssociation(viewBuilder, buffer, formatComponent, FORMAT_ASSOCIATION_VALUE, variableName, "setValueAssociation", "FORMAT_ASSOCIATION_VALUE", isReadOnly ? IViewSourceBuilder.ACCESS_TYPE_GET_ONLY : IViewSourceBuilder.ACCESS_TYPE_BOTH);
appendAssociation(viewBuilder, buffer, formatComponent, FORMAT_ASSOCIATION_MAX_VALUE, variableName, "setMaxValueAssociation", "FORMAT_ASSOCIATION_MAX_VALUE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, formatComponent, FORMAT_ASSOCIATION_MIN_VALUE, variableName, "setMinValueAssociation", "FORMAT_ASSOCIATION_MIN_VALUE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, formatComponent, FORMAT_ASSOCIATION_LOCALE, variableName, "setLocaleAssociation", "FORMAT_ASSOCIATION_LOCALE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, formatComponent, FORMAT_ASSOCIATION_NEGATIVE_COLOR, variableName, "setNegativeColorAssociation", "FORMAT_ASSOCIATION_NEGATIVE_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, formatComponent, FORMAT_ASSOCIATION_FORMAT, variableName, "setFormatAssociation", "FORMAT_ASSOCIATION_FORMAT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
}//appendIntegerFormat()//
/**
* Appends the decimal (floating or fixed point non-whole number) format parameters to the format constructor.
* @param viewBuilder
* @param buffer
* @param variableName
* @param formatComponent The component metadata for the format.
* @param isReadOnly
*/
public void appendDecimalFormat(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData formatComponent, boolean isReadOnly) {
Integer maxFractionDigits = (Integer) formatComponent.getPropertyValue(FORMAT_PROPERTY_MAX_FRACTION_DIGITS);
Integer minFractionDigits = (Integer) formatComponent.getPropertyValue(FORMAT_PROPERTY_MIN_FRACTION_DIGITS);
Integer multiplier = (Integer) formatComponent.getPropertyValue(FORMAT_PROPERTY_MULTIPLIER);
appendIntegerFormat(viewBuilder, buffer, variableName, formatComponent, isReadOnly);
if(maxFractionDigits != null) {
buffer.append("\t" + variableName + ".setMaxFractionDigits(new Integer(" + maxFractionDigits + "));\r\n");
}//if//
if(minFractionDigits != null) {
buffer.append("\t" + variableName + ".setMinFractionDigits(new Integer(" + minFractionDigits + "));\r\n");
}//if//
if(multiplier != null) {
buffer.append("\t" + variableName + ".setMultiplier(new Integer(" + multiplier + "));\r\n");
}//if//
}//appendIntegerFormat()//
/**
* Appends the percent format parameters to the format constructor.
* @param viewBuilder
* @param buffer
* @param variableName
* @param formatComponent The component metadata for the format.
* @param isReadOnly
*/
public void appendPercentFormat(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData formatComponent, boolean isReadOnly) {
appendDecimalFormat(viewBuilder, buffer, variableName, formatComponent, isReadOnly);
}//appendPercentFormat()//
/**
* Appends the currency format parameters to the format constructor.
* @param viewBuilder
* @param buffer
* @param variableName
* @param formatComponent The component metadata for the format.
* @param isReadOnly
*/
public void appendCurrencyFormat(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData formatComponent, boolean isReadOnly) {
appendIntegerFormat(viewBuilder, buffer, variableName, formatComponent, isReadOnly);
}//appendCurrencyFormat()//
/**
* Appends the text format parameters to the format constructor.
* @param viewBuilder
* @param buffer
* @param variableName
* @param formatComponent The component metadata for the format.
* @param isReadOnly
*/
public void appendTextFormat(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData formatComponent, boolean isReadOnly) {
String text = (String) formatComponent.getPropertyValue(FORMAT_PROPERTY_TEXT);
Character echoChar = (Character) formatComponent.getPropertyValue(FORMAT_PROPERTY_ECHO_CHAR);
Boolean useNull = (Boolean) formatComponent.getPropertyValue(FORMAT_PROPERTY_USE_NULL);
if(useNull != null) {
buffer.append("\t" + variableName + ".setUseNull(" + useNull + ");\r\n");
}//if//
if(echoChar != null) {
buffer.append("\t" + variableName + ".setEchoCharacter(new Character('" + echoChar + "'));\r\n");
}//if//
if(text != null) {
buffer.append("\t" + variableName + ".setValue(\"" + text + "\");\r\n");
}//if//
appendAssociation(viewBuilder, buffer, formatComponent, FORMAT_ASSOCIATION_VALUE, variableName, "setValueAssociation", "FORMAT_ASSOCIATION_VALUE", isReadOnly ? IViewSourceBuilder.ACCESS_TYPE_GET_ONLY : IViewSourceBuilder.ACCESS_TYPE_BOTH);
appendAssociation(viewBuilder, buffer, formatComponent, FORMAT_ASSOCIATION_TEXT, variableName, "setValueAssociation", "FORMAT_ASSOCIATION_TEXT", isReadOnly ? IViewSourceBuilder.ACCESS_TYPE_GET_ONLY : IViewSourceBuilder.ACCESS_TYPE_BOTH);
}//appendTextFormat()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#updateComponent(com.foundation.view.definition.IViewModel, com.foundation.util.xml.INode)
*/
public boolean updateComponent(IViewModel viewModel, INode node) {
boolean result = false;
INode textAssociation = findAssociationNode(node, "text");
IComponentType formatType = ((IComponentType) viewModel.getComponentTypeMap().get("text")).getDefinedComponentType("format");
INode formatNode = findNode(node, formatType);
IAttribute typeAttribute = node.getAttribute("type");
IAttribute echoCharAttribute = node.getAttribute("echo-char");
if(formatNode == null) {
String type = typeAttribute != null ? typeAttribute.getValue() : null;
node.getElements().remove(textAssociation);
node.removeAttribute("type");
node.removeAttribute("echo-char");
if((type != null) && (type.equals("integer") || type.equals("byte") || type.equals("short") || type.equals("long"))) {
formatNode = new Node("integer-format");
if(textAssociation != null) {
textAssociation.removeAttribute("function");
textAssociation.addAttribute("function", "value");
formatNode.getElements().add(textAssociation);
}//if//
}//if//
else if((type != null) && (type.equals("float") || type.equals("double") || type.equals("big-decimal"))) {
formatNode = new Node("decimal-format");
if(textAssociation != null) {
textAssociation.removeAttribute("function");
textAssociation.addAttribute("function", "value");
formatNode.getElements().add(textAssociation);
}//if//
}//else if//
else {
formatNode = new Node("text-format");
if(echoCharAttribute != null) {
formatNode.addAttribute(echoCharAttribute);
}//if//
if(textAssociation != null) {
textAssociation.removeAttribute("function");
textAssociation.addAttribute("function", "value");
formatNode.getElements().add(textAssociation);
}//if//
}//if//
node.getElements().add(formatNode);
result = true;
}//if//
return result;
}//updateComponent()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.cell.CellTextField";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
}//TextBuilder//