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,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="/Foundation View Builder"/>
<classpathentry kind="src" path="/Foundation"/>
<classpathentry kind="src" path="/Common"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Foundation SWT View Builder</name>
<comment></comment>
<projects>
<project>Common</project>
<project>Foundation</project>
<project>Foundation SWT</project>
<project>Foundation View Builder</project>
<project>SWT</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,277 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.util.xml.IElement;
import com.foundation.util.xml.INode;
import com.foundation.view.definition.*;
import com.foundation.view.builder.*;
public abstract class AbstractBuilder implements IBuilder {
private static final String LINK_TARGET_SYNCHRONIZE = "synchronize";
private static final String LINK_TARGET_SYNCHRONIZE_ALL = "synchronizeAll";
protected static final IHashMap styleMap = new LiteHashMap(10);
protected static final IHashMap linkMap = new LiteHashMap(10);
static {
linkMap.put(LINK_TARGET_SYNCHRONIZE, "LINK_TARGET_SYNCHRONIZE");
linkMap.put(LINK_TARGET_SYNCHRONIZE_ALL, "LINK_TARGET_SYNCHRONIZE_ALL");
}//static//
/**
* AbstractCodeSupport constructor.
*/
public AbstractBuilder() {
}//AbstractCodeSupport()//
/**
* Locate the first node that is or extends the given component type.
* @param node The node to look in.
* @param baseType The component type for the desired node.
* @return The node found, or null.
*/
public INode findNode(INode node, IComponentType baseType) {
IIterator iterator = node.getElements().iterator();
IHashSet typeNameSet = baseType.collectTypeNames();
INode result = null;
while((result == null) && (iterator.hasNext())) {
Object next = iterator.next();
if((((IElement) next).isNode()) && (typeNameSet.containsValue(((INode) next).getName()))) {
result = (INode) next;
}//if//
}//while//
return result;
}//findNode()//
/**
* Locate the first node with the given name.
* @param node The node to look in.
* @param name The name of the node to find.
* @return The node found, or null.
*/
public INode findAssociationNode(INode node, String function) {
IIterator iterator = node.getElements().iterator();
INode result = null;
while((result == null) && (iterator.hasNext())) {
Object next = iterator.next();
if((((IElement) next).isNode()) && ((((INode) next).getName().equals("association-group")) || (((INode) next).getName().equals("association"))) && (((INode) next).getAttributeValue("function").equals(function))) {
result = (INode) next;
}//if//
}//while//
return result;
}//findAssociationNode()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendComponentConstructorParameters(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition2.ComponentData, java.lang.String)
*/
public final void appendComponentConstructorParameters(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String parentVariable) {
appendComponentConstructorParameters(viewBuilder, buffer, componentData, parentVariable, null);
}//appendComponentConstructorParameters()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendComponentConstructorParameters(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition2.ComponentData, java.lang.String, java.lang.String)
*/
public void appendComponentConstructorParameters(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String parentVariable, String controlIdentifier) {
String name = viewBuilder.getComponentName(componentData);
boolean hasStyle = false;
String additionalStyles = null;
if(controlIdentifier == null) {
controlIdentifier = (name != null ? viewBuilder.addComponentNameIdentifier(componentData.getDocumentElement(), name) : "null");
}//if//
if(parentVariable != null) {
buffer.append(parentVariable);
buffer.append(", ");
}//if//
buffer.append(controlIdentifier);
buffer.append(", ");
hasStyle = appendComponentStyles(viewBuilder, buffer, componentData);
additionalStyles = getAdditionalStyleSource(componentData);
if(additionalStyles != null) {
if(hasStyle) {
buffer.append('|');
}//if//
buffer.append(additionalStyles);
hasStyle = true;
}//if//
if(!hasStyle) {
buffer.append('0');
}//else//
}//appendComponentConstructorParameters()//
/**
* Appends association source to the view source code.
* @param viewBuilder The view builder managing the building of the view source.
* @param buffer The buffer for the outputed source code.
* @param data The component data for the component defining the association.
* @param associationFunction The function name for the association as defined in the cml file for the view control.
* @param variableName The variable name that defines the setter for the association object.
* @param setter The name of the setter method that sets the association object.
* @param identifier The identifier part used to generate identifiers for the association. This should look something like 'ASSOCIATION_FONT'.
* @param accessType One of the access types defined by IViewSourceBuilder.
* @see IViewSourceBuilder.ACCESS_TYPE_GET_ONLY
* @see IViewSourceBuilder.ACCESS_TYPE_BOTH
*/
protected void appendAssociation(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String associationFunction, String variableName, String setter, String identifier, byte accessType) {
IAssociationGroupPart association = data.getAssociations(associationFunction);
if(association != null) {
buffer.append("\t");
buffer.append(variableName);
buffer.append(".");
buffer.append(setter);
buffer.append("(");
viewBuilder.appendAssociation(data, buffer, variableName, association, identifier, accessType);
buffer.append(");\r\n");
}//if//
}//appendAssociation()//
/**
* Appends association source to the view source code.
* @param viewBuilder The view builder managing the building of the view source.
* @param buffer The buffer for the outputed source code.
* @param data The component data for the component defining the association.
* @param associationFunction The function name for the association as defined in the cml file for the view control.
* @param variableName The variable name that defines the setter for the association object.
* @param setter The name of the setter method that sets the association object.
* @param identifier The identifier part used to generate identifiers for the association. This should look something like 'ASSOCIATION_FONT'.
* @param accessType One of the access types defined by IViewSourceBuilder.
* @see IViewSourceBuilder.ACCESS_TYPE_GET_ONLY
*/
protected void appendCollectionAssociation(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String associationFunction, String variableName, String setter, String identifier) {
IList associations = data.getCollectingAssociations(associationFunction);
if(associations != null) {
buffer.append("\t");
buffer.append(variableName);
buffer.append(".");
buffer.append(setter);
buffer.append("(");
viewBuilder.appendCollectingAssociation(data, buffer, variableName, associations, identifier, IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
buffer.append(");\r\n");
}//if//
}//appendCollectionAssociation()//
/**
* Appends the component's styles to the source (separates the styles by '|' characters).
* @param viewBuilder The view builder for which the source is being built.
* @param buffer The buffer containing the source.
* @param componentData The component data for the component whose source is being built by this builder.
* @return Whether any styles were appended to the source.
*/
protected boolean appendComponentStyles(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData) {
boolean result = false;
ISet styles = componentData.getStyles();
//Append the style.//
if(styles.getSize() > 0) {
IIterator iterator = styles.iterator();
while(iterator.hasNext()) {
Object styleName = iterator.next();
String style = getStyleSource((String) styleName);
if(style != null) {
if(!result) {
result = true;
}//if//
else {
buffer.append('|');
}//else//
buffer.append(style);
}//if//
else {
throw new ViewBuilderException("Cannot identify the style: " + styleName + " for this " + getComponentClassName() + (viewBuilder.getComponentName(componentData) != null ? " named " + viewBuilder.getComponentName(componentData) : " [unnamed]"), -1, -1, -1);
}//else//
}//while//
}//if//
return result;
}//appendComponentStyles()//
/**
* Gets the source for a given style.
* @param styleName The style name used in the VML file and defined by the component type.
* @return The style name used by the underlying view system.
*/
protected String getStyleSource(String styleName) {
if(!getStyleMap().containsKey(styleName)) {
throw new ViewBuilderException("The style '" + styleName + "' is not defined by the builder for the component type '" + getComponentClassName() + "'", -1, -1, -1);
}//if//
return getComponentClassName().replace('$', '.') + '.' + ((String) getStyleMap().get(styleName));
}//getStyleSource()//
/**
* Provides the builder the opportunity to supply additional style source.
* Multiple styles should be separated using logical OR operators, but should not begin or end with such operators.
* These styles should be formatted by calling getStyleSource(String).
* @param data The component whose additional (beyond what is auto generated) style source is required.
* @return The source for any additional unlisted styles, or null if none exists.
*/
protected String getAdditionalStyleSource(IComponentData data) {
return null;
}//getAdditionalStyleSource()//
/**
* Gets the style map for the component.
* @return The map of control specific component styles by the builder style.
*/
public abstract IHashMap getStyleMap();
/**
* Gets the link map for the component.
* @return The map of control specific component link-target identifiers by the link-target name (in the cml file).
*/
public abstract IHashMap getLinkMap();
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getLinkTargetIdentifier(java.lang.String)
*/
public String getLinkTargetIdentifier(String linkTargetName) {
return (String) getLinkMap().get(linkTargetName);
}//getLinkTargetIdentifier()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.IComponentData)
*/
public abstract void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData);
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.IComponentData, java.lang.String)
*/
public abstract void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String variableName);
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public abstract String getComponentClassName();
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition2.ComponentData)
*/
public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData componentData) {
//Builders that can be primary view components must provide an implementation.//
}//buildConstructors()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getPrimaryInitializationMethodName()
*/
public String getPrimaryInitializationMethodName() {
return "internalViewInitialize";
}//getPrimaryInitializationMethodName()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#shouldPack(com.foundation.view.definition.ComponentData)
*/
public boolean shouldPack(IComponentData componentData) {
return false;
}//shouldPack()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#updateComponent(com.foundation.view.definition.IViewModel, com.foundation.util.xml.INode)
*/
public boolean updateComponent(IViewModel viewModel, INode node) {
return false;
}//updateComponent()//
}//AbstractBuilder//

View File

@@ -0,0 +1,107 @@
/*
* 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.util.xml.INode;
import com.foundation.view.builder.IBuilder;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IAssociationGroupPart;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.definition.IViewModel;
public abstract class AbstractLayoutBuilder implements IBuilder {
/**
* AbstractLayoutBuilder constructor.
*/
public AbstractLayoutBuilder() {
super();
}//AbstractLayoutBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendComponentConstructorParameters(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String, java.lang.String)
*/
public void appendComponentConstructorParameters(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String parentVariable, String controlIdentifier) {
}//appendComponentConstructorParameters()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendComponentConstructorParameters(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public void appendComponentConstructorParameters(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String parentVariable) {
}//appendComponentConstructorParameters()//
/* (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 componentData, String variableName) {
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData)
*/
public abstract void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData);
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition.ComponentData)
*/
public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData componentData) {
}//buildConstructors()//
/* (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 void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String variableName) {
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getLinkTargetIdentifier(java.lang.String)
*/
public String getLinkTargetIdentifier(String linkTargetName) {
return null;
}//getLinkTargetIdentifier()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public abstract String getComponentClassName();
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getPrimaryInitializationMethodName()
*/
public String getPrimaryInitializationMethodName() {
return ""; //Not called.//
}//getPrimaryInitializationMethodName()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#shouldPack(com.foundation.view.definition.ComponentData)
*/
public boolean shouldPack(IComponentData componentData) {
return false;
}//shouldPack()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#updateComponent(com.foundation.view.definition.IViewModel, com.foundation.util.xml.INode)
*/
public boolean updateComponent(IViewModel viewModel, INode node) {
return false;
}//updateComponent()//
/**
* Appends association source to the view source code.
* @param viewBuilder The view builder managing the building of the view source.
* @param buffer The buffer for the outputed source code.
* @param data The component data for the component defining the association.
* @param associationFunction The function name for the association as defined in the cml file for the view control.
* @param variableName The variable name that defines the setter for the association object.
* @param setter The name of the setter method that sets the association object.
* @param identifier The identifier part used to generate identifiers for the association. This should look something like 'ASSOCIATION_FONT'.
* @param accessType One of the access types defined by IViewSourceBuilder.
* @see IViewSourceBuilder.ACCESS_TYPE_GET_ONLY
* @see IViewSourceBuilder.ACCESS_TYPE_BOTH
*/
protected void appendAssociation(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String associationFunction, String variableName, String setter, String identifier, byte accessType) {
IAssociationGroupPart association = data.getAssociations(associationFunction);
if(association != null) {
buffer.append("\t");
buffer.append(variableName);
buffer.append(".");
buffer.append(setter);
buffer.append("(");
viewBuilder.appendAssociation(data, buffer, variableName, association, identifier, accessType);
buffer.append(");\r\n");
}//if//
}//appendAssociation()//
}//AbstractLayoutBuilder//

View File

@@ -0,0 +1,240 @@
/*
* 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;
import com.common.util.*;
import com.foundation.view.JefImage;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
import com.foundation.view.resource.ResourceReference;
public class ButtonBuilder extends ComponentBuilder {
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 = "auto-synchronize-selection";
protected static final String PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY = "auto-synchronize-selection-delay";
protected static final String PROPERTY_SELECTION_DATA = "selection-data";
protected static final String PROPERTY_AUTO_VALIDATE = "auto-validate";
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 String LINK_SELECTION = "selection";
private static final String LINK_TARGET_SELECTION = "selection";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
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");
linkMap.put(LINK_TARGET_SELECTION, "LINK_TARGET_SELECTION");
}//static//
/**
* ButtonBuilder constructor.
*/
public ButtonBuilder() {
}//ButtonBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String typeName = data.getComponentType().getName();
String variableName = viewBuilder.getComponentAttributeName(data);
ISet styles = data.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, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
appendInitializationBody(viewBuilder, buffer, data, 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);
Boolean autoValidate = (Boolean) data.getPropertyValue(PROPERTY_AUTO_VALIDATE);
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
Long autoSynchronizeSelectionDelay = (Long) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY);
String selectionData = (String) data.getPropertyValue(PROPERTY_SELECTION_DATA);
IMethodPart selectionMethod = data.getMethod(METHOD_SELECTION);
boolean isPush = typeName.equals("button");
boolean isToggle = typeName.equals("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//
if(isToggle && selectionData != null && data.getStyles().containsValue(STYLE_RADIO)) {
buffer.append("\t" + variableName + ".setSelectionData(" + selectionData + ");\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 && autoSynchronizeSelection != null) {
buffer.append("\t" + variableName + ".setAutoSynchronizeSelection(" + autoSynchronizeSelection + ");\r\n");
}//if//
if(autoValidate != null) {
buffer.append("\t" + variableName + ".setAutoValidate(" + autoValidate + ");\r\n");
}//if//
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.builder.IBuilder#appendLinks(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.IComponentData, java.lang.String)
*/
public void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
IList selectionLinks = data.getLinks(LINK_SELECTION);
if(selectionLinks != null) {
for(int index = 0; index < selectionLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) selectionLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addSelectionLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
super.appendLinks(viewBuilder, buffer, data, variableName);
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Button";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//ButtonBuilder//

View File

@@ -0,0 +1,53 @@
/*
* 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//

View File

@@ -0,0 +1,26 @@
package com.foundation.view.swt.builder;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public class CenterLayoutBuilder extends AbstractLayoutBuilder {
/**
* CenterLayoutBuilder constructor.
*/
public CenterLayoutBuilder() {
}//CenterLayoutBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractLayoutBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.IComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData) {
buffer.append("\t" + getComponentClassName() + " layout = new " + getComponentClassName() + "(" + viewBuilder.getComponentAttributeName(componentData.getParent()) + ");\r\n");
buffer.append("\t\r\n");
buffer.append("\t" + viewBuilder.getComponentAttributeName(componentData.getParent()) + ".setLayout(layout);\r\n");
}//appendInitializationHead()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractLayoutBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.CenterLayout";
}//getComponentClassName()//
}//CenterLayoutBuilder//

View File

@@ -0,0 +1,210 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.view.JefColor;
import com.foundation.view.JefFont;
import com.foundation.view.definition.*;
import com.foundation.view.builder.*;
public abstract class CollectionComponentBuilder extends ScrollableComponentBuilder {
protected static final int HIDDEN_DATA_TYPE_CODE_BOOLEAN = 0;
protected static final int HIDDEN_DATA_TYPE_CODE_INTEGER = 1;
protected static final int HIDDEN_DATA_TYPE_CODE_STRING = 2;
protected static final int HIDDEN_DATA_TYPE_CODE_COLOR = 3;
protected static final int HIDDEN_DATA_TYPE_CODE_FONT = 4;
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_AUTO_VALIDATE = "auto-validate";
protected static final String PROPERTY_DATA = "data";
protected static final String ASSOCIATION_COLLECTION = "collection";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String ASSOCIATION_DATA = "data";
protected static final String METHOD_DOUBLE_CLICK = "double-click";
protected static final String COMPONENT_HIDDEN_DATA = "hidden-data";
protected static final String LINK_SELECTION = "selection";
protected static final IHashMap styleMap = new LiteHashMap(ScrollableComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ScrollableComponentBuilder.linkMap);
private int hiddenDataAssociationIndex = 0;
/**
* CollectionComponentBuilder constructor.
*/
public CollectionComponentBuilder() {
super();
}//CollectionComponentBuilder()//
/**
* Determines whether the control allows the user to select more than one value.
* @param The component data representing the control.
* @return Whether the user may make more than one selection for the control.
*/
public abstract boolean allowMultiSelection(IComponentData data);
/* (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) {
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
Long autoSynchronizeSelectionDelay = (Long) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY);
Boolean autoValidate = (Boolean) data.getPropertyValue(PROPERTY_AUTO_VALIDATE);
IMethodPart doubleClickMethod = data.getMethod(METHOD_DOUBLE_CLICK);
IList hiddenData = new LiteList(10, 20);
data.getComponents(hiddenData, COMPONENT_HIDDEN_DATA, true);
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//
if(autoValidate != null) {
buffer.append("\t" + variableName + ".setAutoValidate(" + autoValidate + ");\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", allowMultiSelection(data) ? IViewSourceBuilder.ACCESS_TYPE_GET_ONLY : IViewSourceBuilder.ACCESS_TYPE_BOTH);
if((doubleClickMethod != null) && (doubleClickMethod.getName() != null)) {
String associationIdentifier = viewBuilder.addMethodAssociationIdentifier(data.getDocumentElement(), variableName, METHOD_DOUBLE_CLICK);
viewBuilder.addDirectMethodHandler(data, associationIdentifier, doubleClickMethod);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".setDoubleClickMethod(");
viewBuilder.appendMethodAssociation(buffer, variableName, doubleClickMethod, associationIdentifier);
buffer.append(");\r\n");
}//if//
//Add the data for all the columns.//
for(int hiddenDataIndex = 0; hiddenDataIndex < hiddenData.getSize(); hiddenDataIndex++) {
appendHiddenDataBody(viewBuilder, buffer, (IComponentData) hiddenData.get(hiddenDataIndex), variableName, hiddenDataIndex);
}//for//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/**
* Appends the hidden data 'column' code for one hidden data part.
* @param buffer The buffer to write the java source to.
* @param component The hidden data's component which contains all the info necessary to build the source for the hidden data.
* @param variableName The hidden data's assigned variable name. This is a local variable and not an object level attribute.
* @param hiddenDataIndex The index of the hidden data component within this collection component.
*/
protected void appendHiddenDataBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData component, String variableName, int hiddenDataIndex) {
String componentTypeName = component.getComponentType().getName();
Object dataProperty = component.getPropertyValue(PROPERTY_DATA);
if(componentTypeName.equals("hidden-boolean")) {
appendHiddenDataBody(viewBuilder, buffer, component, variableName, "Boolean", dataProperty != null ? ((Boolean) dataProperty).booleanValue() ? "Boolean.TRUE" : "Boolean.FALSE" : null, hiddenDataIndex);
}//if//
else if(componentTypeName.equals("hidden-integer")) {
appendHiddenDataBody(viewBuilder, buffer, component, variableName, "Integer", dataProperty != null ? ((Integer) dataProperty).toString() : null, hiddenDataIndex);
}//else if//
else if(componentTypeName.equals("hidden-string")) {
appendHiddenDataBody(viewBuilder, buffer, component, variableName, "String", dataProperty != null ? "\"" + ((String) dataProperty) + "\"" : null, hiddenDataIndex);
}//else if//
else if(componentTypeName.equals("hidden-color")) {
appendHiddenDataBody(viewBuilder, buffer, component, variableName, "Color", dataProperty != null ? "new " + JefColor.class.getName() + "(\"" + dataProperty.toString() + "\")" : null, hiddenDataIndex);
}//else if//
else if(componentTypeName.equals("hidden-font")) {
appendHiddenDataBody(viewBuilder, buffer, component, variableName, "Font", dataProperty != null ? "new " + JefFont.class.getName() + "(\"" + JefFont.getJefFontsString((JefFont[]) dataProperty) + "\")" : null, hiddenDataIndex);
}//else if//
}//appendHiddenDataBody()//
/**
* Appends the hidden data 'column' code for one hidden data part.
* @param buffer The buffer to write the java source to.
* @param component The hidden data's component which contains all the info necessary to build the source for the hidden data.
* @param variableName The hidden data's assigned variable name. This is a local variable and not an object level attribute.
* @param typeName The name of the hidden data's data type as used by the addHiddenXXX() method defined by the collection component and the IHiddenXXX interface that the method returns.
* @param defaultValueCode The code whose result is passed to the setData(..) method, or null if no data property was specified.
* @param hiddenDataIndex The index of the hidden data component within this collection component.
*/
protected void appendHiddenDataBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData component, String variableName, String typeName, String defaultValueCode, int hiddenDataIndex) {
String hiddenDataVariableName = variableName + "HiddenDataPart" + hiddenDataIndex;
IAssociationGroupPart dataAssociations = component.getAssociations(ASSOCIATION_DATA);
viewBuilder.addAttribute(getComponentClassName() + ".IHidden" + typeName, hiddenDataVariableName);
buffer.append("\t");
//buffer.append(getComponentClassName() + ".IHidden" + typeName);
//buffer.append(" ");
buffer.append(hiddenDataVariableName);
buffer.append(" = ");
buffer.append(variableName);
buffer.append(".addHidden" + typeName + "();\r\n");
if(defaultValueCode != null) {
buffer.append("\t" + hiddenDataVariableName + ".setData(" + defaultValueCode + ");\r\n");
}//if//
if(dataAssociations != null) {
buffer.append("\t");
buffer.append(hiddenDataVariableName);
buffer.append(".setDataAssociation(");
viewBuilder.appendAssociation(component, buffer, variableName, dataAssociations, "ASSOCIATION_DATA_" + hiddenDataAssociationIndex++, IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
buffer.append(");\r\n");
}//if//
}//appendHiddenDataBody()//
/* (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 void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
IList selectionLinks = data.getLinks(LINK_SELECTION);
IList hiddenData = new LiteList(10, 20);
data.getComponents(hiddenData, COMPONENT_HIDDEN_DATA, true);
if(selectionLinks != null) {
for(int index = 0; index < selectionLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) selectionLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addSelectionLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
//Add the data for all the columns.//
for(int hiddenDataIndex = 0; hiddenDataIndex < hiddenData.getSize(); hiddenDataIndex++) {
IComponentData component = (IComponentData) hiddenData.get(hiddenDataIndex);
String hiddenDataVariableName = variableName + "HiddenDataPart" + hiddenDataIndex;
selectionLinks = component.getLinks(LINK_SELECTION);
if(selectionLinks != null) {
for(int index = 0; index < selectionLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) selectionLinks.get(index);
buffer.append("\t");
buffer.append(hiddenDataVariableName);
buffer.append(".addSelectionLink(");
viewBuilder.appendLink(component, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
}//for//
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//CollectionComponentBuilder//

View File

@@ -0,0 +1,93 @@
/*
* Copyright (c) 2003,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;
import com.common.util.*;
import com.foundation.view.swt.*;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.builder.*;
public class ComboBuilder extends CollectionComponentBuilder {
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_TEXT_LIMIT = "textLimit";
protected static final String ASSOCIATION_ITEM_TEXT = "item-text";
protected static final String ASSOCIATION_ITEM_IMAGE = "item-image";
protected static final IHashMap styleMap = new LiteHashMap(CollectionComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(CollectionComponentBuilder.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//
/**
* ComboBoxBuilder constructor.
*/
public ComboBuilder() {
}//ComboBoxBuilder()//
/* (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) {
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.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 textLimit = (String) data.getPropertyValue(PROPERTY_TEXT_LIMIT);
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);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ITEM_IMAGE, variableName, "setItemImageAssociation", "ASSOCIATION_ITEM_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.ComboBox";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.CollectionComponentBuilder#allowMultiSelection(com.foundation.view.definition.ComponentData)
*/
public boolean allowMultiSelection(IComponentData data) {
return false;
}//allowMultiSelection()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//ComboBuilder//

View File

@@ -0,0 +1,337 @@
/*
* Copyright (c) 2003,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 java.text.NumberFormat;
import com.common.debug.Debug;
import com.common.util.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
import com.foundation.view.resource.ResourceReference;
import com.foundation.view.JefColor;
import com.foundation.view.JefFont;
import com.foundation.view.JefGradient;
import com.foundation.view.JefImage;
public abstract class ComponentBuilder 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_X = "x";
protected static final String PROPERTY_Y = "y";
protected static final String PROPERTY_WIDTH = "width";
protected static final String PROPERTY_HEIGHT = "height";
protected static final String PROPERTY_IS_VISIBLE = "is-visible";
protected static final String PROPERTY_IS_ENABLED = "is-enabled";
protected static final String PROPERTY_TAB_ORDER = "tab-order";
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_BACKGROUND_IMAGE = "background-image";
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_CONTAINER_TITLE = "container-title";
protected static final String PROPERTY_CONTAINER_IMAGE = "container-image";
protected static final String PROPERTY_CHANGE_TEXT = "change-text";
protected static final String PROPERTY_CHANGE_IMAGE = "change-image";
protected static final String PROPERTY_UPDATE_TEXT = "update-text";
protected static final String PROPERTY_UPDATE_IMAGE = "update-image";
protected static final String PROPERTY_UPDATE_TIMEOUT = "update-timeout";
protected static final String ASSOCIATION_IS_VISIBLE = "is-visible";
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_BACKGROUND_IMAGE = "background-image";
protected static final String ASSOCIATION_FOREGROUND_COLOR = "foreground-color";
protected static final String ASSOCIATION_FONT = "font";
protected static final String ASSOCIATION_CONTAINER_TITLE = "container-title";
protected static final String ASSOCIATION_CONTAINER_IMAGE = "container-image";
protected static final String EVENT_GAIN_FOCUS = "gain-focus";
protected static final String COMPONENT_MENU_FLOATING = "menu-floating";
private static final String LINK_TARGET_IS_VISIBLE = "is-visible";
private static final String LINK_TARGET_IS_ENABLED = "is-enabled";
private static final String LINK_TARGET_GAIN_FOCUS = "gain-focus";
private static final String LINK_TARGET_TOOL_TIP_TEXT = "tool-tip-text";
private static final String LINK_TARGET_BACKGROUND_COLOR = "background-color";
private static final String LINK_TARGET_FOREGROUND_COLOR = "foreground-color";
private static final String LINK_TARGET_FONT = "font";
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");
linkMap.put(LINK_TARGET_IS_VISIBLE, "LINK_TARGET_IS_VISIBLE");
linkMap.put(LINK_TARGET_IS_ENABLED, "LINK_TARGET_IS_ENABLED");
linkMap.put(LINK_TARGET_GAIN_FOCUS, "LINK_TARGET_GAIN_FOCUS");
linkMap.put(LINK_TARGET_TOOL_TIP_TEXT, "LINK_TARGET_TOOL_TIP_TEXT");
linkMap.put(LINK_TARGET_BACKGROUND_COLOR, "LINK_TARGET_BACKGROUND_COLOR");
linkMap.put(LINK_TARGET_FOREGROUND_COLOR, "LINK_TARGET_FOREGROUND_COLOR");
linkMap.put(LINK_TARGET_FONT, "LINK_TARGET_FONT");
}//static//
/**
* ComponentBuilder constructor.
*/
public ComponentBuilder() {
super();
}//ComponentBuilder()//
/* (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) {
Integer x = (Integer) data.getPropertyValue(PROPERTY_X);
Integer y = (Integer) data.getPropertyValue(PROPERTY_Y);
Integer width = (Integer) data.getPropertyValue(PROPERTY_WIDTH);
Integer height = (Integer) data.getPropertyValue(PROPERTY_HEIGHT);
Object isVisible = (Object) data.getPropertyValue(PROPERTY_IS_VISIBLE);
Object isEnabled = (Object) data.getPropertyValue(PROPERTY_IS_ENABLED);
Object toolTipText = (Object) data.getPropertyValue(PROPERTY_TOOL_TIP_TEXT);
Object backgroundColor = (Object) data.getPropertyValue(PROPERTY_BACKGROUND_COLOR);
Object backgroundImage = (Object) data.getPropertyValue(PROPERTY_BACKGROUND_IMAGE);
Object foregroundColor = (Object) data.getPropertyValue(PROPERTY_FOREGROUND_COLOR);
Object font = (Object) data.getPropertyValue(PROPERTY_FONT);
Integer decimalScale = (Integer) data.getPropertyValue(PROPERTY_DECIMAL_SCALE);
Object title = (Object) data.getPropertyValue(PROPERTY_CONTAINER_TITLE);
Object image = (Object) data.getPropertyValue(PROPERTY_CONTAINER_IMAGE);
Object changeText = (Object) data.getPropertyValue(PROPERTY_CHANGE_TEXT);
Object changeImage = (Object) data.getPropertyValue(PROPERTY_CHANGE_IMAGE);
Object updateText = (Object) data.getPropertyValue(PROPERTY_UPDATE_TEXT);
Object updateImage = (Object) data.getPropertyValue(PROPERTY_UPDATE_IMAGE);
Object updateTimeout = (Object) data.getPropertyValue(PROPERTY_UPDATE_TIMEOUT);
IList gainFocusEvents = data.getEvents(EVENT_GAIN_FOCUS);
IComponentData floatingMenu = data.getComponent(COMPONENT_MENU_FLOATING, true);
IList keys = data.getKeys();
if((width != null) && (height != null)) {
buffer.append("\t" + variableName + ".setSize(" + width + ", " + height + ");\r\n");
}//if//
if((x != null) && (y != null)) {
buffer.append("\t" + variableName + ".setLocation(" + x + ", " + y + ");\r\n");
}//if//
if(isVisible != null) {
if(isVisible instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultIsVisible(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) isVisible).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultIsVisible(" + ((Boolean) isVisible).booleanValue() + ");\r\n");
}//else//
}//if//
if(isEnabled != null) {
if(isEnabled instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultIsEnabled(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) isEnabled).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultIsEnabled(" + ((Boolean) isEnabled).booleanValue() + ");\r\n");
}//else//
}//if//
if(toolTipText != null) {
if(toolTipText instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultToolTipText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) toolTipText).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultToolTipText(\"" + toolTipText + "\");\r\n");
}//else//
}//if//
if(backgroundColor != null) {
if(backgroundColor instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultBackgroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) backgroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultBackgroundColor(new " + JefGradient.class.getName() + "(\"" + backgroundColor + "\"));\r\n");
}//else//
}//if//
if(backgroundImage != null) {
if(backgroundImage instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultBackgroundImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) backgroundImage).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultBackgroundImage(new " + JefImage.class.getName() + "(\"" + backgroundImage + "\"));\r\n");
}//else//
}//if//
if(foregroundColor != null) {
if(foregroundColor instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultForegroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) foregroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultForegroundColor(new " + JefColor.class.getName() + "(\"" + foregroundColor + "\"));\r\n");
}//else//
}//if//
if(font != null) {
if(font instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultFont(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) font).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultFont(" + JefFont.class.getName() + ".getJefFonts(\"" + JefFont.getJefFontsString((JefFont[]) font) + "\"));\r\n");
}//else//
}//if//
if(changeText != null) {
if(changeText instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultChangeText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) changeText).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultChangeText(\"" + changeText + "\");\r\n");
}//else//
}//if//
if(changeImage != null) {
if(changeImage instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultChangeImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) changeImage).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultChangeImage(new " + JefImage.class.getName() + "(\"" + changeImage + "\"));\r\n");
}//else//
}//if//
if(updateText != null) {
if(updateText instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultUpdateText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) updateText).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultUpdateText(\"" + updateText + "\");\r\n");
}//else//
}//if//
if(updateImage != null) {
if(updateImage instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultUpdateImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) updateImage).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultUpdateImage(new " + JefImage.class.getName() + "(\"" + updateImage + "\"));\r\n");
}//else//
}//if//
if(updateTimeout != null) {
if(updateTimeout instanceof ResourceReference) {
//Not supported yet.//
// buffer.append("\t" + variableName + ".setDefaultUpdateTimeout(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) updateTimeout).getResourceUrl() + "\"));\r\n");
}//if//
else {
int timeout = 10000;
try {
timeout = updateTimeout instanceof Number ? ((Number) updateTimeout).intValue() : NumberFormat.getIntegerInstance().parse(updateTimeout.toString()).intValue();
}//try//
catch(Throwable e) {
Debug.log(e);
}//catch//
buffer.append("\t" + variableName + ".setDefaultUpdateTimeout(new Integer(" + timeout + "));\r\n");
}//else//
}//if//
if(decimalScale != null) {
buffer.append("\t" + variableName + ".setDecimalScale(new Integer(" + decimalScale + "));\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IS_VISIBLE, variableName, "setIsVisibleAssociation", "ASSOCIATION_IS_VISIBLE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IS_ENABLED, variableName, "setIsEnabledAssociation", "ASSOCIATION_IS_ENABLED", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_TOOL_TIP_TEXT, variableName, "setToolTipTextAssociation", "ASSOCIATION_TOOL_TIP_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_BACKGROUND_COLOR, variableName, "setBackgroundColorAssociation", "ASSOCIATION_BACKGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_BACKGROUND_IMAGE, variableName, "setBackgroundImageAssociation", "ASSOCIATION_BACKGROUND_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_FOREGROUND_COLOR, variableName, "setForegroundColorAssociation", "ASSOCIATION_FOREGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_FONT, variableName, "setFontAssociation", "ASSOCIATION_FONT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_CONTAINER_TITLE, variableName, "setContainerTitleAssociation", "ASSOCIATION_CONTAINER_TITLE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_CONTAINER_IMAGE, variableName, "setContainerImageAssociation", "ASSOCIATION_CONTAINER_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
if(title != null) {
if(title instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultContainerTitle(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) title).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultContainerTitle(\"" + title + "\");\r\n");
}//else//
}//if//
if(image != null) {
if(image instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultContainerImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) image).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultContainerImage(new " + JefImage.class.getName() + "(\"" + image + "\"));\r\n");
}//else//
}//if//
if(gainFocusEvents != null) {
for(int index = 0; index < gainFocusEvents.getSize(); index++) {
IEventPart eventPart = (IEventPart) gainFocusEvents.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addGainFocusEventAssociation(");
viewBuilder.appendEventAssociation(buffer, variableName, eventPart);
buffer.append(");\r\n");
}//for//
}//if//
if(keys != null) {
for(int index = 0; index < keys.getSize(); index++) {
IKeyPart keyPart = (IKeyPart) keys.get(index);
String identifier = viewBuilder.addKeyBindingIdentifier(keyPart, variableName, null);
viewBuilder.addDirectKeyHandler(data, identifier, keyPart);
buffer.append('\t');
buffer.append(variableName);
buffer.append(".addKeyBinding(");
viewBuilder.appendKeyBinding(buffer, variableName, keyPart, identifier);
buffer.append(");\r\n");
}//for//
}//if//
if(floatingMenu != null) {
String initializeMethodName = viewBuilder.addInitializeMenuMethod(data, 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 void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#shouldPack(com.foundation.view.definition.ComponentData)
*/
public boolean shouldPack(IComponentData componentData) {
Integer width = (Integer) componentData.getPropertyValue(PROPERTY_WIDTH);
Integer height = (Integer) componentData.getPropertyValue(PROPERTY_HEIGHT);
return (width == null) || (height == null);
}//shouldPack()//
}//ComponentBuilder//

View File

@@ -0,0 +1,143 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.common.comparison.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public abstract class ContainerBuilder extends ScrollableComponentBuilder {
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_DEFAULT_BUTTON = "default-button";
protected static final String PROPERTY_INHERIT_BACKGROUND = "inherit-background";
protected static final String PROPERTY_PACKAGE = "package";
protected static final String COMPONENT_COMPONENT = "component";
protected static final String COMPONENT_LAYOUT = "layout";
protected static final IHashMap styleMap = new LiteHashMap(ScrollableComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ScrollableComponentBuilder.linkMap);
static {
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//
/**
* ContainerBuilder constructor.
*/
public ContainerBuilder() {
super();
}//ContainerBuilder()//
/* (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 defaultButtonName = (String) data.getPropertyValue(PROPERTY_DEFAULT_BUTTON);
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" : "INHERIT_NONE") + ");\r\n");
}//if//
//Search for all sub-parts that extend the component type.//
data.getComponents(components, COMPONENT_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);
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 " + LiteList.class.getName() + "(new Object[] {");
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);
if(defaultButtonName != null) {
IComponentData defaultButtonComponent = data.searchForComponent(defaultButtonName, null, IComponentData.SEARCH_FLAG_UP);
if(defaultButtonComponent != null) {
buffer.append('\t');
buffer.append(variableName);
buffer.append(".setDefaultButton(");
buffer.append(viewBuilder.getComponentAttributeName(defaultButtonComponent));
buffer.append(");\r\n");
}//if//
}//if//
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//ContainerBuilder//

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 2006,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;
import com.common.util.*;
import com.foundation.view.swt.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class CoolBarBuilder extends ComponentBuilder {
protected static final String STYLE_FLAT = "flat";
protected static final String COMPONENT_COOL_ITEM = "cool-item";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
static {
styleMap.put(STYLE_FLAT, "STYLE_FLAT");
}//static//
/**
* CoolBarBuilder constructor.
*/
public CoolBarBuilder() {
super();
}//CoolBarBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
IList components = new LiteList(10, 20);
IIterator itemIterator = null;
//Search for all sub-parts that extend the cool-item type.//
data.getComponents(components, COMPONENT_COOL_ITEM, true);
itemIterator = components.iterator();
//Call the initialize method on the contained cool items.//
while(itemIterator.hasNext()) {
IComponentData next = (IComponentData) itemIterator.next();
String initializeMethodName = viewBuilder.addInitializeComponentMethod(next);
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
}//while//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.CoolBar";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//TabPanelBuilder//

View File

@@ -0,0 +1,150 @@
/*
* Copyright (c) 2006,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;
import com.common.util.*;
import com.foundation.view.swt.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class CoolItemBuilder extends AbstractBuilder {
protected static final String STYLE_DROP_DOWN = "drop down";
protected static final String PROPERTY_WIDTH = "width";
protected static final String PROPERTY_HEIGHT = "height";
protected static final String PROPERTY_MINIMUM_WIDTH = "minimum-width";
protected static final String PROPERTY_MINIMUM_HEIGHT = "minimum-height";
protected static final String PROPERTY_PREFERRED_WIDTH = "preferred-width";
protected static final String PROPERTY_PREFERRED_HEIGHT = "preferred-height";
protected static final String PROPERTY_IS_VISIBLE = "is-visible";
protected static final String ASSOCIATION_IS_VISIBLE = "is-visible";
protected static final String COMPONENT_COMPONENT = "component";
private static final String LINK_TARGET_IS_VISIBLE = "isVisible";
protected static final IHashMap styleMap = new LiteHashMap(AbstractBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(AbstractBuilder.linkMap);
static {
styleMap.put(STYLE_DROP_DOWN, "STYLE_DROP_DOWN");
linkMap.put(LINK_TARGET_IS_VISIBLE, "LINK_TARGET_IS_VISIBLE");
}//static//
/**
* CoolItemBuilder constructor.
*/
public CoolItemBuilder() {
super();
}//CoolItemBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName().replace('$', '.') + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
Integer width = (Integer) data.getPropertyValue(PROPERTY_WIDTH);
Integer height = (Integer) data.getPropertyValue(PROPERTY_HEIGHT);
Integer minimumWidth = (Integer) data.getPropertyValue(PROPERTY_MINIMUM_WIDTH);
Integer minimumHeight = (Integer) data.getPropertyValue(PROPERTY_MINIMUM_HEIGHT);
Integer preferredWidth = (Integer) data.getPropertyValue(PROPERTY_PREFERRED_WIDTH);
Integer preferredHeight = (Integer) data.getPropertyValue(PROPERTY_PREFERRED_HEIGHT);
Boolean isVisible = (Boolean) data.getPropertyValue(PROPERTY_IS_VISIBLE);
IComponentData component = data.getComponent(COMPONENT_COMPONENT, true);
if(component != null) {
String initializeMethodName = viewBuilder.addInitializeComponentMethod(component);
//Initialize the control.//
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(viewBuilder.getComponentAttributeName(data.getParent()));
buffer.append(");\r\n");
//Pass the control to the item.//
buffer.append('\t');
buffer.append(variableName);
buffer.append(".setControl(");
buffer.append(viewBuilder.getComponentAttributeName(component));
buffer.append(");\r\n");
}//if//
else {
//Error: Must have exactly one component in the page.//
throw new ViewBuilderException("Must have only one component part of a cool item.", data.getDocumentElement());
}//else//
if((width != null) && (height != null)) {
buffer.append("\t" + variableName + ".setSize(" + width + ", " + height + ");\r\n");
}//if//
if((minimumWidth != null) && (minimumHeight != null)) {
buffer.append("\t" + variableName + ".setMinimumSize(" + minimumWidth + ", " + minimumHeight + ");\r\n");
}//if//
if((preferredHeight != null) && (preferredWidth != null)) {
buffer.append("\t" + variableName + ".setPreferredSize(" + preferredWidth + ", " + preferredHeight + ");\r\n");
}//if//
if((isVisible != null) && (!isVisible.booleanValue())) {
buffer.append("\t" + variableName + ".setIsVisible(false);\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IS_VISIBLE, variableName, "setIsVisibleAssociation", "ASSOCIATION_IS_VISIBLE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
}//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 void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
/* TODO: Are there any links associated with the cool item? Perhaps visibility?
IList selectionLinks = data.getLinks(LINK_SELECTION);
if(selectionLinks != null) {
for(int index = 0; index < selectionLinks.getSize(); index++) {
LinkPart part = (LinkPart) selectionLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addSelectionLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
*/
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.CoolBar.CoolItem";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//TabPanelBuilder//

View File

@@ -0,0 +1,109 @@
/*
* 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;
import com.common.util.*;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.definition.IMethodPart;
import com.foundation.view.builder.*;
public class DateTimeBuilder extends ComponentBuilder {
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 STYLE_DROP_DOWN = "drop down";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String METHOD_DOUBLE_CLICK = "double-click";
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(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
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");
styleMap.put(STYLE_DROP_DOWN, "STYLE_DROP_DOWN");
}//static//
/**
* DateTimeBuilder constructor.
*/
public DateTimeBuilder() {
super();
}//DateTimeBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, 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.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) {
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
Long autoSynchronizeSelectionDelay = (Long) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY);
IMethodPart doubleClickMethod = data.getMethod(METHOD_DOUBLE_CLICK);
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);
if((doubleClickMethod != null) && (doubleClickMethod.getName() != null)) {
String associationIdentifier = viewBuilder.addMethodAssociationIdentifier(data.getDocumentElement(), variableName, METHOD_DOUBLE_CLICK);
viewBuilder.addDirectMethodHandler(data, associationIdentifier, doubleClickMethod);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".setDoubleClickMethod(");
viewBuilder.appendMethodAssociation(buffer, variableName, doubleClickMethod, associationIdentifier);
buffer.append(");\r\n");
}//if//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.DateTime";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//DateTimeBuilder//

View File

@@ -0,0 +1,98 @@
/*
* Copyright (c) 2008,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.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.controller.ViewController;
import com.foundation.view.IAbstractContainer;
import com.foundation.view.IView;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public class DynamicContainerBuilder extends ContainerBuilder {
protected static final String ASSOCIATION_CONTROLLERS = "controllers";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
/**
* DynamicContainerBuilder constructor.
*/
public DynamicContainerBuilder() {
}//DynamicContainerBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.IComponentData)
*/
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.ContainerBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.IComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_CONTROLLERS, variableName, "setControllersAssociation", "ASSOCIATION_CONTROLLERS", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition.IComponentData)
*/
public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData data) {
String componentName = viewBuilder.addComponentNameIdentifier(data.getDocumentElement(), viewBuilder.getComponentName(data));
constructor.append("/**\r\n");
constructor.append(" * ");
constructor.append(className);
constructor.append(" constructor.\r\n");
constructor.append(" * @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.\r\n");
constructor.append(" * @param parentComponent The non-null parent view component which this frame will be contained in.\r\n");
constructor.append(" */\r\n");
constructor.append("public ");
constructor.append(className);
constructor.append("(");
constructor.append(ViewController.class.getName());
constructor.append(" controller, ");
constructor.append(IView.class.getName());
constructor.append(" parentComponent) {\r\n");
constructor.append("\tsuper((");
constructor.append(IAbstractContainer.class.getName());
constructor.append(") parentComponent, ");
appendComponentConstructorParameters(viewBuilder, constructor, data, null, componentName);
constructor.append(");\r\n\r\n");
constructor.append("\tsetController(controller);\r\n");
constructor.append("}//" + className + "()//\r\n");
}//buildConstructors()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.ContainerDynamic";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//DynamicContainerBuilder//

View File

@@ -0,0 +1,268 @@
/*
* Copyright (c) 2008,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.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.common.util.LiteList;
import com.foundation.view.builder.BuildFailedException;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.builder.ViewBuilderException;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.definition.IMethodPart;
import com.foundation.view.definition.Message;
public class DynamicMenuBuilder extends AbstractBuilder {
protected static final String PROPERTY_NAME = "name";
protected static final String PROPERTY_CLASS = "class";
protected static final String PROPERTY_SYNCHRONOUS_SELECTION = "synchronous-selection";
protected static final String ASSOCIATION_COLLECTION = "collection";
protected static final String ASSOCIATION_TEXT = "text";
protected static final String ASSOCIATION_IMAGE = "image";
protected static final String ASSOCIATION_IS_VISIBLE = "is-visible";
protected static final String ASSOCIATION_IS_ENABLED = "is-enabled";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String METHOD_SELECTION = "selection";
/** The base type for the different menu types. */
protected static final String COMPONENT_DYNAMIC_ABSTRACT_MENU = "dynamic-abstract-menu";
private static final IHashMap styleMap = new LiteHashMap(AbstractBuilder.styleMap);
private static final IHashMap linkMap = new LiteHashMap(AbstractBuilder.linkMap);
/**
* DynamicMenuBuilder constructor.
*/
public DynamicMenuBuilder() {
}//DynamicMenuBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.IComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData) {
String variableName = viewBuilder.getComponentAttributeName(componentData);
String parentVariableName = viewBuilder.getComponentAttributeName(componentData.getParent());
viewBuilder.addComponentAttribute(componentData, this);
buffer.append("//begin dmb//\r\n");
buffer.append("\t");
buffer.append(variableName);
buffer.append(" = new ");
buffer.append(getComponentClassName());
buffer.append("(");
appendComponentConstructorParameters(viewBuilder, buffer, componentData, parentVariableName);
buffer.append(");\r\n");
buffer.append("\t\r\n");
appendInitializationBody(viewBuilder, buffer, componentData, variableName);
buffer.append("//end dmb//\r\n");
}//appendInitializationHead()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.IComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String variableName) {
LiteList components = new LiteList(10, 20);
componentData.getComponents(components, COMPONENT_DYNAMIC_ABSTRACT_MENU, true);
appendAssociation(viewBuilder, buffer, componentData, ASSOCIATION_COLLECTION, variableName, "setCollectionAssociation", "ASSOCIATION_COLLECTION", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
for(int index = 0; index < components.getSize(); index++) {
appendMenuComponent(viewBuilder, buffer, variableName, (IComponentData) components.get(index), index);
}//for//
}//appendInitializationBody()//
/**
* Appends the setFormat method to the view source.
* @param viewBuilder
* @param buffer
* @param variableName
* @param formatComponent The component metadata for the format.
*/
public void appendMenuComponent(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData menuComponent, int index) {
String menuComponentName = menuComponent.getComponentType().getName();
String temporaryVariableName = variableName + "Menu" + index;
String menuComponentTypeName = getMenuComponentTypeName(menuComponentName, menuComponent);
buffer.append('\t');
buffer.append(menuComponentTypeName);
buffer.append(' ');
buffer.append(temporaryVariableName);
buffer.append(" = (");
buffer.append(menuComponentTypeName);
buffer.append(") ");
buffer.append(variableName);
buffer.append(".createMenuDefinition(");
buffer.append(menuComponentTypeName);
buffer.append(".class);\r\n");
appendMenuComponentContent(viewBuilder, buffer, temporaryVariableName, menuComponent, menuComponentName, index);
}//appendMenuComponent()//
/**
* Gets the class name for the menu component class based on the given menu component name as defined in the cml file.
* @param menuComponentName The cml component name.
* @return The format class name.
*/
protected String getMenuComponentTypeName(String menuComponentName, IComponentData menuComponent) {
String result;
if(menuComponentName.equals("dynamic-cascade-menu")) {
result = getComponentClassName() + ".CascadeMenuDefinition";
}//if//
else if(menuComponentName.equals("dynamic-push-menu")) {
result = getComponentClassName() + ".PushMenuDefinition";
}//else if//
else if(menuComponentName.equals("dynamic-check-menu")) {
result = getComponentClassName() + ".CheckMenuDefinition";
}//else if//
else if(menuComponentName.equals("dynamic-radio-menu")) {
result = getComponentClassName() + ".RadioMenuDefinition";
}//else if//
else {
throw new ViewBuilderException("Unknown menu component type: " + menuComponentName, menuComponent.getDocumentElement());
}//else//
return result;
}//getMenuComponentTypeName()//
/**
* Appends the content for the menu component based on the menu component name.
* @param viewBuilder
* @param buffer
* @param variableName
* @param menuComponent
* @param menuComponentName
* @param isReadOnly
*/
protected void appendMenuComponentContent(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData menuComponent, String menuComponentName, int index) {
if(menuComponentName.equals("dynamic-cascade-menu")) {
appendCascadeMenuComponent(viewBuilder, buffer, variableName, menuComponent, index);
}//if//
else if(menuComponentName.equals("dynamic-push-menu")) {
appendPushMenuComponent(viewBuilder, buffer, variableName, menuComponent, index);
}//else if//
else if(menuComponentName.equals("dynamic-check-menu")) {
appendCheckMenuComponent(viewBuilder, buffer, variableName, menuComponent, index);
}//else if//
else if(menuComponentName.equals("dynamic-radio-menu")) {
appendRadioMenuComponent(viewBuilder, buffer, variableName, menuComponent, index);
}//else if//
}//appendMenuComponentContent()//
/**
* Appends the menu component to the source.
* @param viewBuilder
* @param buffer
* @param variableName
* @param menuComponent The component metadata for the menu.
*/
public void appendBaseMenuComponent(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData menuComponent, int index) {
String cls = (String) menuComponent.getPropertyValue(PROPERTY_CLASS);
//TODO: Can we verify it is a fully qualified class name that really exists?
if(cls != null) {
buffer.append("\t" + variableName + ".setType(" + cls + ".class);\r\n");
}//if//
else {
viewBuilder.getFeedbackStack().add(new Message(true, "Missing class property. The class property defines what objects in the collection use this menu builder data to create a menu.", menuComponent.getDocumentElement()));
throw new BuildFailedException();
}//else//
appendAssociation(viewBuilder, buffer, menuComponent, ASSOCIATION_TEXT, variableName, "setTextAssociation", "ASSOCIATION_TEXT" + index, IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, menuComponent, ASSOCIATION_IMAGE, variableName, "setImageAssociation", "ASSOCIATION_IMAGE" + index, IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, menuComponent, ASSOCIATION_IS_ENABLED, variableName, "setIsEnabledAssociation", "ASSOCIATION_IS_ENABLED" + index, IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, menuComponent, ASSOCIATION_IS_VISIBLE, variableName, "setIsVisibleAssociation", "ASSOCIATION_IS_VISIBLE" + index, IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
}//appendBaseMenuComponent()//
/**
* Appends the cascade menu component to the source.
* @param viewBuilder
* @param buffer
* @param variableName
* @param menuComponent The component metadata for the menu.
*/
public void appendCascadeMenuComponent(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData menuComponent, int index) {
appendBaseMenuComponent(viewBuilder, buffer, variableName, menuComponent, index);
appendAssociation(viewBuilder, buffer, menuComponent, ASSOCIATION_COLLECTION, variableName, "setCollectionAssociation", "ASSOCIATION_COLLECTION" + index, IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
}//appendCascadeMenuComponent()//
/**
* Appends the push menu component to the source.
* @param viewBuilder
* @param buffer
* @param variableName
* @param menuComponent The component metadata for the menu.
*/
public void appendPushMenuComponent(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData menuComponent, int index) {
Boolean synchronousSelection = (Boolean) menuComponent.getPropertyValue(PROPERTY_SYNCHRONOUS_SELECTION);
IMethodPart selectionMethod = menuComponent.getMethod(METHOD_SELECTION);
if(synchronousSelection != null) {
buffer.append("\t" + variableName + ".setSynchronousSelection(" + synchronousSelection + ");\r\n");
}//if//
appendBaseMenuComponent(viewBuilder, buffer, variableName, menuComponent, index);
if(selectionMethod != null) {
String associationIdentifier = viewBuilder.addMethodAssociationIdentifier(menuComponent.getDocumentElement(), variableName, METHOD_SELECTION);
viewBuilder.addDirectMethodHandler(menuComponent, associationIdentifier, selectionMethod);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".setSelectionMethod(");
viewBuilder.appendMethodAssociation(buffer, variableName, selectionMethod, associationIdentifier);
buffer.append(");\r\n");
}//if//
}//appendPushMenuComponent()//
/**
* Appends the toggle menu component to the source.
* @param viewBuilder
* @param buffer
* @param variableName
* @param menuComponent The component metadata for the menu.
*/
public void appendToggleMenuComponent(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData menuComponent, int index) {
appendBaseMenuComponent(viewBuilder, buffer, variableName, menuComponent, index);
appendAssociation(viewBuilder, buffer, menuComponent, ASSOCIATION_SELECTION, variableName, "setSelectionAssociation", "ASSOCIATION_SELECTION" + index, IViewSourceBuilder.ACCESS_TYPE_BOTH);
}//appendCheckMenuComponent()//
/**
* Appends the check menu component to the source.
* @param viewBuilder
* @param buffer
* @param variableName
* @param menuComponent The component metadata for the menu.
*/
public void appendCheckMenuComponent(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData menuComponent, int index) {
appendToggleMenuComponent(viewBuilder, buffer, variableName, menuComponent, index);
}//appendCheckMenuComponent()//
/**
* Appends the radio menu component to the source.
* @param viewBuilder
* @param buffer
* @param variableName
* @param menuComponent The component metadata for the menu.
*/
public void appendRadioMenuComponent(IViewSourceBuilder viewBuilder, StringBuffer buffer, String variableName, IComponentData menuComponent, int index) {
appendToggleMenuComponent(viewBuilder, buffer, variableName, menuComponent, index);
}//appendRadioMenuComponent()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.DynamicMenu";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendLinks(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.IComponentData, java.lang.String)
*/
public void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String variableName) {
}//appendLinks()//
}//DynamicMenuBuilder//

View File

@@ -0,0 +1,97 @@
/*
* 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;
import com.common.util.*;
import com.foundation.view.JefImage;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
import com.foundation.view.resource.ResourceReference;
public class EnhancedListBuilder extends TableComponentBuilder {
protected static final String STYLE_SINGLE = "single selection";
protected static final String STYLE_MULTI = "multi selection";
protected static final String PROPERTY_ITEM_IMAGE = "item-image";
protected static final String ASSOCIATION_ITEM_TEXT = "item-text";
protected static final String ASSOCIATION_ITEM_IMAGE = "item-image";
protected static final IHashMap styleMap = new LiteHashMap(TableComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(TableComponentBuilder.linkMap);
static {
styleMap.put(STYLE_SINGLE, "STYLE_SINGLE");
styleMap.put(STYLE_MULTI, "STYLE_MULTI");
}//static//
/**
* EnhancedListBuilder constructor.
*/
public EnhancedListBuilder() {
}//EnhancedListBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
buffer.append("\t");
buffer.append(variableName);
buffer.append(" = new ");
buffer.append(getComponentClassName());
buffer.append("(");
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.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) {
Object itemImage = (Object) data.getPropertyValue(PROPERTY_ITEM_IMAGE);
if(itemImage != null) {
if(itemImage instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultItemImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) itemImage).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultItemImage(new " + JefImage.class.getName() + "(\"" + itemImage + "\"));\r\n");
}//else//
}//if//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ITEM_TEXT, variableName, "setItemTextAssociation", "ASSOCIATION_ITEM_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ITEM_IMAGE, variableName, "setItemImageAssociation", "ASSOCIATION_ITEM_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.CollectionComponentBuilder#allowMultiSelection(com.foundation.view.definition.ComponentData)
*/
public boolean allowMultiSelection(IComponentData data) {
return data.getStyles().containsValue(STYLE_MULTI);
}//allowMultiSelection()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.EnhancedList";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//EnhancedListBuilder//

View File

@@ -0,0 +1,181 @@
/*
* 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;
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.controller.ViewController;
import com.foundation.view.IAbstractContainer;
import com.foundation.view.IView;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IAssociationGroupPart;
import com.foundation.view.definition.IComponentData;
public class ExpandBarBuilder extends ContainerBuilder {
protected static final String STYLE_VERTICAL_SCROLL = "vertical scroll";
protected static final String COMPONENT_ABSTRACT_ITEM = "abstract-item";
protected static final String COMPONENT_ITEMS = "items";
protected static final String COMPONENT_ITEM = "item";
protected static final String ASSOCIATION_ITEMS = "items";
protected static final String ASSOCIATION_SPACING = "spacing";
protected static final String PROPERTY_SPACING = "spacing";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap); //Note: Use ComponentBuilder instead of ContainerBuilder since we don't want to inherit any scrollable or container styles.//
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
static {
styleMap.put(STYLE_VERTICAL_SCROLL, "STYLE_VERTICAL_SCROLL");
}//static//
/**
* ExpandBarBuilder constructor.
*/
public ExpandBarBuilder() {
super();
}//ExpandBarBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
IList items = new LiteList(10, 50);
IIterator iterator = null;
boolean hasCreatedItemsHolderVariable = false;
Integer spacing = (Integer) data.getPropertyValue(PROPERTY_SPACING);
if(spacing != null) {
buffer.append("\t" + variableName + ".setSpacing(new Integer(" + spacing + "));\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_SPACING, variableName, "setSpacingAssociation", "ASSOCIATION_SPACING", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
//Collect the items components which define variable lists of components to show in the expand panel.//
data.getComponents(items, COMPONENT_ABSTRACT_ITEM, true);
iterator = items.iterator();
while(iterator.hasNext()) {
IComponentData item = (IComponentData) iterator.next();
if(item.getComponentType().getName().equals(COMPONENT_ITEM)) {
IComponentData itemData = item.getComponent(COMPONENT_COMPONENT, true);
if(itemData != null) {
String initializeMethodName = viewBuilder.addInitializeComponentMethod(itemData);
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
}//if//
else {
//Error: Must have exactly one component in the item.//
//TODO:
}//else//
}//if//
else if(item.getComponentType().getName().equals(COMPONENT_ITEMS)) {
IAssociationGroupPart itemsAssociations = item.getAssociations(ASSOCIATION_ITEMS);
//Item associations are added to a items holder, one holder for each grouping of associations.//
if(itemsAssociations != null) {
buffer.append("\t");
if(!hasCreatedItemsHolderVariable) {
buffer.append(getComponentClassName());
buffer.append(".IItemsHolder ");
hasCreatedItemsHolderVariable = true;
}//if//
//Initialize a items holder for this grouping of associations.//
buffer.append("itemsHolder = ");
buffer.append(variableName);
buffer.append(".addItems();\r\n");
buffer.append("\t");
buffer.append("itemsHolder");
buffer.append(".setItemsAssociation(");
viewBuilder.appendAssociation(data, buffer, variableName, itemsAssociations, "ASSOCIATION_ITEMS", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
buffer.append(");\r\n");
}//if//
else {
//Error: Expecting at least one items association.//
//TODO:
}//else//
}//else if//
else {
//Error: Unexpected component type.//
//TODO:
}//else//
}//while//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition.ComponentData)
*/
public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData data) {
String componentName = viewBuilder.addComponentNameIdentifier(data.getDocumentElement(), viewBuilder.getComponentName(data));
constructor.append("/**\r\n");
constructor.append(" * ");
constructor.append(className);
constructor.append(" constructor.\r\n");
constructor.append(" * @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.\r\n");
constructor.append(" * @param parentComponent The non-null parent view component which this frame will be contained in.\r\n");
constructor.append(" */\r\n");
constructor.append("public ");
constructor.append(className);
constructor.append("(");
constructor.append(ViewController.class.getName());
constructor.append(" controller, ");
constructor.append(IView.class.getName());
constructor.append(" parentComponent) {\r\n");
constructor.append("\tsuper((");
constructor.append(IAbstractContainer.class.getName());
constructor.append(") parentComponent, ");
appendComponentConstructorParameters(viewBuilder, constructor, data, null, componentName);
constructor.append(");\r\n\r\n");
constructor.append("\tsetController(controller);\r\n");
constructor.append("}//" + className + "()//\r\n");
}//buildConstructors()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.ExpandBar";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//ExpandBarBuilder//

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2004,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;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class FillLayoutBuilder extends AbstractLayoutBuilder {
protected static final String PROPERTY_DIRECTION = "direction";
protected static final String PROPERTY_MARGIN_WIDTH = "margin-width";
protected static final String PROPERTY_MARGIN_HEIGHT = "margin-height";
protected static final String PROPERTY_SPACING = "spacing";
/**
* FillLayoutBuilder constructor.
*/
public FillLayoutBuilder() {
super();
}//FillLayoutBuilder()//
/* (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) {
String direction = (String) data.getPropertyValue(PROPERTY_DIRECTION);
Integer marginWidth = (Integer) data.getPropertyValue(PROPERTY_MARGIN_WIDTH);
Integer marginHeight = (Integer) data.getPropertyValue(PROPERTY_MARGIN_HEIGHT);
Integer spacing = (Integer) data.getPropertyValue(PROPERTY_SPACING);
buffer.append("\t" + getComponentClassName() + " layout = new " + getComponentClassName() + "(" + viewBuilder.getComponentAttributeName(data.getParent()) + ");\r\n");
buffer.append("\t\r\n");
if(direction != null) {
if(direction.equals("horizontal")) {
buffer.append("\tlayout.setType(" + "org.eclipse.swt.SWT" + ".HORIZONTAL);\r\n");
}//if//
else {
buffer.append("\tlayout.setType(" + "org.eclipse.swt.SWT" + ".VERTICAL);\r\n");
}//else//
}//if//
if(spacing != null) {
buffer.append("\tlayout.setSpacing(" + spacing + ");\r\n");
}//if//
if(marginHeight != null) {
buffer.append("\tlayout.setMarginHeight(" + marginHeight + ");\r\n");
}//if//
if(marginWidth != null) {
buffer.append("\tlayout.setMarginWidth(" + marginWidth + ");\r\n");
}//if//
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.FillLayout";
}//getComponentClassName()//
}//FillLayoutBuilder//

View File

@@ -0,0 +1,48 @@
/*
* 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//

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 2006,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;
import com.common.util.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class FontNameComboBuilder extends ComponentBuilder {
protected static final String PROPERTY_SELECTION = "selection";
protected static final String PROPERTY_AUTO_SYNCHRONIZE_SELECTION = "auto-synchronize-selection";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String LINK_SELECTION = "selection";
private static final String LINK_TARGET_SELECTION = "selection";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
static {
linkMap.put(LINK_TARGET_SELECTION, "LINK_TARGET_SELECTION");
}//static//
/**
* FontNameComboBuilder constructor.
*/
public FontNameComboBuilder() {
}//FontNameComboBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, 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.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 selection = (String) data.getPropertyValue(PROPERTY_SELECTION);
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
if(selection != null) {
buffer.append("\t" + variableName + ".setSelection(\"" + selection + "\");\r\n");
}//if//
if(autoSynchronizeSelection != null) {
buffer.append("\t" + variableName + ".setAutoSynchronizeSelection(" + autoSynchronizeSelection + ");\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.builder.IBuilder#appendLinks(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
IList selectionLinks = data.getLinks(LINK_SELECTION);
if(selectionLinks != null) {
for(int index = 0; index < selectionLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) selectionLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addSelectionLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
super.appendLinks(viewBuilder, buffer, data, variableName);
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.FontNameComboBox";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//ButtonBuilder//

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 2006,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;
import com.common.util.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class FontSizeComboBuilder extends ComponentBuilder {
protected static final String PROPERTY_SELECTION = "selection";
protected static final String PROPERTY_AUTO_SYNCHRONIZE_SELECTION = "auto-synchronize-selection";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String LINK_SELECTION = "selection";
private static final String LINK_TARGET_SELECTION = "selection";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
static {
linkMap.put(LINK_TARGET_SELECTION, "LINK_TARGET_SELECTION");
}//static//
/**
* FontNameComboBuilder constructor.
*/
public FontSizeComboBuilder() {
}//FontNameComboBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, 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.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) {
Integer selection = (Integer) data.getPropertyValue(PROPERTY_SELECTION);
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
if(selection != null) {
buffer.append("\t" + variableName + ".setSelection(\"" + selection + "\");\r\n");
}//if//
if(autoSynchronizeSelection != null) {
buffer.append("\t" + variableName + ".setAutoSynchronizeSelection(" + autoSynchronizeSelection + ");\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.builder.IBuilder#appendLinks(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData, java.lang.String)
*/
public void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
IList selectionLinks = data.getLinks(LINK_SELECTION);
if(selectionLinks != null) {
for(int index = 0; index < selectionLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) selectionLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addSelectionLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
super.appendLinks(viewBuilder, buffer, data, variableName);
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.FontSizeComboBox";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//ButtonBuilder//

View File

@@ -0,0 +1,53 @@
/*
* 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.definition.IComponentData;
import com.foundation.view.builder.*;
public class FormLayoutBuilder extends AbstractLayoutBuilder {
protected static final String PROPERTY_MARGIN_WIDTH = "margin-width";
protected static final String PROPERTY_MARGIN_HEIGHT = "margin-height";
protected static final String PROPERTY_SPACING = "spacing";
/**
* FormLayoutBuilder constructor.
*/
public FormLayoutBuilder() {
}//FormLayoutBuilder()//
/* (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);
Integer spacing = (Integer) data.getPropertyValue(PROPERTY_SPACING);
buffer.append("\t" + getComponentClassName() + " layout = new " + getComponentClassName() + "(" + viewBuilder.getComponentAttributeName(data.getParent()) + ");\r\n");
buffer.append("\t\r\n");
if(spacing != null) {
buffer.append("\tlayout.setSpacing(" + spacing + ");\r\n");
}//if//
if(marginHeight != null) {
buffer.append("\tlayout.setMarginHeight(" + marginHeight + ");\r\n");
}//if//
if(marginWidth != null) {
buffer.append("\tlayout.setMarginWidth(" + marginWidth + ");\r\n");
}//if//
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.FormLayout";
}//getComponentClassName()//
}//FormLayoutBuilder//

View File

@@ -0,0 +1,175 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class FormLayoutDataBuilder extends AbstractLayoutBuilder {
protected static final String SIDE_LEFT = "left";
protected static final String SIDE_TOP = "top";
protected static final String SIDE_RIGHT = "right";
protected static final String SIDE_BOTTOM = "bottom";
protected static final String ALIGNMENT_DEFAULT = "default";
protected static final String ALIGNMENT_LEFT = "left";
protected static final String ALIGNMENT_TOP = "top";
protected static final String ALIGNMENT_RIGHT = "right";
protected static final String ALIGNMENT_BOTTOM = "bottom";
protected static final String ALIGNMENT_CENTER = "center";
protected static final String PROPERTY_WIDTH = "width";
protected static final String PROPERTY_HEIGHT = "height";
protected static final String PROPERTY_SIDE = "side";
protected static final String PROPERTY_PERCENT = "percent";
protected static final String PROPERTY_OFFSET = "offset";
protected static final String PROPERTY_COMPONENT = "component";
protected static final String PROPERTY_ALIGNMENT = "alignment";
protected static final String COMPONENT_ATTACHMENT = "attachment";
/**
* FormLayoutDataBuilder constructor.
*/
public FormLayoutDataBuilder() {
}//FormLayoutDataBuilder()//
/**
* A utility method to retrieve an attachment with a specific side.
* @param layoutData The layout data component.
* @param side The side property value.
* @return The attachment component, or null if one with the given side doesn't exist.
*/
protected IComponentData getAttachment(IComponentData layoutData, String side) {
IIterator iterator = layoutData.getComponents().iterator();
IComponentData result = null;
while((result == null) && (iterator.hasNext())) {
IComponentData next = (IComponentData) iterator.next();
if((next.getComponentType().getName().equals(COMPONENT_ATTACHMENT)) && (side.equals(next.getPropertyValue(PROPERTY_SIDE)))) {
result = next;
}//if//
}//while//
return result;
}//getAttachment()//
/* (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);
IComponentData left = getAttachment(data, SIDE_LEFT);
IComponentData top = getAttachment(data, SIDE_TOP);
IComponentData right = getAttachment(data, SIDE_RIGHT);
IComponentData bottom = getAttachment(data, SIDE_BOTTOM);
buffer.append("\t\t" + getComponentClassName() + " layoutData = new " + getComponentClassName() + "();\r\n");
buffer.append("\t\t\r\n");
if(width != null) {
buffer.append("\t\tlayoutData.width = " + width + ";\r\n");
}//if//
if(height != null) {
buffer.append("\t\tlayoutData.height = " + height + ";\r\n");
}//if//
if(left != null) {
appendAttachment(viewBuilder, buffer, data, left, SIDE_LEFT);
}//if//
if(top != null) {
appendAttachment(viewBuilder, buffer, data, top, SIDE_TOP);
}//if//
if(right != null) {
appendAttachment(viewBuilder, buffer, data, right, SIDE_RIGHT);
}//if//
if(bottom != null) {
appendAttachment(viewBuilder, buffer, data, bottom, SIDE_BOTTOM);
}//if//
buffer.append("\t\t" + viewBuilder.getComponentAttributeName(data.getParent()) + ".setLayoutData(layoutData);\r\n");
}//appendInitializationHead()//
/**
* Adds the attachment to the source.
* @param viewBuilder
* @param buffer
* @param formLayoutData
* @param attachment
* @param side
*/
protected void appendAttachment(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData formLayoutData, IComponentData attachment, String side) {
Integer percent = (Integer) attachment.getPropertyValue(PROPERTY_PERCENT);
Integer offset = (Integer) attachment.getPropertyValue(PROPERTY_OFFSET);
String alignment = (String) attachment.getPropertyValue(PROPERTY_ALIGNMENT);
String componentName = (String) attachment.getPropertyValue(PROPERTY_COMPONENT);
buffer.append("\t\tlayoutData.");
buffer.append(side);
buffer.append(" = new ");
buffer.append(getAttachmentClassName());
buffer.append("(");
if(componentName != null) {
IComponentData attachedComponent = formLayoutData.getParent().searchForComponent(componentName, "component", IComponentData.SEARCH_FLAG_STEP_DOWN);
if(attachedComponent == null) {
viewBuilder.getFeedbackStack().add(new Message(true, "Could not find the component named: " + componentName + " while building the layout attachment for the component named: " + viewBuilder.getComponentName(formLayoutData.getParent()), attachment.getDocumentElement()));
throw new BuildFailedException();
}//if//
else {
buffer.append(viewBuilder.getComponentAttributeName(attachedComponent));
buffer.append(".getSwtControl(), ");
buffer.append(offset != null ? offset.intValue() : 0);
buffer.append(", ");
buffer.append("org.eclipse.swt.SWT");
buffer.append('.');
if(ALIGNMENT_LEFT.equals(alignment)) {
buffer.append("LEFT");
}//if//
else if(ALIGNMENT_TOP.equals(alignment)) {
buffer.append("TOP");
}//else if//
else if(ALIGNMENT_RIGHT.equals(alignment)) {
buffer.append("RIGHT");
}//else if//
else if(ALIGNMENT_BOTTOM.equals(alignment)) {
buffer.append("BOTTOM");
}//else if//
else if(ALIGNMENT_CENTER.equals(alignment)) {
buffer.append("CENTER");
}//else if//
else {
buffer.append("DEFAULT");
}//else//
}//else//
}//if//
else {
buffer.append(percent != null ? percent.intValue() : 0);
buffer.append(", ");
buffer.append(offset != null ? offset.intValue() : 0);
}//else//
buffer.append(");\r\n");
}//appendAttachment()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.layout.FormData";
}//getComponentClassName()//
/**
* Gets the form attachment's class name.
* @return The name of the form attachment class.
*/
public String getAttachmentClassName() {
return "com.foundation.view.swt.layout.FormAttachment";
}//getAttachmentClassName()//
}//FormLayoutDataBuilder//

View File

@@ -0,0 +1,225 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.controller.*;
import com.foundation.view.JefImage;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
import com.foundation.view.resource.ResourceReference;
public class FrameBuilder extends ContainerBuilder {
protected static final String STYLE_MINIMIZE = "minimize";
protected static final String STYLE_MAXIMIZE = "maximize";
protected static final String STYLE_CLOSE = "close";
protected static final String STYLE_RESIZE = "resize";
protected static final String STYLE_TITLE = "title";
protected static final String STYLE_NO_TRIM = "no trim";
protected static final String STYLE_ON_TOP = "on top";
protected static final String STYLE_TOOL = "tool";
protected static final String STYLE_WINDOW_TRIM = "window trim";
protected static final String STYLE_DIALOG_TRIM = "dialog trim";
protected static final String METHOD_CLOSED = "closed";
protected static final String METHOD_ACTIVATED = "activated";
protected static final String METHOD_DEACTIVATED = "deactivated";
protected static final String METHOD_ICONIFIED = "iconified";
protected static final String METHOD_DEICONIFIED = "deiconified";
protected static final String COMPONENT_MENU_BAR = "menu-bar";
protected static final String PROPERTY_CONTAINER_IMAGES = "container-images";
protected static final String ASSOCIATION_CONTAINER_IMAGES = "container-images";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
static {
styleMap.put(STYLE_CLOSE, "STYLE_CLOSE");
styleMap.put(STYLE_MINIMIZE, "STYLE_MIN");
styleMap.put(STYLE_MAXIMIZE, "STYLE_MAX");
styleMap.put(STYLE_RESIZE, "STYLE_RESIZE");
styleMap.put(STYLE_TITLE, "STYLE_TITLE");
styleMap.put(STYLE_NO_TRIM, "STYLE_NO_TRIM");
styleMap.put(STYLE_WINDOW_TRIM, "STYLE_SHELL_TRIM");
styleMap.put(STYLE_DIALOG_TRIM, "STYLE_DIALOG_TRIM");
styleMap.put(STYLE_ON_TOP, "STYLE_ON_TOP");
styleMap.put(STYLE_TOOL, "STYLE_TOOL");
}//static//
/**
* FrameBuilder constructor.
*/
public FrameBuilder() {
}//FrameBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
IMethodPart closedMethod = data.getMethod(METHOD_CLOSED);
IMethodPart activatedMethod = data.getMethod(METHOD_ACTIVATED);
IMethodPart deactivatedMethod = data.getMethod(METHOD_DEACTIVATED);
IMethodPart iconifiedMethod = data.getMethod(METHOD_ICONIFIED);
IMethodPart deiconifiedMethod = data.getMethod(METHOD_DEICONIFIED);
Object images = (Object) data.getPropertyValue(PROPERTY_CONTAINER_IMAGES);
IComponentData menuBarComponent = (IComponentData) data.getComponent(COMPONENT_MENU_BAR, true);
if(menuBarComponent != null) {
String initializeMethodName = viewBuilder.addInitializeMenuMethod(data, menuBarComponent, "MenuBar");
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_CONTAINER_IMAGES, variableName, "setContainerImagesAssociation", "ASSOCIATION_CONTAINER_IMAGES", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
if(images != null) {
if(images instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultContainerImages(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) images).getResourceUrl() + "\"));\r\n");
}//if//
else {
String[] imagePaths = images.toString().split(";");
boolean isFirst = true;
buffer.append("\t" + variableName + ".setDefaultContainerImages(new " + JefImage.class.getName() + "[] {");
for(int index = 0; index < imagePaths.length; index++) {
String path = imagePaths[index] != null ? imagePaths[index].trim() : null;
if(path != null && path.length() > 0) {
if(!isFirst) {
buffer.append(", ");
}//if//
else {
isFirst = false;
}//else//
buffer.append("new " + JefImage.class.getName() + "(\"");
buffer.append(path);
buffer.append("\")");
}//if//
}//for//
buffer.append(");\r\n");
}//else//
}//if//
if(closedMethod != null) {
String associationIdentifier = viewBuilder.addMethodAssociationIdentifier(data.getDocumentElement(), variableName, METHOD_CLOSED);
viewBuilder.addDirectMethodHandler(data, associationIdentifier, closedMethod);
buffer.append("\t" + variableName + ".setClosedMethod(");
viewBuilder.appendMethodAssociation(buffer, variableName, closedMethod, associationIdentifier);
buffer.append(");\r\n");
}//if//
if(activatedMethod != null) {
String associationIdentifier = viewBuilder.addMethodAssociationIdentifier(data.getDocumentElement(), variableName, METHOD_ACTIVATED);
viewBuilder.addDirectMethodHandler(data, associationIdentifier, activatedMethod);
buffer.append("\t" + variableName + ".setActivatedMethod(");
viewBuilder.appendMethodAssociation(buffer, variableName, activatedMethod, associationIdentifier);
buffer.append(");\r\n");
}//if//
if(deactivatedMethod != null) {
String associationIdentifier = viewBuilder.addMethodAssociationIdentifier(data.getDocumentElement(), variableName, METHOD_DEACTIVATED);
viewBuilder.addDirectMethodHandler(data, associationIdentifier, deactivatedMethod);
buffer.append("\t" + variableName + ".setDeactivatedMethod(");
viewBuilder.appendMethodAssociation(buffer, variableName, deactivatedMethod, associationIdentifier);
buffer.append(");\r\n");
}//if//
if(iconifiedMethod != null) {
String associationIdentifier = viewBuilder.addMethodAssociationIdentifier(data.getDocumentElement(), variableName, METHOD_ICONIFIED);
viewBuilder.addDirectMethodHandler(data, associationIdentifier, iconifiedMethod);
buffer.append("\t" + variableName + ".setIconifiedMethod(");
viewBuilder.appendMethodAssociation(buffer, variableName, iconifiedMethod, associationIdentifier);
buffer.append(");\r\n");
}//if//
if(deiconifiedMethod != null) {
String associationIdentifier = viewBuilder.addMethodAssociationIdentifier(data.getDocumentElement(), variableName, METHOD_DEICONIFIED);
viewBuilder.addDirectMethodHandler(data, associationIdentifier, deiconifiedMethod);
buffer.append("\t" + variableName + ".setDeiconifiedMethod(");
viewBuilder.appendMethodAssociation(buffer, variableName, deiconifiedMethod, associationIdentifier);
buffer.append(");\r\n");
}//if//
//Make sure any buttons will be initialzed prior to setting any of them as the default.//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Frame";
}//getComponentClassName()//
/**
* Gets the platform specific name of the container class.
* @return The qualified name of the container class.
*/
public String getContainerClassName() {
return "com.foundation.view.swt.Container";
}//getContainerClassName()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition.ComponentData)
*/
public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData data) {
String componentName = viewBuilder.addComponentNameIdentifier(data.getDocumentElement(), viewBuilder.getComponentName(data));
constructor.append("/**\r\n");
constructor.append(" * ");
constructor.append(className);
constructor.append(" constructor.\r\n");
constructor.append(" * @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.\r\n");
constructor.append(" */\r\n");
constructor.append("public ");
constructor.append(className);
constructor.append("(");
constructor.append(ViewController.class.getName());
constructor.append(" controller) {\r\n");
constructor.append("\tsuper(");
appendComponentConstructorParameters(viewBuilder, constructor, data, "(" + getContainerClassName() + ") controller.getParentComponent()", componentName);
constructor.append(");\r\n\r\n");
constructor.append("\tsetController(controller);\r\n");
constructor.append("}//" + className + "()//\r\n");
}//buildConstructors()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//FrameBuilder//

View File

@@ -0,0 +1,72 @@
/*
* 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 GridLayoutBuilder extends AbstractLayoutBuilder {
protected static final String PROPERTY_MARGIN_WIDTH = "margin-width";
protected static final String PROPERTY_MARGIN_HEIGHT = "margin-height";
protected static final String PROPERTY_COLUMN_COUNT = "column-count";
protected static final String PROPERTY_EQUAL_WIDTH_COLUMNS = "equal-width-columns";
protected static final String PROPERTY_HORIZONTAL_SPACING = "horizontal-spacing";
protected static final String PROPERTY_VERTICAL_SPACING = "vertical-spacing";
/**
* GridLayoutBuilder constructor.
*/
public GridLayoutBuilder() {
super();
}//GridLayoutBuilder()//
/* (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);
Integer columnCount = (Integer) data.getPropertyValue(PROPERTY_COLUMN_COUNT);
Boolean equalWidthColumns = (Boolean) data.getPropertyValue(PROPERTY_EQUAL_WIDTH_COLUMNS);
Integer horizontalSpacing = (Integer) data.getPropertyValue(PROPERTY_HORIZONTAL_SPACING);
Integer verticalSpacing = (Integer) data.getPropertyValue(PROPERTY_VERTICAL_SPACING);
buffer.append("\t" + getComponentClassName() + " layout = new " + getComponentClassName() + "(" + viewBuilder.getComponentAttributeName(data.getParent()) + ");\r\n");
buffer.append("\t\r\n");
if(columnCount != null) {
buffer.append("\tlayout.setNumColumns(" + columnCount + ");\r\n");
}//if//
if(equalWidthColumns != null) {
buffer.append("\tlayout.setMakeColumnsEqualWidth(" + equalWidthColumns + ");\r\n");
}//if//
if(marginHeight != null) {
buffer.append("\tlayout.setMarginHeight(" + marginHeight.toString() + ");\r\n");
}//if//
if(marginWidth != null) {
buffer.append("\tlayout.setMarginWidth(" + marginWidth.toString() + ");\r\n");
}//if//
if(horizontalSpacing != null) {
buffer.append("\tlayout.setHorizontalSpacing(" + horizontalSpacing + ");\r\n");
}//if//
if(verticalSpacing != null) {
buffer.append("\tlayout.setVerticalSpacing(" + verticalSpacing + ");\r\n");
}//if//
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.GridLayout";
}//getComponentClassName()//
}//GridLayoutBuilder//

View File

@@ -0,0 +1,163 @@
/*
* 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 GridLayoutDataBuilder 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";
//These are the same as beginning and end, but allow people hand writing the vml to make mistakes.//
protected static final String ALIGNMENT_RIGHT = "right";
protected static final String ALIGNMENT_LEFT = "left";
protected static final String ALIGNMENT_TOP = "top";
protected static final String ALIGNMENT_BOTTOM = "bottom";
protected static final String PROPERTY_HORIZONTAL_ALIGNMENT = "horizontal-alignment";
protected static final String PROPERTY_VERTICAL_ALIGNMENT = "vertical-alignment";
protected static final String PROPERTY_DEFAULT_WIDTH = "default-width";
protected static final String PROPERTY_DEFAULT_HEIGHT = "default-height";
protected static final String PROPERTY_MINIMUM_WIDTH = "minimum-width";
protected static final String PROPERTY_MINIMUM_HEIGHT = "minimum-height";
protected static final String PROPERTY_HORIZONTAL_INDENT = "horizontal-indent";
protected static final String PROPERTY_HORIZONTAL_SPAN = "horizontal-span";
protected static final String PROPERTY_HORIZONTAL_FILL = "horizontal-fill";
protected static final String PROPERTY_VERTICAL_INDENT = "vertical-indent";
protected static final String PROPERTY_VERTICAL_SPAN = "vertical-span";
protected static final String PROPERTY_VERTICAL_FILL = "vertical-fill";
protected static final String PROPERTY_EXCLUDE = "exclude";
/**
* GridLayoutDataBuilder constructor.
*/
public GridLayoutDataBuilder() {
super();
}//GridLayoutDataBuilder()//
/**
* 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) || ALIGNMENT_LEFT.equals(alignment) || ALIGNMENT_TOP.equals(alignment)) {
source = "BEGINNING";
}//if//
else if(ALIGNMENT_CENTER.equals(alignment)) {
source = "CENTER";
}//else if//
else if(ALIGNMENT_END.equals(alignment) || ALIGNMENT_RIGHT.equals(alignment) || ALIGNMENT_BOTTOM.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#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition.ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String horizontalAlignment = (String) data.getPropertyValue(PROPERTY_HORIZONTAL_ALIGNMENT);
String verticalAlignment = (String) data.getPropertyValue(PROPERTY_VERTICAL_ALIGNMENT);
Integer defaultWidth = (Integer) data.getPropertyValue(PROPERTY_DEFAULT_WIDTH);
Integer defaultHeight = (Integer) data.getPropertyValue(PROPERTY_DEFAULT_HEIGHT);
Integer minimumWidth = (Integer) data.getPropertyValue(PROPERTY_MINIMUM_WIDTH);
Integer minimumHeight = (Integer) data.getPropertyValue(PROPERTY_MINIMUM_HEIGHT);
Integer horizontalIndent = (Integer) data.getPropertyValue(PROPERTY_HORIZONTAL_INDENT);
Integer horizontalSpan = (Integer) data.getPropertyValue(PROPERTY_HORIZONTAL_SPAN);
Boolean horizontalFill = (Boolean) data.getPropertyValue(PROPERTY_HORIZONTAL_FILL);
Integer verticalIndent = (Integer) data.getPropertyValue(PROPERTY_VERTICAL_INDENT);
Integer verticalSpan = (Integer) data.getPropertyValue(PROPERTY_VERTICAL_SPAN);
Boolean verticalFill = (Boolean) data.getPropertyValue(PROPERTY_VERTICAL_FILL);
Boolean exclude = (Boolean) data.getPropertyValue(PROPERTY_EXCLUDE);
buffer.append("\t\t" + getComponentClassName() + " layoutData = new " + getComponentClassName() + "();\r\n");
buffer.append("\t\t\r\n");
if(verticalAlignment != null) {
String alignment = getAlignmentSource(verticalAlignment);
if(alignment != null) {
buffer.append("\t\tlayoutData.verticalAlignment = " + getComponentClassName() + "." + alignment + ";\r\n");
}//if//
}//if//
if(horizontalAlignment != null) {
String alignment = getAlignmentSource(horizontalAlignment);
if(alignment != null) {
buffer.append("\t\tlayoutData.horizontalAlignment = " + getComponentClassName() + "." + alignment + ";\r\n");
}//if//
}//if//
if(defaultWidth != null) {
buffer.append("\t\tlayoutData.widthHint = " + (defaultWidth.intValue() < 0 ? -1 : defaultWidth.intValue()) + ";\r\n");
}//if//
if(defaultHeight != null) {
buffer.append("\t\tlayoutData.heightHint = " + (defaultHeight.intValue() < 0 ? -1 : defaultHeight.intValue()) + ";\r\n");
}//if//
if(minimumWidth != null) {
buffer.append("\t\tlayoutData.minimumWidth = " + (minimumWidth.intValue() < 0 ? 0 : minimumWidth.intValue()) + ";\r\n");
if(defaultWidth == null) {
buffer.append("\t\tlayoutData.widthHint = " + (minimumWidth.intValue() < 0 ? 0 : minimumWidth.intValue()) + ";\r\n");
}//if//
}//if//
if(minimumHeight != null) {
buffer.append("\t\tlayoutData.minimumHeight = " + (minimumHeight.intValue() < 0 ? -1 : minimumHeight.intValue()) + ";\r\n");
if(defaultHeight == null) {
buffer.append("\t\tlayoutData.heightHint = " + (minimumHeight.intValue() < 0 ? -1 : minimumHeight.intValue()) + ";\r\n");
}//if//
}//if//
if(horizontalIndent != null) {
buffer.append("\t\tlayoutData.horizontalIndent = " + horizontalIndent + ";\r\n");
}//if//
if(horizontalSpan != null) {
buffer.append("\t\tlayoutData.horizontalSpan = " + horizontalSpan + ";\r\n");
}//if//
if(verticalIndent != null) {
buffer.append("\t\tlayoutData.verticalIndent = " + verticalIndent + ";\r\n");
}//if//
if(verticalSpan != null) {
buffer.append("\t\tlayoutData.verticalSpan = " + verticalSpan + ";\r\n");
}//if//
if(horizontalFill != null) {
buffer.append("\t\tlayoutData.grabExcessHorizontalSpace = " + horizontalFill + ";\r\n");
}//if//
if(verticalFill != null) {
buffer.append("\t\tlayoutData.grabExcessVerticalSpace = " + verticalFill + ";\r\n");
}//if//
if(exclude != null) {
buffer.append("\t\tlayoutData.exclude = " + exclude + ";\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.GridData";
}//getComponentClassName()//
}//GridLayoutDataBuilder//

View File

@@ -0,0 +1,107 @@
/*
* 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;
import com.common.util.*;
import com.foundation.controller.ViewController;
import com.foundation.view.IAbstractContainer;
import com.foundation.view.IView;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class GroupBuilder extends ContainerBuilder {
protected static final String STYLE_SHADOW_ETCHED_IN = "shadow etched in";
protected static final String STYLE_SHADOW_ETCHED_OUT = "shadow etched out";
protected static final String STYLE_SHADOW_IN = "shadow in";
protected static final String STYLE_SHADOW_OUT = "shadow out";
protected static final String STYLE_SHADOW_NONE = "shadow none";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
static {
styleMap.put(STYLE_SHADOW_ETCHED_IN, "STYLE_SHADOW_ETCHED_IN");
styleMap.put(STYLE_SHADOW_ETCHED_OUT, "STYLE_SHADOW_ETCHED_OUT");
styleMap.put(STYLE_SHADOW_IN, "STYLE_SHADOW_IN");
styleMap.put(STYLE_SHADOW_OUT, "STYLE_SHADOW_OUT");
styleMap.put(STYLE_SHADOW_NONE, "STYLE_SHADOW_NONE");
}//static//
/**
* GroupBuilder constructor.
*/
public GroupBuilder() {
}//GroupBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition.ComponentData)
*/
public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData data) {
String componentName = viewBuilder.addComponentNameIdentifier(data.getDocumentElement(), viewBuilder.getComponentName(data));
constructor.append("/**\r\n");
constructor.append(" * ");
constructor.append(className);
constructor.append(" constructor.\r\n");
constructor.append(" * @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.\r\n");
constructor.append(" * @param parentComponent The non-null parent view component which this frame will be contained in.\r\n");
constructor.append(" */\r\n");
constructor.append("public ");
constructor.append(className);
constructor.append("(");
constructor.append(ViewController.class.getName());
constructor.append(" controller, ");
constructor.append(IView.class.getName());
constructor.append(" parentComponent) {\r\n");
constructor.append("\tsuper((");
constructor.append(IAbstractContainer.class.getName());
constructor.append(") parentComponent, ");
appendComponentConstructorParameters(viewBuilder, constructor, data, null, componentName);
constructor.append(");\r\n\r\n");
constructor.append("\tsetController(controller);\r\n");
constructor.append("}//" + className + "()//\r\n");
}//buildConstructors()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Group";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//GroupBuilder//

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) 2003,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;
import com.common.util.*;
import com.foundation.view.JefImage;
import com.foundation.view.resource.ResourceReference;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class LabelBuilder extends ComponentBuilder {
protected static final String STYLE_SEPARATOR = "separator";
protected static final String STYLE_HORIZONTAL = "horizontal";
protected static final String STYLE_VERTICAL = "vertical";
protected static final String STYLE_SHADOW_IN = "shadow in";
protected static final String STYLE_SHADOW_OUT = "shadow out";
protected static final String STYLE_SHADOW_NONE = "shadow now";
protected static final String STYLE_LEFT = "left";
protected static final String STYLE_RIGHT = "right";
protected static final String STYLE_CENTER = "center";
protected static final String STYLE_WRAP = "wrap";
protected static final String PROPERTY_TEXT = "text";
protected static final String PROPERTY_IMAGE = "image";
protected static final String ASSOCIATION_TEXT = "text";
protected static final String ASSOCIATION_IMAGE = "image";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
static {
styleMap.put(STYLE_SEPARATOR, "STYLE_SEPARATOR");
styleMap.put(STYLE_HORIZONTAL, "STYLE_HORIZONTAL");
styleMap.put(STYLE_VERTICAL, "STYLE_VERTICAL");
styleMap.put(STYLE_SHADOW_IN, "STYLE_SHADOW_IN");
styleMap.put(STYLE_SHADOW_OUT, "STYLE_SHADOW_OUT");
styleMap.put(STYLE_SHADOW_NONE, "STYLE_SHADOW_NONE");
styleMap.put(STYLE_LEFT, "STYLE_LEFT");
styleMap.put(STYLE_RIGHT, "STYLE_RIGHT");
styleMap.put(STYLE_CENTER, "STYLE_CENTER");
styleMap.put(STYLE_WRAP, "STYLE_WRAP");
}//static//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, 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.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) {
Object text = (Object) data.getPropertyValue(PROPERTY_TEXT);
Object image = (Object) data.getPropertyValue(PROPERTY_IMAGE);
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//
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);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Label";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//LabelBuilder//

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2005,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.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.definition.IMethodPart;
public class LinkBuilder extends ComponentBuilder {
protected static final String PROPERTY_TEXT = "text";
protected static final String ASSOCIATION_TEXT = "text";
protected static final String METHOD_SELECTION = "selection";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
/**
* LinkBuilder constructor.
*/
public LinkBuilder() {
super();
}//LinkBuilder()//
/* (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) {
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.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 text = (String) data.getPropertyValue(PROPERTY_TEXT);
IMethodPart selectionMethod = data.getMethod(METHOD_SELECTION);
if(text != null) {
buffer.append("\t" + variableName + ".setText(\"" + text + "\");\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_TEXT, variableName, "setTextAssociation", "ASSOCIATION_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
if((selectionMethod != null) && (selectionMethod.getName() != 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.Link";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//LinkBuilder//

View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 2003,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;
import com.common.util.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class ListBuilder extends CollectionComponentBuilder {
protected static final String STYLE_SINGLE = "single selection";
protected static final String STYLE_MULTI = "multi selection";
protected static final String ASSOCIATION_ITEM_TEXT = "item-text";
protected static final String ASSOCIATION_ITEM_IMAGE = "item-image";
protected static final IHashMap styleMap = new LiteHashMap(CollectionComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(CollectionComponentBuilder.linkMap);
static {
styleMap.put(STYLE_SINGLE, "STYLE_SINGLE");
styleMap.put(STYLE_MULTI, "STYLE_MULTI");
}//static//
/**
* ListBuilder constructor.
*/
public ListBuilder() {
}//ListBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
buffer.append("\t");
buffer.append(variableName);
buffer.append(" = new ");
buffer.append(getComponentClassName());
buffer.append("(");
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.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) {
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ITEM_TEXT, variableName, "setItemTextAssociation", "ASSOCIATION_ITEM_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ITEM_IMAGE, variableName, "setItemImageAssociation", "ASSOCIATION_ITEM_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.CollectionComponentBuilder#allowMultiSelection(com.foundation.view.definition.ComponentData)
*/
public boolean allowMultiSelection(IComponentData data) {
return data.getStyles().containsValue(STYLE_MULTI);
}//allowMultiSelection()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.ListBox";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//ListBuilder//

View File

@@ -0,0 +1,401 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.view.JefImage;
import com.foundation.view.resource.ResourceReference;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class MenuBuilder extends AbstractBuilder {
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 STYLE_NO_RADIO_GROUP = "no radio group";
protected static final String STYLE_DOWN = "down";
protected static final String STYLE_UP = "up";
protected static final String STYLE_CHECK = "check";
//protected static final String STYLE_PUSH = "push";
protected static final String STYLE_RADIO = "radio";
//protected static final String STYLE_SEPARATOR = "separator";
protected static final String PROPERTY_NAME = "name";
protected static final String PROPERTY_TEXT = "text";
protected static final String PROPERTY_IMAGE = "image";
protected static final String PROPERTY_X = "x";
protected static final String PROPERTY_Y = "y";
protected static final String PROPERTY_DEFAULT_ITEM = "default-item";
protected static final String PROPERTY_ACCELERATOR = "accelerator";
protected static final String PROPERTY_IS_VISIBLE = "is-visible";
protected static final String PROPERTY_IS_ENABLED = "is-enabled";
protected static final String PROPERTY_AUTO_SYNCHRONIZE_SELECTION = "auto-synchronize-selection";
protected static final String ASSOCIATION_TEXT = "text";
protected static final String ASSOCIATION_IMAGE = "image";
protected static final String ASSOCIATION_IS_VISIBLE = "is-visible";
protected static final String ASSOCIATION_IS_ENABLED = "is-enabled";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String LINK_SELECTION = "selection";
protected static final String METHOD_SELECTION = "selection";
protected static final String COMPONENT_MENU = "menu";
protected static final String COMPONENT_MENU_CASCADE = "menu-cascade";
private static final String LINK_TARGET_SELECTION = "selection";
private static final String LINK_TARGET_IS_VISIBLE = "is-visible";
private static final String LINK_TARGET_IS_ENABLED = "is-enabled";
private static final IHashMap styleMap = new LiteHashMap(AbstractBuilder.styleMap);
private static final IHashMap linkMap = new LiteHashMap(AbstractBuilder.linkMap);
private static final IHashMap acceleratorModifierMap = new LiteHashMap(10);
private static final IHashMap acceleratorKeyMap = new LiteHashMap(10);
public static final String SWT_ALT = "org.eclipse.swt.SWT.ALT";
public static final String SWT_SHIFT = "org.eclipse.swt.SWT.SHIFT";
public static final String SWT_CTRL = "org.eclipse.swt.SWT.CTRL";
public static final String SWT_CONTROL = "org.eclipse.swt.SWT.CONTROL";
public static final String SWT_COMMAND = "org.eclipse.swt.SWT.COMMAND";
public static final String SWT_MODIFIER_1 = "org.eclipse.swt.SWT.MOD1";
public static final String SWT_MODIFIER_2 = "org.eclipse.swt.SWT.MOD2";
public static final String SWT_MODIFIER_3 = "org.eclipse.swt.SWT.MOD3";
public static final String SWT_MODIFIER_4 = "org.eclipse.swt.SWT.MOD4";
public static final String SWT_BACK_SPACE = "org.eclipse.swt.SWT.BS";
public static final String SWT_CARRIAGE_RETURN = "org.eclipse.swt.SWT.CR";
public static final String SWT_DELETE = "org.eclipse.swt.SWT.DEL";
public static final String SWT_ESCAPE = "org.eclipse.swt.SWT.ESC";
public static final String SWT_LINE_FEED = "org.eclipse.swt.SWT.LF";
public static final String SWT_TAB = "org.eclipse.swt.SWT.TAB";
public static final String SWT_ARROW_UP = "org.eclipse.swt.SWT.ARROW_UP";
public static final String SWT_ARROW_DOWN = "org.eclipse.swt.SWT.ARROW_DOWN";
public static final String SWT_ARROW_LEFT = "org.eclipse.swt.SWT.ARROW_LEFT";
public static final String SWT_ARROW_RIGHT = "org.eclipse.swt.SWT.ARROW_RIGHT";
public static final String SWT_PAGE_UP = "org.eclipse.swt.SWT.PAGE_UP";
public static final String SWT_PAGE_DOWN = "org.eclipse.swt.SWT.PAGE_DOWN";
public static final String SWT_HOME = "org.eclipse.swt.SWT.HOME";
public static final String SWT_END = "org.eclipse.swt.SWT.END";
public static final String SWT_INSERT = "org.eclipse.swt.SWT.INSERT";
public static final String SWT_F1 = "org.eclipse.swt.SWT.F1";
public static final String SWT_F2 = "org.eclipse.swt.SWT.F2";
public static final String SWT_F3 = "org.eclipse.swt.SWT.F3";
public static final String SWT_F4 = "org.eclipse.swt.SWT.F4";
public static final String SWT_F5 = "org.eclipse.swt.SWT.F5";
public static final String SWT_F6 = "org.eclipse.swt.SWT.F6";
public static final String SWT_F7 = "org.eclipse.swt.SWT.F7";
public static final String SWT_F8 = "org.eclipse.swt.SWT.F8";
public static final String SWT_F9 = "org.eclipse.swt.SWT.F9";
public static final String SWT_F10 = "org.eclipse.swt.SWT.F10";
public static final String SWT_F11 = "org.eclipse.swt.SWT.F11";
public static final String SWT_F12 = "org.eclipse.swt.SWT.F12";
static {
styleMap.put(STYLE_LEFT_TO_RIGHT, "STYLE_LEFT_TO_RIGHT");
styleMap.put(STYLE_RIGHT_TO_LEFT, "STYLE_RIGHT_TO_LEFT");
//styleMap.put(STYLE_PUSH, "STYLE_PUSH");
styleMap.put(STYLE_CHECK, "STYLE_CHECK");
styleMap.put(STYLE_RADIO, "STYLE_RADIO");
//styleMap.put(STYLE_SEPARATOR, "STYLE_SEPARATOR");
styleMap.put(STYLE_NO_RADIO_GROUP, "NO_RADIO_GROUP");
styleMap.put(STYLE_DOWN, "STYLE_DOWN");
styleMap.put(STYLE_UP, "STYLE_UP");
linkMap.put(LINK_TARGET_SELECTION, "LINK_TARGET_SELECTION");
linkMap.put(LINK_TARGET_IS_VISIBLE, "LINK_TARGET_IS_VISIBLE");
linkMap.put(LINK_TARGET_IS_ENABLED, "LINK_TARGET_IS_ENABLED");
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_ALT, SWT_ALT);
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_COMMAND, SWT_COMMAND);
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_CONTROL, SWT_CONTROL);
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_CTRL, SWT_CTRL);
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_MODIFIER_1, SWT_MODIFIER_1);
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_MODIFIER_2, SWT_MODIFIER_2);
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_MODIFIER_3, SWT_MODIFIER_3);
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_MODIFIER_4, SWT_MODIFIER_4);
acceleratorModifierMap.put(IViewSourceBuilder.MODIFIER_SHIFT, SWT_SHIFT);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_BACK_SPACE, SWT_BACK_SPACE);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_CARRIAGE_RETURN, SWT_CARRIAGE_RETURN);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_DELETE, SWT_DELETE);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_ESCAPE, SWT_ESCAPE);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_LINE_FEED, SWT_LINE_FEED);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_TAB, SWT_TAB);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_ARROW_UP, SWT_ARROW_UP);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_ARROW_DOWN, SWT_ARROW_DOWN);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_ARROW_LEFT, SWT_ARROW_LEFT);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_ARROW_RIGHT, SWT_ARROW_RIGHT);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_PAGE_UP, SWT_PAGE_UP);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_PAGE_DOWN, SWT_PAGE_DOWN);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_HOME, SWT_HOME);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_END, SWT_END);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_INSERT, SWT_INSERT);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F1, SWT_F1);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F2, SWT_F2);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F3, SWT_F3);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F4, SWT_F4);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F5, SWT_F5);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F6, SWT_F6);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F7, SWT_F7);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F8, SWT_F8);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F9, SWT_F9);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F10, SWT_F10);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F11, SWT_F11);
acceleratorKeyMap.put(IViewSourceBuilder.ACCELERATOR_KEY_F12, SWT_F12);
}//static//
/**
* MenuBuilder constructor.
*/
public MenuBuilder() {
}//MenuBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
String parentVariableName = viewBuilder.getComponentAttributeName(data.getParent());
viewBuilder.addComponentAttribute(data, this);
buffer.append("\t");
buffer.append(variableName);
buffer.append(" = new ");
buffer.append(getComponentClassName());
buffer.append("(");
appendComponentConstructorParameters(viewBuilder, buffer, data, parentVariableName);
buffer.append(");\r\n");
buffer.append("\t\r\n");
appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationCode()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder2.ComponentBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition2.ComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
String typeName = data.getComponentType().getName();
boolean isBar = typeName.equals("menu-bar");
boolean isFloating = typeName.equals("menu-floating");
//boolean isSeparator = typeName.equals("menu-separator");
boolean isToggle = typeName.equals("menu-toggle");
boolean isPush = typeName.equals("menu");
boolean isCascade = typeName.equals("menu-cascade");
Object text = (Object) data.getPropertyValue(PROPERTY_TEXT);
Object image = (Object) data.getPropertyValue(PROPERTY_IMAGE);
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
String accelerator = null;
String defaultItem = null;
Integer x = null;
Integer y = null;
Object isVisible = (Object) data.getPropertyValue(PROPERTY_IS_VISIBLE);
Object isEnabled = (Object) data.getPropertyValue(PROPERTY_IS_ENABLED);
IMethodPart selectionMethod = data.getMethod(METHOD_SELECTION);
if(isBar || isFloating) {
defaultItem = (String) data.getPropertyValue(PROPERTY_DEFAULT_ITEM);
x = (Integer) data.getPropertyValue(PROPERTY_X);
y = (Integer) data.getPropertyValue(PROPERTY_Y);
}//if//
else {
accelerator = (String) data.getPropertyValue(PROPERTY_ACCELERATOR);
}//else//
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((x != null) && (y != null)) {
buffer.append("\t" + variableName + ".setLocation(" + x + ", " + y + ");\r\n");
}//if//
if((isToggle) && (autoSynchronizeSelection != null)) {
buffer.append("\t" + variableName + ".setAutoSynchronizeSelection(\"" + autoSynchronizeSelection + "\");\r\n");
}//if//
if(defaultItem != null) {
IComponentData defaultItemComponent = data.searchForComponent(defaultItem, null, IComponentData.SEARCH_FLAG_UP);
buffer.append('\t');
buffer.append(variableName);
buffer.append(".setDefaultItem(");
buffer.append(viewBuilder.getComponentAttributeName(defaultItemComponent));
buffer.append(");\r\n");
}//if//
if(isVisible != null) {
if(isVisible instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setIsVisible(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) isVisible).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setIsVisible(" + ((Boolean) isVisible).booleanValue() + ");\r\n");
}//else//
}//if//
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(accelerator != null) {
IList options = parseAccelerator(accelerator.trim());
IIterator iterator = options.iterator();
if(options.getSize() > 0) {
boolean isFirst = true;
buffer.append("\t" + variableName + ".setAccelerator(");
while(iterator.hasNext()) {
String next = (String) iterator.next();
String command = (String) acceleratorModifierMap.get(next);
if(isFirst) {
isFirst = false;
}//if//
else {
buffer.append(" | ");
}//else//
if(command != null) {
buffer.append(command);
}//if//
else if((command = (String) acceleratorKeyMap.get(next)) != null) {
buffer.append(command);
if(iterator.hasNext()) {
throw new ViewBuilderException("Error: Expected '" + next + "' ended the accelerator sequence: " + accelerator, -1, -1, -1);
}//if//
}//else if//
else {
if(next.length() > 1) {
throw new ViewBuilderException("Error: Expecting only one character, not several: " + next, -1, -1, -1);
}//if//
buffer.append('\'');
buffer.append(next.charAt(0));
buffer.append('\'');
if(iterator.hasNext()) {
throw new ViewBuilderException("Error: Expected '" + next + "' ended the accelerator sequence: " + accelerator, -1, -1, -1);
}//if//
}//else//
}//while//
buffer.append(");\r\n");
}//if//
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IS_VISIBLE, variableName, "setIsVisibleAssociation", "ASSOCIATION_IS_VISIBLE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IS_ENABLED, variableName, "setIsEnabledAssociation", "ASSOCIATION_IS_ENABLED", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
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);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_SELECTION, variableName, "setSelectionAssociation", "ASSOCIATION_SELECTION", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
if(isPush) {
if(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//
}//if//
//Append the child menus.//
if(isBar || isFloating || isCascade) {
IIterator iterator = data.getComponents().iterator();
while(iterator.hasNext()) {
IComponentData next = (IComponentData) iterator.next();
viewBuilder.getBuilder(next).appendInitializationHead(viewBuilder, buffer, next);
}//while//
}//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 void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
IList selectionLinks = data.getLinks(LINK_SELECTION);
if(selectionLinks != null) {
for(int index = 0; index < selectionLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) selectionLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addSelectionLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getAdditionalStyleSource()
*/
protected String getAdditionalStyleSource(IComponentData data) {
String typeName = data.getComponentType().getName();
boolean isBar = typeName.equals("menu-bar");
boolean isFloating = typeName.equals("menu-floating");
boolean isCascade = typeName.equals("menu-cascade");
boolean isPush = typeName.equals("menu");
boolean isSeparator = typeName.equals("menu-separator");
return isPush ? getComponentClassName() + '.' + "STYLE_PUSH" : isSeparator ? getComponentClassName() + '.' + "STYLE_SEPARATOR" : isBar ? getComponentClassName() + '.' + "STYLE_BAR" : isFloating ? getComponentClassName() + '.' + "STYLE_POPUP" : isCascade ? getComponentClassName() + '.' + "STYLE_CASCADE" : null;
}//getAdditionalStyleSource()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Menu";
}//getComponentClassName()//
/**
* Parses the accelerator options which are space delimited.
* @param accelerator The string containing space delimited options. Space, control, shift, and the F-keys are all represented by words which will be picked out.
* @return The set of accelerator options such as 'space', 'control', 'F2', or 's'.
*/
private IList parseAccelerator(String accelerator) {
IList result = new LiteList(5, 10);
AdvancedTextParser parser = new AdvancedTextParser(accelerator);
parser.setDelimiterSet(AdvancedTextParser.addDelimiter(null, " ", false, false, null));
while(parser.hasNext()) {
result.add(parser.next());
}//while//
return result;
}//parseAccelerator()//
}//MenuModel//

View File

@@ -0,0 +1,109 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.controller.ViewController;
import com.foundation.view.IAbstractContainer;
import com.foundation.view.IView;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class PanelBuilder extends ContainerBuilder {
//protected static final String ATTRIBUTE_INTERNAL_VIEWS = "internal-views";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
/**
* PanelBuilder constructor.
*/
public PanelBuilder() {
}//PanelBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
/*
AttributePart internalViewsAttribute = (AttributePart) data.getAttribute(ATTRIBUTE_INTERNAL_VIEWS);
if((internalViewsAttribute != null) && (internalViewsAttribute.getName() != null)) {
String associationIdentifier = viewBuilder.addAttributeAssociationIdentifier(variableName, ATTRIBUTE_INTERNAL_VIEWS);
viewBuilder.addDirectAttributeHandler(data, associationIdentifier, internalViewsAttribute, ICollection.class.getName(), IViewSourceBuilder.ATTRIBUTE_TYPE_GET_ONLY);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".setInternalViewsAttribute(");
viewBuilder.appendAttributeAssociation(buffer, variableName, internalViewsAttribute, associationIdentifier);
buffer.append(");\r\n");
}//if//
*/
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition.ComponentData)
*/
public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData data) {
String componentName = viewBuilder.addComponentNameIdentifier(data.getDocumentElement(), viewBuilder.getComponentName(data));
constructor.append("/**\r\n");
constructor.append(" * ");
constructor.append(className);
constructor.append(" constructor.\r\n");
constructor.append(" * @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.\r\n");
constructor.append(" * @param parentComponent The non-null parent view component which this frame will be contained in.\r\n");
constructor.append(" */\r\n");
constructor.append("public ");
constructor.append(className);
constructor.append("(");
constructor.append(ViewController.class.getName());
constructor.append(" controller, ");
constructor.append(IView.class.getName());
constructor.append(" parentComponent) {\r\n");
constructor.append("\tsuper((");
constructor.append(IAbstractContainer.class.getName());
constructor.append(") parentComponent, ");
appendComponentConstructorParameters(viewBuilder, constructor, data, null, componentName);
constructor.append(");\r\n\r\n");
constructor.append("\tsetController(controller);\r\n");
constructor.append("}//" + className + "()//\r\n");
}//buildConstructors()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Panel";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//PanelBuilder//

View File

@@ -0,0 +1,106 @@
/*
* Copyright (c) 2005,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.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.controller.ViewController;
import com.foundation.view.IAbstractContainer;
import com.foundation.view.IView;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public class PanelViewerBuilder extends ContainerBuilder {
protected static final String PROPERTY_CHANGE_FOCUS = "change-focus";
protected static final String ASSOCIATION_CONTROLLER = "controller";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
/**
* PanelViewerBuilder constructor.
*/
public PanelViewerBuilder() {
super();
}//PanelViewerBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
Boolean changeFocus = (Boolean) data.getPropertyValue(PROPERTY_CHANGE_FOCUS);
if(changeFocus != null) {
buffer.append("\t" + variableName + ".setChangeFocus(" + changeFocus + ");\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_CONTROLLER, variableName, "setControllerAssociation", "ASSOCIATION_CONTROLLER", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition.ComponentData)
*/
public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData data) {
String componentName = viewBuilder.addComponentNameIdentifier(data.getDocumentElement(), viewBuilder.getComponentName(data));
constructor.append("/**\r\n");
constructor.append(" * ");
constructor.append(className);
constructor.append(" constructor.\r\n");
constructor.append(" * @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.\r\n");
constructor.append(" * @param parentComponent The non-null parent view component which this frame will be contained in.\r\n");
constructor.append(" */\r\n");
constructor.append("public ");
constructor.append(className);
constructor.append("(");
constructor.append(ViewController.class.getName());
constructor.append(" controller, ");
constructor.append(IView.class.getName());
constructor.append(" parentComponent) {\r\n");
constructor.append("\tsuper((");
constructor.append(IAbstractContainer.class.getName());
constructor.append(") parentComponent, ");
appendComponentConstructorParameters(viewBuilder, constructor, data, null, componentName);
constructor.append(");\r\n\r\n");
constructor.append("\tsetController(controller);\r\n");
constructor.append("}//" + className + "()//\r\n");
}//buildConstructors()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.PanelViewer";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//PanelViewerBuilder//

View File

@@ -0,0 +1,119 @@
/*
* Copyright (c) 2006,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;
import java.math.BigDecimal;
import com.common.util.*;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.builder.*;
public class ProgressBuilder extends ComponentBuilder {
protected static final String STYLE_SMOOTH = "smooth";
protected static final String STYLE_VERTICAL = "vertical";
protected static final String STYLE_HORIZONTAL = "horizontal";
protected static final String STYLE_INDETERMINATE = "indeterminate";
protected static final String PROPERTY_MINIMUM = "maximum";
protected static final String PROPERTY_MAXIMUM = "minimum";
protected static final String PROPERTY_PROGRESS = "progress";
protected static final String PROPERTY_MULTIPLIER = "multiplier";
protected static final String ASSOCIATION_MAXIMUM = "maximum";
protected static final String ASSOCIATION_MINIMUM = "minimum";
protected static final String ASSOCIATION_PROGRESS = "progress";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
static {
styleMap.put(STYLE_SMOOTH, "STYLE_SMOOTH");
styleMap.put(STYLE_VERTICAL, "STYLE_VERTICAL");
styleMap.put(STYLE_HORIZONTAL, "STYLE_HORIZONTAL");
styleMap.put(STYLE_INDETERMINATE, "STYLE_INDETERMINATE");
}//static//
/**
* ProgressBuilder constructor.
*/
public ProgressBuilder() {
super();
}//ProgressBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, 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.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) {
Integer maximum = (Integer) data.getPropertyValue(PROPERTY_MAXIMUM);
Integer minimum = (Integer) data.getPropertyValue(PROPERTY_MINIMUM);
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(maximum != null) {
buffer.append("\t" + variableName + ".setMaximum(new Integer(" + maximum + "));\r\n");
}//if//
if(minimum != null) {
buffer.append("\t" + variableName + ".setMinimum(new Integer(" + minimum + "));\r\n");
}//if//
if(progress != null) {
buffer.append("\t" + variableName + ".setProgress(new java.math.BigDecimal(\"" + progress + "\"));\r\n");
}//if//
if(multiplier != null) {
buffer.append("\t" + variableName + ".setMultiplier(new java.math.BigDecimal(\"" + multiplier + "\"));\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_MAXIMUM, variableName, "setMaximumAssociation", "ASSOCIATION_MAXIMUM", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_MINIMUM, variableName, "setMinimumAssociation", "ASSOCIATION_MINIMUM", 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.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Progress";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//ProgressBuilder//

View File

@@ -0,0 +1,150 @@
/*
* Copyright (c) 2004,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;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class RowLayoutBuilder 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_DIRECTION = "direction";
protected static final String PROPERTY_MARGIN_WIDTH = "margin-width";
protected static final String PROPERTY_MARGIN_HEIGHT = "margin-height";
protected static final String PROPERTY_SPACING = "spacing";
protected static final String PROPERTY_WRAP = "wrap";
protected static final String PROPERTY_PACK = "pack";
protected static final String PROPERTY_FILL = "fill";
protected static final String PROPERTY_JUSTIFY = "justify";
protected static final String PROPERTY_MARGIN_LEFT = "margin-left";
protected static final String PROPERTY_MARGIN_TOP = "margin-top";
protected static final String PROPERTY_MARGIN_RIGHT = "margin-right";
protected static final String PROPERTY_MARGIN_BOTTOM = "margin-bottom";
protected static final String PROPERTY_ALIGNMENT = "alignment";
/**
* RowLayoutBuilder constructor.
*/
public RowLayoutBuilder() {
super();
}//RowLayoutBuilder()//
/* (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) {
String direction = (String) data.getPropertyValue(PROPERTY_DIRECTION);
Integer marginWidth = (Integer) data.getPropertyValue(PROPERTY_MARGIN_WIDTH);
Integer marginHeight = (Integer) data.getPropertyValue(PROPERTY_MARGIN_HEIGHT);
Integer spacing = (Integer) data.getPropertyValue(PROPERTY_SPACING);
Boolean wrap = (Boolean) data.getPropertyValue(PROPERTY_WRAP);
Boolean pack = (Boolean) data.getPropertyValue(PROPERTY_PACK);
Boolean fill = (Boolean) data.getPropertyValue(PROPERTY_FILL);
String alignment = (String) data.getPropertyValue(PROPERTY_ALIGNMENT);
Boolean justify = (Boolean) data.getPropertyValue(PROPERTY_JUSTIFY);
Integer marginLeft = (Integer) data.getPropertyValue(PROPERTY_MARGIN_LEFT);
Integer marginTop = (Integer) data.getPropertyValue(PROPERTY_MARGIN_TOP);
Integer marginRight = (Integer) data.getPropertyValue(PROPERTY_MARGIN_RIGHT);
Integer marginBottom = (Integer) data.getPropertyValue(PROPERTY_MARGIN_BOTTOM);
buffer.append("\t" + getComponentClassName() + " layout = new " + getComponentClassName() + "(" + viewBuilder.getComponentAttributeName(data.getParent()) + ");\r\n");
buffer.append("\t\r\n");
if(direction != null) {
if(direction.equals("horizontal")) {
buffer.append("\tlayout.setType(" + "org.eclipse.swt.SWT" + ".HORIZONTAL);\r\n");
}//if//
else {
buffer.append("\tlayout.setType(" + "org.eclipse.swt.SWT" + ".VERTICAL);\r\n");
}//else//
}//if//
if(spacing != null) {
buffer.append("\tlayout.setSpacing(" + spacing + ");\r\n");
}//if//
if(marginHeight != null) {
buffer.append("\tlayout.setMarginHeight(" + marginHeight + ");\r\n");
}//if//
if(marginWidth != null) {
buffer.append("\tlayout.setMarginWidth(" + marginWidth + ");\r\n");
}//if//
if(wrap != null) {
buffer.append("\tlayout.setWrap(" + wrap + ");\r\n");
}//if//
if(pack != null) {
buffer.append("\tlayout.setPack(" + pack + ");\r\n");
}//if//
if(alignment != null) {
alignment = getAlignmentSource(alignment);
if(alignment != null) {
buffer.append("\t\tlayout.setAlignment(org.eclipse.swt.SWT." + alignment + ");\r\n");
}//if//
}//if//
else if(fill != null) {
buffer.append("\tlayout.setAlignment(org.eclipse.swt.SWT.FILL);\r\n");
}//else if//
if(justify != null) {
buffer.append("\tlayout.setJustify(" + justify + ");\r\n");
}//if//
if(marginLeft != null) {
buffer.append("\tlayout.setMarginLeft(" + marginLeft + ");\r\n");
}//if//
if(marginTop != null) {
buffer.append("\tlayout.setMarginTop(" + marginTop + ");\r\n");
}//if//
if(marginRight != null) {
buffer.append("\tlayout.setMarginRight(" + marginRight + ");\r\n");
}//if//
if(marginBottom != null) {
buffer.append("\tlayout.setMarginBottom(" + marginBottom + ");\r\n");
}//if//
buffer.append("\t" + viewBuilder.getComponentAttributeName(data.getParent()) + ".setLayout(layout);\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.RowLayout";
}//getComponentClassName()//
}//RowLayoutBuilder//

View File

@@ -0,0 +1,92 @@
/*
* 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//

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2003,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;
import com.common.util.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class SashBuilder extends ComponentBuilder {
protected static final String STYLE_HORIZONTAL = "horizontal";
protected static final String STYLE_VERTICAL = "vertical";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
static {
styleMap.put(STYLE_HORIZONTAL, "STYLE_HORIZONTAL");
styleMap.put(STYLE_VERTICAL, "STYLE_VERTICAL");
}//static//
/**
* SashBuilder constructor.
*/
public SashBuilder() {
super();
}//SashBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, 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");
appendInitializationBody(viewBuilder, buffer, data, 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) {
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Sash";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//SashBuilder//

View File

@@ -0,0 +1,120 @@
/*
* Copyright (c) 2005,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;
import com.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public class SashFormBuilder extends ContainerBuilder {
protected static final String STYLE_VERTICAL = "vertical";
protected static final String STYLE_HORIZONTAL = "horizontal";
protected static final String STYLE_SMOOTH = "smooth";
protected static final String PROPERTY_WEIGHTS = "weights";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
static {
styleMap.put(STYLE_VERTICAL, "STYLE_VERTICAL");
styleMap.put(STYLE_HORIZONTAL, "STYLE_HORIZONTAL");
styleMap.put(STYLE_SMOOTH, "STYLE_SMOOTH");
}//static//
/**
* SashFormBuilder constructor.
*/
public SashFormBuilder() {
super();
}//SashFormBuilder()//
/* (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) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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 weightsText = (String) data.getPropertyValue(PROPERTY_WEIGHTS);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
//Process the weights after the components since swt doesn't like getting the weights first.//
//TODO: The weight count should be exactly equal to the number of components.//
if((weightsText != null) && (weightsText.trim().length() > 0)) {
int count = 1;
int index = -1;
int[] weights = null;
while((index = weightsText.indexOf(',', index + 1)) != -1) {
count++;
}//while//
weights = new int[count];
for(int startIndex = -1, endIndex = 0, weightIndex = 0; endIndex >= 0; weightIndex++) {
endIndex = weightsText.indexOf(',', startIndex + 1);
try {
String weight = endIndex == -1 ? weightsText.substring(startIndex + 1) : weightsText.substring(startIndex + 1, endIndex);
weight = weight.trim();
weights[weightIndex] = Integer.parseInt(weight);
}//try//
catch(Throwable e) {
weights[weightIndex] = 1;
}//catch//
startIndex = endIndex;
}//for//
buffer.append("\t" + variableName + ".setWeights(new int[] {");
for(index = 0; index < weights.length; index++) {
if(index != 0) {
buffer.append(',');
}//if//
buffer.append(weights[index]);
}//for//
buffer.append("});\r\n");
}//if//
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.SashForm";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//SashFormBuilder//

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.view.definition.*;
import com.foundation.view.builder.*;
public abstract class ScrollableComponentBuilder extends ComponentBuilder {
protected static final String STYLE_H_SCROLL = "horizontal scroll";
protected static final String STYLE_V_SCROLL = "vertical scroll";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
static {
styleMap.put(STYLE_H_SCROLL, "STYLE_H_SCROLL");
styleMap.put(STYLE_V_SCROLL, "STYLE_V_SCROLL");
}//static//
/**
* ScrollableComponentBuilder constructor.
*/
public ScrollableComponentBuilder() {
super();
}//ScrollableComponentBuilder()//
/* (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) {
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//ScrollableComponentBuilder//

View File

@@ -0,0 +1,445 @@
/*
* Copyright (c) 2005,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.common.util.IHashMap;
import com.common.util.IList;
import com.common.util.LiteHashMap;
import com.common.util.LiteList;
import com.foundation.view.JefColor;
import com.foundation.view.JefFont;
import com.foundation.view.JefImage;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.builder.ViewBuilderException;
import com.foundation.view.definition.IEventPart;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.resource.ResourceReference;
public class SimpleTableBuilder extends TableComponentBuilder {
protected static final String STYLE_MULTI = "multi selection";
protected static final String STYLE_SINGLE = "single selection";
protected static final String STYLE_CHECK = "check";
protected static final String STYLE_FULL_SELECTION = "full selection";
protected static final String STYLE_HIDE_SELECTION = "hide selection";
protected static final String STYLE_VIRTUAL = "virtual";
protected static final String PROPERTY_IN_VIEW_SORTING = "view-sorting";
protected static final String PROPERTY_SHOW_HEADERS = "show-headers";
protected static final String PROPERTY_SHOW_GRID_LINES = "show-grid-lines";
protected static final String PROPERTY_AUTO_FIT = "auto-fit";
protected static final String PROPERTY_FILL_ON_INITIALIZE = "fill-on-initialize";
protected static final String PROPERTY_FILL_ON_RESIZE = "fill-on-resize";
protected static final String EVENT_FIT = "fit";
protected static final String EVENT_FILL = "fill";
/** Used to hold column data which make up the columns of the table. */
protected static final String COMPONENT_COLUMNS = "columns";
/** Used to provide metadata for a specific column. */
protected static final String COMPONENT_COLUMN = "column";
/** Used to collect display types. */
protected static final String COMPONENT_DISPLAY_SET = "display-set";
/** The base type for the component and renderer display containers. */
protected static final String COMPONENT_DISPLAY_ABSTRACT = "display-abstract";
/** An extension of display-abstract which encapsulates a component. */
protected static final String COMPONENT_DISPLAY_COMPONENT = "display-component";
/** An extension of display-abstract which encapsulates a renderer. */
protected static final String COMPONENT_DISPLAY_RENDERER= "display-renderer";
/** Used to specify a component that replaces or augments cell values. */
protected static final String COMPONENT_CELL_COMPONENT = "cell-component";
/** Used to specify a renderer that replaces or augments cell values. */
protected static final String COMPONENT_CELL_RENDERER = "cell-renderer";
private static final String LINK_TARGET_FIT = "fit";
private static final String LINK_TARGET_FILL = "fill";
//Column identifiers.//
protected static final String PROPERTY_COLUMN_HEADER_TEXT = "header-text";
protected static final String PROPERTY_COLUMN_HEADER_IMAGE = "header-image";
protected static final String PROPERTY_COLUMN_RESIZEABLE = "resizable";
protected static final String PROPERTY_COLUMN_ALIGNMENT = "alignment";
protected static final String PROPERTY_COLUMN_WIDTH = "width";
protected static final String PROPERTY_COLUMN_MINIMUM_WIDTH = "minimum-width";
protected static final String PROPERTY_COLUMN_TOOL_TIP_TEXT = "tool-tip-text";
protected static final String PROPERTY_COLUMN_MOVEABLE = "moveable";
protected static final String PROPERTY_COLUMN_CELL_TEXT = "cell-text";
protected static final String PROPERTY_COLUMN_CELL_IMAGE = "cell-image";
protected static final String PROPERTY_COLUMN_CELL_BACKGROUND_COLOR = "cell-background-color";
protected static final String PROPERTY_COLUMN_CELL_FOREGROUND_COLOR = "cell-foreground-color";
protected static final String PROPERTY_COLUMN_CELL_FONT = "cell-font";
protected static final String ASSOCIATION_COLUMN_HEADER_TEXT = "header-text";
protected static final String ASSOCIATION_COLUMN_HEADER_IMAGE = "header-image";
protected static final String ASSOCIATION_COLUMN_CELL_TEXT = "cell-text";
protected static final String ASSOCIATION_COLUMN_CELL_IMAGE = "cell-image";
protected static final String ASSOCIATION_COLUMN_CELL_BACKGROUND_COLOR = "cell-background-color";
protected static final String ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR = "cell-foreground-color";
protected static final String ASSOCIATION_COLUMN_CELL_FONT = "cell-font";
protected static final String PROPERTY_CELL_DISPLAY_TYPE = "row-type";
protected static final IHashMap styleMap = new LiteHashMap(TableComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(TableComponentBuilder.linkMap);
static {
styleMap.put(STYLE_MULTI, "STYLE_MULTI");
styleMap.put(STYLE_SINGLE, "STYLE_SINGLE");
styleMap.put(STYLE_FULL_SELECTION, "STYLE_FULL_SELECTION");
styleMap.put(STYLE_HIDE_SELECTION, "STYLE_HIDE_SELECTION");
/* Not yet supported.
styleMap.put(STYLE_CHECK, "STYLE_CHECK");
styleMap.put(STYLE_VIRTUAL, "STYLE_VIRTUAL");
*/
linkMap.put(LINK_TARGET_FIT, "LINK_TARGET_FIT");
linkMap.put(LINK_TARGET_FILL, "LINK_TARGET_FILL");
}//static//
/**
* SimpleTableBuilder constructor.
*/
public SimpleTableBuilder() {
super();
}//SimpleTableBuilder()//
/* (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 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()//
/**
* Gets the fully qualified class name for the column class used by the source code builder to add a column.
* @return The simple table's column class name.
*/
protected String getColumnClassName() {
return "com.foundation.view.swt.SimpleTable.ColumnData";
}//getColumnClassName()//
/* (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) {
Boolean inViewSortingProperty = (Boolean) data.getPropertyValue(PROPERTY_IN_VIEW_SORTING);
Boolean showHeadersProperty = (Boolean) data.getPropertyValue(PROPERTY_SHOW_HEADERS);
Boolean showGridLinesProperty = (Boolean) data.getPropertyValue(PROPERTY_SHOW_GRID_LINES);
Boolean autoFit = (Boolean) data.getPropertyValue(PROPERTY_AUTO_FIT);
Boolean fillOnInitialize = (Boolean) data.getPropertyValue(PROPERTY_FILL_ON_INITIALIZE);
Boolean fillOnResize = (Boolean) data.getPropertyValue(PROPERTY_FILL_ON_RESIZE);
IList fitEvents = data.getEvents(EVENT_FIT);
IList fillEvents = data.getEvents(EVENT_FILL);
IComponentData columns = data.getComponent(COMPONENT_COLUMNS, false);
IList columnData = new LiteList(10, 20);
if(inViewSortingProperty != null) {
buffer.append("\t" + variableName + ".setInViewSorting(" + inViewSortingProperty + ");\r\n");
}//if//
if(showHeadersProperty != null) {
buffer.append("\t" + variableName + ".showHeaders(" + showHeadersProperty + ");\r\n");
}//if//
if(showGridLinesProperty != null) {
buffer.append("\t" + variableName + ".showGridLines(" + showGridLinesProperty + ");\r\n");
}//if//
if(autoFit != null) {
buffer.append("\t" + variableName + ".setAutoFit(" + autoFit + ");\r\n");
}//if//
if(fillOnInitialize != null) {
buffer.append("\t" + variableName + ".setFillOnInitialize(" + fillOnInitialize + ");\r\n");
}//if//
if(fillOnResize != null) {
buffer.append("\t" + variableName + ".setFillOnResize(" + fillOnResize + ");\r\n");
}//if//
if(fitEvents != null) {
for(int index = 0; index < fitEvents.getSize(); index++) {
IEventPart eventPart = (IEventPart) fitEvents.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addFitEventAssociation(");
viewBuilder.appendEventAssociation(buffer, variableName, eventPart);
buffer.append(");\r\n");
}//for//
}//if//
if(fillEvents != null) {
for(int index = 0; index < fillEvents.getSize(); index++) {
IEventPart eventPart = (IEventPart) fillEvents.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addFillEventAssociation(");
viewBuilder.appendEventAssociation(buffer, variableName, eventPart);
buffer.append(");\r\n");
}//for//
}//if//
if(columns != null) {
columns.getComponents(columnData, COMPONENT_COLUMN, true);
//Add the data for all the columns.//
for(int columnIndex = 0; columnIndex < columnData.getSize(); columnIndex++) {
String columnId = variableName + "ColumnPart" + columnIndex;
IComponentData column = (IComponentData) columnData.get(columnIndex);
Object headerTextProperty = (Object) column.getPropertyValue(PROPERTY_COLUMN_HEADER_TEXT);
Object headerImageProperty = (Object) column.getPropertyValue(PROPERTY_COLUMN_HEADER_IMAGE);
Object columnToolTipProperty = (Object) column.getPropertyValue(PROPERTY_COLUMN_TOOL_TIP_TEXT);
Boolean resizeableProperty = (Boolean) column.getPropertyValue(PROPERTY_COLUMN_RESIZEABLE);
Boolean moveableProperty = (Boolean) column.getPropertyValue(PROPERTY_COLUMN_MOVEABLE);
Integer widthProperty = (Integer) column.getPropertyValue(PROPERTY_COLUMN_WIDTH);
Integer minimumWidthProperty = (Integer) column.getPropertyValue(PROPERTY_COLUMN_MINIMUM_WIDTH);
String alignmentProperty = (String) column.getPropertyValue(PROPERTY_COLUMN_ALIGNMENT);
Object cellText = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_TEXT);
Object cellImage = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_IMAGE);
Object cellBackgroundColor = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_BACKGROUND_COLOR);
Object cellForegroundColor = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_FOREGROUND_COLOR);
Object cellFont = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_FONT);
IComponentData displaySet = column.getComponent(COMPONENT_DISPLAY_SET, false);
buffer.append("\t");
buffer.append(getColumnClassName());
buffer.append(" ");
buffer.append(columnId);
buffer.append(" = ");
buffer.append(variableName);
buffer.append(".addColumn();\r\n");
if(headerTextProperty != null) {
if(headerTextProperty instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setHeaderText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) headerTextProperty).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setHeaderText(\"" + headerTextProperty + "\");\r\n");
}//else//
}//if//
if(headerImageProperty != null) {
if(headerImageProperty instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setHeaderImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) headerImageProperty).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setHeaderImage(new " + JefImage.class.getName() + "(\"" + headerImageProperty + "\"));\r\n");
}//else//
}//if//
if(columnToolTipProperty != null) {
if(columnToolTipProperty instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setToolTipText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) columnToolTipProperty).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setToolTipText(\"" + columnToolTipProperty + "\");\r\n");
}//else//
}//if//
if(resizeableProperty != null) {
buffer.append("\t" + columnId + ".setHeaderResizeable(" + resizeableProperty + ");\r\n");
}//if//
if(moveableProperty != null) {
buffer.append("\t" + columnId + ".setMoveable(" + moveableProperty + ");\r\n");
}//if//
if(alignmentProperty != null) {
String code = alignmentProperty.equalsIgnoreCase("center") ? getSimpleTableCenterCode() : alignmentProperty.equalsIgnoreCase("right") ? getSimpleTableRightCode() : getSimpleTableLeftCode();
buffer.append("\t" + columnId + ".setAlignment(" + code + ");\r\n");
}//if//
if(widthProperty != null) {
buffer.append("\t" + columnId + ".setWidth(" + widthProperty + ");\r\n");
}//if//
if(minimumWidthProperty != null) {
buffer.append("\t" + columnId + ".setMinimumWidth(" + minimumWidthProperty + ");\r\n");
}//if//
if(cellText != null) {
if(cellText instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setCellText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellText).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setCellText(\"" + cellText + "\");\r\n");
}//else//
}//if//
if(cellImage != null) {
if(cellImage instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setCellImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellImage).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setCellImage(new " + JefImage.class.getName() + "(\"" + cellImage + "\"));\r\n");
}//else//
}//if//
if(cellBackgroundColor != null) {
if(cellBackgroundColor instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setBackgroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellBackgroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setBackgroundColor(new " + JefColor.class.getName() + "(\"" + cellBackgroundColor + "\"));\r\n");
}//else//
}//if//
if(cellForegroundColor != null) {
if(cellForegroundColor instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setForegroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellForegroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setForegroundColor(new " + JefColor.class.getName() + "(\"" + cellForegroundColor + "\"));\r\n");
}//else//
}//if//
if(cellFont != null) {
if(cellFont instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setFont(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellFont).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setFont(" + JefFont.class.getName() + ".getJefFonts(\"" + JefFont.getJefFontsString((JefFont[]) cellFont) + "\"));\r\n");
}//else//
}//if//
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_HEADER_TEXT, columnId, "setHeaderTextAssociation", "ASSOCIATION_COLUMN_HEADER_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_HEADER_IMAGE, columnId, "setHeaderImageAssociation", "ASSOCIATION_COLUMN_HEADER_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_TEXT, columnId, "setCellTextAssociation", "ASSOCIATION_COLUMN_CELL_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_IMAGE, columnId, "setCellImageAssociation", "ASSOCIATION_COLUMN_CELL_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_BACKGROUND_COLOR, columnId, "setBackgroundColorAssociation", "ASSOCIATION_COLUMN_CELL_BACKGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR, columnId, "setForegroundColorAssociation", "ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_FONT, columnId, "setFontAssociation", "ASSOCIATION_COLUMN_CELL_FONT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
if(displaySet != null) {
IList cellDisplays = new LiteList(10, 20);
displaySet.getComponents(cellDisplays, COMPONENT_DISPLAY_ABSTRACT, true);
//Setup each of the cell displays for the column.//
for(int displayIndex = 0; displayIndex < cellDisplays.getSize(); displayIndex++) {
IComponentData cellDisplay = (IComponentData) cellDisplays.get(displayIndex);
if(cellDisplay.getComponentType().getName().equals(COMPONENT_DISPLAY_COMPONENT)) {
IComponentData cellComponent = cellDisplay.getComponent(COMPONENT_CELL_COMPONENT, true);
String initializeMethodName = viewBuilder.addInitializeComponentMethod(cellComponent, getComponentClassName());
String typeProperty = (String) cellDisplay.getPropertyValue(PROPERTY_CELL_DISPLAY_TYPE);
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
//Add the component to the column's cell-component set.//
buffer.append('\t');
buffer.append(columnId);
buffer.append(".addCellComponent(");
if(typeProperty != null) {
buffer.append(typeProperty);
buffer.append(".class");
}//if//
else {
buffer.append("null");
}//else//
buffer.append(", ");
buffer.append(viewBuilder.getComponentAttributeName(cellComponent));
buffer.append(");\r\n");
}//if//
else if(cellDisplay.getComponentType().getName().equals(COMPONENT_DISPLAY_RENDERER)) {
IComponentData cellRenderer = cellDisplay.getComponent(COMPONENT_CELL_RENDERER, true);
String initializeMethodName = viewBuilder.addInitializeComponentMethod(cellRenderer);
String typeProperty = (String) cellDisplay.getPropertyValue(PROPERTY_CELL_DISPLAY_TYPE);
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
//Add the component to the column's cell-component set.//
buffer.append('\t');
buffer.append(columnId);
buffer.append(".addCellRenderer(");
if(typeProperty != null) {
buffer.append(typeProperty);
buffer.append(".class");
}//if//
else {
buffer.append("null");
}//else//
buffer.append(", ");
buffer.append(viewBuilder.getComponentAttributeName(cellRenderer));
buffer.append(");\r\n");
}//else if//
else {
throw new ViewBuilderException("The display-set must contain either display-component or display-renderer types.", null);
}//else//
}//for//
}//if//
}//for//
}//if//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.CollectionComponentBuilder#allowMultiSelection(com.foundation.view.definition.ComponentData)
*/
public boolean allowMultiSelection(IComponentData data) {
return data.getStyles().containsValue(STYLE_MULTI);
}//allowMultiSelection()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.SimpleTable";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
/**
* Gets the identifier to be used for the CENTER alignemnt identifier.
* @return The identifier code snipit identifying a center alignment.
*/
protected String getSimpleTableCenterCode() {
//TODO: Implement for the thick client table.//
return "com.foundation.view.swt.SimpleTable.ALIGNMENT_CENTER";
}//getSimpleTableCenterCode()//
/**
* Gets the identifier to be used for the CENTER alignemnt identifier.
* @return The identifier code snipit identifying a center alignment.
*/
protected String getSimpleTableLeftCode() {
//TODO: Implement for the thick client table.//
return "com.foundation.view.swt.SimpleTable.ALIGNMENT_LEFT";
}//getSimpleTableLeftCode()//
/**
* Gets the identifier to be used for the CENTER alignemnt identifier.
* @return The identifier code snipit identifying a center alignment.
*/
protected String getSimpleTableRightCode() {
//TODO: Implement for the thick client table.//
return "com.foundation.view.swt.SimpleTable.ALIGNMENT_RIGHT";
}//getSimpleTableRightCode()//
}//SimpleTableBuilder//

View File

@@ -0,0 +1,501 @@
/*
* Copyright (c) 2005,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;
import com.common.util.IHashMap;
import com.common.util.IList;
import com.common.util.LiteHashMap;
import com.common.util.LiteList;
import com.foundation.view.JefColor;
import com.foundation.view.JefFont;
import com.foundation.view.JefImage;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.builder.ViewBuilderException;
import com.foundation.view.definition.IEventPart;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.resource.ResourceReference;
public class SimpleTreeTableBuilder extends TreeComponentBuilder {
protected static final String STYLE_MULTI = "multi selection";
protected static final String STYLE_SINGLE = "single selection";
protected static final String STYLE_CHECK = "check";
protected static final String STYLE_FULL_SELECTION = "full selection";
protected static final String STYLE_HIDE_SELECTION = "hide selection";
protected static final String STYLE_VIRTUAL = "virtual";
//protected static final String PROPERTY_IN_VIEW_SORTING = "view-sorting";
protected static final String PROPERTY_SHOW_HEADERS = "show-headers";
protected static final String PROPERTY_SHOW_GRID_LINES = "show-grid-lines";
protected static final String PROPERTY_SELECT_ON_OPEN = "select-on-open";
protected static final String PROPERTY_AUTO_FIT = "auto-fit";
protected static final String PROPERTY_FILL_ON_INITIALIZE = "fill-on-initialize";
protected static final String PROPERTY_FILL_ON_RESIZE = "fill-on-resize";
protected static final String PROPERTY_ROW_BACKGROUND_COLOR = "row-background-color";
protected static final String PROPERTY_ROW_FOREGROUND_COLOR = "row-foreground-color";
protected static final String PROPERTY_ROW_FONT = "row-font";
protected static final String PROPERTY_ROW_HEIGHT = "row-height";
protected static final String ASSOCIATION_ROW_BACKGROUND_COLOR = "row-background-color";
protected static final String ASSOCIATION_ROW_FOREGROUND_COLOR = "row-foreground-color";
protected static final String ASSOCIATION_ROW_FONT = "row-font";
protected static final String ASSOCIATION_ROW_HEIGHT = "row-height";
protected static final String EVENT_FIT = "fit";
protected static final String EVENT_FILL = "fill";
private static final String LINK_TARGET_FIT = "fit";
private static final String LINK_TARGET_FILL = "fill";
/** Used to hold column data which make up the columns of the table. */
protected static final String COMPONENT_COLUMNS = "columns";
/** Used to provide metadata for a specific column. */
protected static final String COMPONENT_COLUMN = "column";
/** Used to collect display types. */
protected static final String COMPONENT_DISPLAY_SET = "display-set";
/** The base type for the component and renderer display containers. */
protected static final String COMPONENT_DISPLAY_ABSTRACT = "display-abstract";
/** An extension of display-abstract which encapsulates a component. */
protected static final String COMPONENT_DISPLAY_COMPONENT = "display-component";
/** An extension of display-abstract which encapsulates a renderer. */
protected static final String COMPONENT_DISPLAY_RENDERER= "display-renderer";
/** Used to specify a component that replaces or augments cell values. */
protected static final String COMPONENT_CELL_COMPONENT = "cell-component";
/** Used to specify a renderer that replaces or augments cell values. */
protected static final String COMPONENT_CELL_RENDERER = "cell-renderer";
//Column identifiers.//
protected static final String PROPERTY_COLUMN_HEADER_TEXT = "header-text";
protected static final String PROPERTY_COLUMN_HEADER_IMAGE = "header-image";
protected static final String PROPERTY_COLUMN_RESIZEABLE = "resizable";
protected static final String PROPERTY_COLUMN_ALIGNMENT = "alignment";
protected static final String PROPERTY_COLUMN_WIDTH = "width";
protected static final String PROPERTY_COLUMN_MINIMUM_WIDTH = "minimum-width";
protected static final String PROPERTY_COLUMN_TOOL_TIP_TEXT = "tool-tip-text";
protected static final String PROPERTY_COLUMN_MOVEABLE = "moveable";
protected static final String PROPERTY_COLUMN_CELL_TEXT = "cell-text";
protected static final String PROPERTY_COLUMN_CELL_IMAGE = "cell-image";
protected static final String PROPERTY_COLUMN_CELL_BACKGROUND_COLOR = "cell-background-color";
protected static final String PROPERTY_COLUMN_CELL_FOREGROUND_COLOR = "cell-foreground-color";
protected static final String PROPERTY_COLUMN_CELL_FONT = "cell-font";
protected static final String ASSOCIATION_COLUMN_HEADER_TEXT = "header-text";
protected static final String ASSOCIATION_COLUMN_HEADER_IMAGE = "header-image";
protected static final String ASSOCIATION_COLUMN_CELL_TEXT = "cell-text";
protected static final String ASSOCIATION_COLUMN_CELL_IMAGE = "cell-image";
protected static final String ASSOCIATION_COLUMN_CELL_BACKGROUND_COLOR = "cell-background-color";
protected static final String ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR = "cell-foreground-color";
protected static final String ASSOCIATION_COLUMN_CELL_FONT = "cell-font";
protected static final String ASSOCIATION_CHILDREN = "children";
protected static final String ASSOCIATION_GROUPING = "grouping";
protected static final String PROPERTY_CELL_DISPLAY_TYPE = "row-type";
protected static final IHashMap styleMap = new LiteHashMap(TreeComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(TreeComponentBuilder.linkMap);
static {
styleMap.put(STYLE_MULTI, "STYLE_MULTI");
styleMap.put(STYLE_SINGLE, "STYLE_SINGLE");
styleMap.put(STYLE_FULL_SELECTION, "FULL_SELECTION");
styleMap.put(STYLE_HIDE_SELECTION, "STYLE_HIDE_SELECTION");
/* Not yet supported.
styleMap.put(STYLE_CHECK, "STYLE_CHECK");
styleMap.put(STYLE_VIRTUAL, "STYLE_VIRTUAL");
*/
linkMap.put(LINK_TARGET_FIT, "LINK_TARGET_FIT");
linkMap.put(LINK_TARGET_FILL, "LINK_TARGET_FILL");
}//static//
/**
* SimpleTreeTableBuilder constructor.
*/
public SimpleTreeTableBuilder() {
super();
}//SimpleTreeTableBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.CollectionComponentBuilder#allowMultiSelection(com.foundation.view.definition.ComponentData)
*/
public boolean allowMultiSelection(IComponentData data) {
return false;
}//allowMultiSelection()//
/* (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 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.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) {
//Boolean inViewSortingProperty = (Boolean) data.getPropertyValue(PROPERTY_IN_VIEW_SORTING);
Boolean showHeadersProperty = (Boolean) data.getPropertyValue(PROPERTY_SHOW_HEADERS);
Boolean showGridLinesProperty = (Boolean) data.getPropertyValue(PROPERTY_SHOW_GRID_LINES);
Boolean setSelectOnOpen = (Boolean) data.getPropertyValue(PROPERTY_SELECT_ON_OPEN);
Boolean autoFit = (Boolean) data.getPropertyValue(PROPERTY_AUTO_FIT);
Boolean fillOnInitialize = (Boolean) data.getPropertyValue(PROPERTY_FILL_ON_INITIALIZE);
Boolean fillOnResize = (Boolean) data.getPropertyValue(PROPERTY_FILL_ON_RESIZE);
Object rowBackgroundColor = (Object) data.getPropertyValue(PROPERTY_ROW_BACKGROUND_COLOR);
Object rowForegroundColor = (Object) data.getPropertyValue(PROPERTY_ROW_FOREGROUND_COLOR);
Object rowFont = (Object) data.getPropertyValue(PROPERTY_ROW_FONT);
Integer rowHeight = (Integer) data.getPropertyValue(PROPERTY_ROW_HEIGHT);
IList fitEvents = data.getEvents(EVENT_FIT);
IList fillEvents = data.getEvents(EVENT_FILL);
IComponentData columns = data.getComponent(COMPONENT_COLUMNS, false);
IList columnData = new LiteList(10, 20);
//if(inViewSortingProperty != null) {
// buffer.append("\t" + variableName + ".setInViewSorting(" + inViewSortingProperty + ");\r\n");
//}//if//
if(showHeadersProperty != null) {
buffer.append("\t" + variableName + ".showHeaders(" + showHeadersProperty + ");\r\n");
}//if//
if(showGridLinesProperty != null) {
buffer.append("\t" + variableName + ".showGridLines(" + showGridLinesProperty + ");\r\n");
}//if//
if(setSelectOnOpen != null) {
buffer.append("\t" + variableName + ".setSelectOnOpen(" + setSelectOnOpen + ");\r\n");
}//if//
if(autoFit != null) {
buffer.append("\t" + variableName + ".setAutoFit(" + autoFit + ");\r\n");
}//if//
if(fillOnInitialize != null) {
buffer.append("\t" + variableName + ".setFillOnInitialize(" + fillOnInitialize + ");\r\n");
}//if//
if(fillOnResize != null) {
buffer.append("\t" + variableName + ".setFillOnResize(" + fillOnResize + ");\r\n");
}//if//
if(rowBackgroundColor != null) {
if(rowBackgroundColor instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setRowBackgroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowBackgroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setRowBackgroundColor(new " + JefColor.class.getName() + "(\"" + rowBackgroundColor + "\"));\r\n");
}//else//
}//if//
if(rowForegroundColor != null) {
if(rowForegroundColor instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setRowForegroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowForegroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setRowForegroundColor(new " + JefColor.class.getName() + "(\"" + rowForegroundColor + "\"));\r\n");
}//else//
}//if//
if(rowFont != null) {
if(rowFont instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setRowFont(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowFont).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setRowFont(" + JefFont.class.getName() + ".getJefFonts(\"" + JefFont.getJefFontsString((JefFont[]) rowFont) + "\"));\r\n");
}//else//
}//if//
if(rowHeight != null) {
buffer.append("\t" + variableName + ".setRowHeight(new Integer(" + rowHeight + "));\r\n");
}//if//
appendCollectionAssociation(viewBuilder, buffer, data, ASSOCIATION_CHILDREN, variableName, "setChildAssociation", "ASSOCIATION_CHILDREN");
appendCollectionAssociation(viewBuilder, buffer, data, ASSOCIATION_GROUPING, variableName, "setGroupAssociation", "ASSOCIATION_GROUPING");
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_BACKGROUND_COLOR, variableName, "setRowBackgroundColorAssociation", "ASSOCIATION_ROW_BACKGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_FOREGROUND_COLOR, variableName, "setRowForegroundColorAssociation", "ASSOCIATION_ROW_FOREGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_FONT, variableName, "setRowFontAssociation", "ASSOCIATION_ROW_FONT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_HEIGHT, variableName, "setRowHeightAssociation", "ASSOCIATION_ROW_HEIGHT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
if(fitEvents != null) {
for(int index = 0; index < fitEvents.getSize(); index++) {
IEventPart eventPart = (IEventPart) fitEvents.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addFitEventAssociation(");
viewBuilder.appendEventAssociation(buffer, variableName, eventPart);
buffer.append(");\r\n");
}//for//
}//if//
if(fillEvents != null) {
for(int index = 0; index < fillEvents.getSize(); index++) {
IEventPart eventPart = (IEventPart) fillEvents.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addFillEventAssociation(");
viewBuilder.appendEventAssociation(buffer, variableName, eventPart);
buffer.append(");\r\n");
}//for//
}//if//
if(columns != null) {
columns.getComponents(columnData, COMPONENT_COLUMN, true);
//Add the data for all the columns.//
for(int columnIndex = 0; columnIndex < columnData.getSize(); columnIndex++) {
String columnId = variableName + "ColumnPart" + columnIndex;
IComponentData column = (IComponentData) columnData.get(columnIndex);
Object headerTextProperty = (Object) column.getPropertyValue(PROPERTY_COLUMN_HEADER_TEXT);
Object headerImageProperty = (Object) column.getPropertyValue(PROPERTY_COLUMN_HEADER_IMAGE);
Object columnToolTipProperty = (Object) column.getPropertyValue(PROPERTY_COLUMN_TOOL_TIP_TEXT);
Boolean resizeableProperty = (Boolean) column.getPropertyValue(PROPERTY_COLUMN_RESIZEABLE);
Boolean moveableProperty = (Boolean) column.getPropertyValue(PROPERTY_COLUMN_MOVEABLE);
Integer widthProperty = (Integer) column.getPropertyValue(PROPERTY_COLUMN_WIDTH);
Integer minimumWidthProperty = (Integer) column.getPropertyValue(PROPERTY_COLUMN_MINIMUM_WIDTH);
String alignmentProperty = (String) column.getPropertyValue(PROPERTY_COLUMN_ALIGNMENT);
Object cellText = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_TEXT);
Object cellImage = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_IMAGE);
Object cellBackgroundColor = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_BACKGROUND_COLOR);
Object cellForegroundColor = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_FOREGROUND_COLOR);
Object cellFont = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_FONT);
IComponentData displaySet = column.getComponent(COMPONENT_DISPLAY_SET, false);
buffer.append("\t");
buffer.append(getColumnClassName());
buffer.append(" ");
buffer.append(columnId);
buffer.append(" = ");
buffer.append(variableName);
buffer.append(".addColumn();\r\n");
if(headerTextProperty != null) {
if(headerTextProperty instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setHeaderText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) headerTextProperty).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setHeaderText(\"" + headerTextProperty + "\");\r\n");
}//else//
}//if//
if(headerImageProperty != null) {
if(headerImageProperty instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setHeaderImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) headerImageProperty).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setHeaderImage(new " + JefImage.class.getName() + "(\"" + headerImageProperty + "\"));\r\n");
}//else//
}//if//
if(columnToolTipProperty != null) {
if(columnToolTipProperty instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setToolTipText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) columnToolTipProperty).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setToolTipText(\"" + columnToolTipProperty + "\");\r\n");
}//else//
}//if//
if(resizeableProperty != null) {
buffer.append("\t" + columnId + ".setHeaderResizeable(" + resizeableProperty + ");\r\n");
}//if//
if(moveableProperty != null) {
buffer.append("\t" + columnId + ".setMoveable(" + moveableProperty + ");\r\n");
}//if//
if(alignmentProperty != null) {
String code = alignmentProperty.equalsIgnoreCase("center") ? getSimpleTableCenterCode() : alignmentProperty.equalsIgnoreCase("right") ? getSimpleTableRightCode() : getSimpleTableLeftCode();
buffer.append("\t" + columnId + ".setAlignment(" + code + ");\r\n");
}//if//
if(widthProperty != null) {
buffer.append("\t" + columnId + ".setWidth(" + widthProperty + ");\r\n");
}//if//
if(minimumWidthProperty != null) {
buffer.append("\t" + columnId + ".setMinimumWidth(" + minimumWidthProperty + ");\r\n");
}//if//
if(cellText != null) {
if(cellText instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setCellText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellText).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setCellText(\"" + cellText + "\");\r\n");
}//else//
}//if//
if(cellImage != null) {
if(cellImage instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setCellImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellImage).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setCellImage(new " + JefImage.class.getName() + "(\"" + cellImage + "\"));\r\n");
}//else//
}//if//
if(cellBackgroundColor != null) {
if(cellBackgroundColor instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setBackgroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellBackgroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setBackgroundColor(new " + JefColor.class.getName() + "(\"" + cellBackgroundColor + "\"));\r\n");
}//else//
}//if//
if(cellForegroundColor != null) {
if(cellForegroundColor instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setForegroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellForegroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setForegroundColor(new " + JefColor.class.getName() + "(\"" + cellForegroundColor + "\"));\r\n");
}//else//
}//if//
if(cellFont != null) {
if(cellFont instanceof ResourceReference) {
buffer.append("\t" + columnId + ".setFont(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellFont).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + columnId + ".setFont(" + JefFont.class.getName() + ".getJefFonts(\"" + JefFont.getJefFontsString((JefFont[]) cellFont) + "\"));\r\n");
}//else//
}//if//
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_HEADER_TEXT, columnId, "setHeaderTextAssociation", "ASSOCIATION_COLUMN_HEADER_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_HEADER_IMAGE, columnId, "setHeaderImageAssociation", "ASSOCIATION_COLUMN_HEADER_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_TEXT, columnId, "setCellTextAssociation", "ASSOCIATION_COLUMN_CELL_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_IMAGE, columnId, "setCellImageAssociation", "ASSOCIATION_COLUMN_CELL_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_BACKGROUND_COLOR, columnId, "setBackgroundColorAssociation", "ASSOCIATION_COLUMN_CELL_BACKGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR, columnId, "setForegroundColorAssociation", "ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_FONT, columnId, "setFontAssociation", "ASSOCIATION_COLUMN_CELL_FONT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
if(displaySet != null) {
IList cellDisplays = new LiteList(10, 20);
displaySet.getComponents(cellDisplays, COMPONENT_DISPLAY_ABSTRACT, true);
//Setup each of the cell displays for the column.//
for(int displayIndex = 0; displayIndex < cellDisplays.getSize(); displayIndex++) {
IComponentData cellDisplay = (IComponentData) cellDisplays.get(displayIndex);
if(cellDisplay.getComponentType().getName().equals(COMPONENT_DISPLAY_COMPONENT)) {
IComponentData cellComponent = cellDisplay.getComponent(COMPONENT_CELL_COMPONENT, true);
String initializeMethodName = viewBuilder.addInitializeComponentMethod(cellComponent, getComponentClassName());
String typeProperty = (String) cellDisplay.getPropertyValue(PROPERTY_CELL_DISPLAY_TYPE);
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
//Add the component to the column's cell-component set.//
buffer.append('\t');
buffer.append(columnId);
buffer.append(".addCellComponent(");
if(typeProperty != null) {
buffer.append(typeProperty);
buffer.append(".class");
}//if//
else {
buffer.append("null");
}//else//
buffer.append(", ");
buffer.append(viewBuilder.getComponentAttributeName(cellComponent));
buffer.append(");\r\n");
}//if//
else if(cellDisplay.getComponentType().getName().equals(COMPONENT_DISPLAY_RENDERER)) {
IComponentData cellRenderer = cellDisplay.getComponent(COMPONENT_CELL_RENDERER, true);
String initializeMethodName = viewBuilder.addInitializeComponentMethod(cellRenderer);
String typeProperty = (String) cellDisplay.getPropertyValue(PROPERTY_CELL_DISPLAY_TYPE);
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
//Add the component to the column's cell-component set.//
buffer.append('\t');
buffer.append(columnId);
buffer.append(".addCellRenderer(");
if(typeProperty != null) {
buffer.append(typeProperty);
buffer.append(".class");
}//if//
else {
buffer.append("null");
}//else//
buffer.append(", ");
buffer.append(viewBuilder.getComponentAttributeName(cellRenderer));
buffer.append(");\r\n");
}//else if//
else {
throw new ViewBuilderException("The display-set must contain either display-component or display-renderer types.", null);
}//else//
}//for//
}//if//
}//for//
}//if//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.SimpleTreeTable";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
/**
* Gets the fully qualified class name for the column class used by the source code builder to add a column.
* @return The simple table's column class name.
*/
protected String getColumnClassName() {
return getComponentClassName() + ".ColumnData";
}//getColumnClassName()//
/**
* Gets the identifier to be used for the CENTER alignemnt identifier.
* @return The identifier code snipit identifying a center alignment.
*/
protected String getSimpleTableCenterCode() {
return getComponentClassName() + ".ALIGNMENT_CENTER";
}//getSimpleTableCenterCode()//
/**
* Gets the identifier to be used for the CENTER alignemnt identifier.
* @return The identifier code snipit identifying a center alignment.
*/
protected String getSimpleTableLeftCode() {
return getComponentClassName() + ".ALIGNMENT_LEFT";
}//getSimpleTableLeftCode()//
/**
* Gets the identifier to be used for the CENTER alignemnt identifier.
* @return The identifier code snipit identifying a center alignment.
*/
protected String getSimpleTableRightCode() {
return getComponentClassName() + ".ALIGNMENT_RIGHT";
}//getSimpleTableRightCode()//
}//SimpleTreeTableBuilder//

View File

@@ -0,0 +1,132 @@
/*
* Copyright (c) 2006,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;
import com.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public class SliderBuilder extends ComponentBuilder {
protected static final String STYLE_VERTICAL = "vertical";
protected static final String STYLE_HORIZONTAL = "horizontal";
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_MINIMUM = "minimum";
protected static final String PROPERTY_MAXIMUM = "maximum";
protected static final String PROPERTY_SELECTION = "selection";
protected static final String PROPERTY_INCREMENT = "increment";
protected static final String PROPERTY_PAGE_INCREMENT = "page-increment";
protected static final String PROPERTY_THUMB = "thumb";
protected static final String ASSOCIATION_MAXIMUM = "maximum";
protected static final String ASSOCIATION_MINIMUM = "minimum";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String ASSOCIATION_INCREMENT = "increment";
protected static final String ASSOCIATION_PAGE_INCREMENT = "page-increment";
protected static final String ASSOCIATION_THUMB = "thumb";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
static {
styleMap.put(STYLE_VERTICAL, "STYLE_VERTICAL");
styleMap.put(STYLE_HORIZONTAL, "STYLE_HORIZONTAL");
}//static//
/**
* SliderBuilder constructor.
*/
public SliderBuilder() {
super();
}//SliderBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, 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.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) {
Integer maximum = (Integer) data.getPropertyValue(PROPERTY_MAXIMUM);
Integer minimum = (Integer) data.getPropertyValue(PROPERTY_MINIMUM);
Integer selection = (Integer) data.getPropertyValue(PROPERTY_SELECTION);
Integer increment = (Integer) data.getPropertyValue(PROPERTY_INCREMENT);
Integer pageIncrement = (Integer) data.getPropertyValue(PROPERTY_PAGE_INCREMENT);
Integer thumb = (Integer) data.getPropertyValue(PROPERTY_THUMB);
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
Long autoSynchronizeSelectionDelay = (Long) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY);
if(maximum != null) {
buffer.append("\t" + variableName + ".setMaximum(new Integer(" + maximum + "));\r\n");
}//if//
if(minimum != null) {
buffer.append("\t" + variableName + ".setMinimum(new Integer(" + minimum + "));\r\n");
}//if//
if(selection != null) {
buffer.append("\t" + variableName + ".setSelection(new Integer(" + selection + "));\r\n");
}//if//
if(increment != null) {
buffer.append("\t" + variableName + ".setIncrement(new Integer(" + increment + "));\r\n");
}//if//
if(pageIncrement != null) {
buffer.append("\t" + variableName + ".setPageIncrement(new Integer(" + pageIncrement + "));\r\n");
}//if//
if(thumb != null) {
buffer.append("\t" + variableName + ".setThumb(new Integer(" + thumb + "));\r\n");
}//if//
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_MAXIMUM, variableName, "setMaximumAssociation", "ASSOCIATION_MAXIMUM", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_MINIMUM, variableName, "setMinimumAssociation", "ASSOCIATION_MINIMUM", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_SELECTION, variableName, "setSelectionAssociation", "ASSOCIATION_SELECTION", IViewSourceBuilder.ACCESS_TYPE_BOTH);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_INCREMENT, variableName, "setIncrementAssociation", "ASSOCIATION_INCREMENT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_PAGE_INCREMENT, variableName, "setPageIncrementAssociation", "ASSOCIATION_PAGE_INCREMENT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_THUMB, variableName, "setThumbAssociation", "ASSOCIATION_THUMB", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Slider";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//SliderBuilder//

View File

@@ -0,0 +1,124 @@
/*
* Copyright (c) 2006,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;
import com.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public class SpinnerBuilder extends ComponentBuilder {
protected static final String STYLE_WRAP = "wrap";
protected static final String STYLE_READ_ONLY = "read only";
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_MINIMUM = "minimum";
protected static final String PROPERTY_MAXIMUM = "maximum";
protected static final String PROPERTY_SELECTION = "selection";
protected static final String PROPERTY_INCREMENT = "increment";
protected static final String PROPERTY_PAGE_INCREMENT = "page-increment";
protected static final String ASSOCIATION_MAXIMUM = "maximum";
protected static final String ASSOCIATION_MINIMUM = "minimum";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String ASSOCIATION_INCREMENT = "increment";
protected static final String ASSOCIATION_PAGE_INCREMENT = "page-increment";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
static {
styleMap.put(STYLE_WRAP, "STYLE_WRAP");
styleMap.put(STYLE_READ_ONLY, "STYLE_READ_ONLY");
}//static//
/**
* SpinnerBuilder constructor.
*/
public SpinnerBuilder() {
super();
}//SpinnerBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, 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.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) {
Integer maximum = (Integer) data.getPropertyValue(PROPERTY_MAXIMUM);
Integer minimum = (Integer) data.getPropertyValue(PROPERTY_MINIMUM);
Integer selection = (Integer) data.getPropertyValue(PROPERTY_SELECTION);
Integer increment = (Integer) data.getPropertyValue(PROPERTY_INCREMENT);
Integer pageIncrement = (Integer) data.getPropertyValue(PROPERTY_PAGE_INCREMENT);
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
Long autoSynchronizeSelectionDelay = (Long) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY);
if(maximum != null) {
buffer.append("\t" + variableName + ".setMaximum(new Integer(" + maximum + "));\r\n");
}//if//
if(minimum != null) {
buffer.append("\t" + variableName + ".setMinimum(new Integer(" + minimum + "));\r\n");
}//if//
if(selection != null) {
buffer.append("\t" + variableName + ".setSelection(new Integer(" + selection + "));\r\n");
}//if//
if(increment != null) {
buffer.append("\t" + variableName + ".setIncrement(new Integer(" + increment + "));\r\n");
}//if//
if(pageIncrement != null) {
buffer.append("\t" + variableName + ".setPageIncrement(new Integer(" + pageIncrement + "));\r\n");
}//if//
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_MAXIMUM, variableName, "setMaximumAssociation", "ASSOCIATION_MAXIMUM", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_MINIMUM, variableName, "setMinimumAssociation", "ASSOCIATION_MINIMUM", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_SELECTION, variableName, "setSelectionAssociation", "ASSOCIATION_SELECTION", IViewSourceBuilder.ACCESS_TYPE_BOTH);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_INCREMENT, variableName, "setIncrementAssociation", "ASSOCIATION_INCREMENT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_PAGE_INCREMENT, variableName, "setPageIncrementAssociation", "ASSOCIATION_PAGE_INCREMENT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Spinner";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//SpinnerBuilder//

View File

@@ -0,0 +1,72 @@
/*
* Copyright (c) 2005,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.common.util.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
/*
* Builds the source for the stack viewer component.
*/
public class StackViewerBuilder extends ContainerBuilder {
protected static final String ASSOCIATION_VIEWS = "views";
protected static final String ASSOCIATION_VISIBLE_VIEW = "visible-view";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
/**
* StackViewerBuilder constructor.
*/
public StackViewerBuilder() {
super();
}//StackViewerBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_VIEWS, variableName, "setViewsAssociation", "ASSOCIATION_VIEWS", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_VISIBLE_VIEW, variableName, "setVisibleViewAssociation", "ASSOCIATION_VISIBLE_VIEW", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.StackViewer";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//StackViewerBuilder//

View File

@@ -0,0 +1,194 @@
/*
* Copyright (c) 2003,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;
import com.common.util.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class StyledTextBuilder extends ComponentBuilder {
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_FULL = "full";
protected static final String PROPERTY_TEXT = "text";
protected static final String PROPERTY_USE_NULL = "use-null";
protected static final String ASSOCIATION_TEXT = "text";
private static final String LINK_TARGET_BOLD_TEXT = "boldText";
private static final String LINK_TARGET_ITALIC_TEXT = "italicText";
private static final String LINK_TARGET_UNDERLINE_TEXT = "underlineText";
private static final String LINK_TARGET_STRIKEOUT_TEXT = "strikeoutText";
private static final String LINK_TARGET_TEXT_FONT_NAME = "textFontName";
private static final String LINK_TARGET_TEXT_FONT_SIZE = "textFontSize";
protected static final IHashMap styleMap = new LiteHashMap(ComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ComponentBuilder.linkMap);
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_FULL, "STYLE_FULL");
linkMap.put(LINK_TARGET_BOLD_TEXT, "LINK_TARGET_BOLD_TEXT");
linkMap.put(LINK_TARGET_ITALIC_TEXT, "LINK_TARGET_ITALIC_TEXT");
linkMap.put(LINK_TARGET_UNDERLINE_TEXT, "LINK_TARGET_UNDERLINE_TEXT");
linkMap.put(LINK_TARGET_STRIKEOUT_TEXT, "LINK_TARGET_STRIKEOUT_TEXT");
linkMap.put(LINK_TARGET_TEXT_FONT_NAME, "LINK_TARGET_TEXT_FONT_NAME");
linkMap.put(LINK_TARGET_TEXT_FONT_SIZE, "LINK_TARGET_TEXT_FONT_SIZE");
}//static//
/**
* TextFieldBuilder constructor.
*/
public StyledTextBuilder() {
}//TextFieldBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, 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");
appendInitializationBody(viewBuilder, buffer, data, 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) {
//boolean isReadOnly = data.getStyles().containsValue(STYLE_READ_ONLY);
String text = (String) data.getPropertyValue(PROPERTY_TEXT);
Boolean useNull = (Boolean) data.getPropertyValue(PROPERTY_USE_NULL);
if(useNull != null) {
buffer.append("\t" + variableName + ".setUseNull(" + useNull + ");\r\n");
}//if//
if(text != null) {
buffer.append("\t" + variableName + ".setText(");
buffer.append('"');
//TODO: Should escape the text.
buffer.append(text);
buffer.append('"');
buffer.append(");\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_TEXT, variableName, "setTextAssociation", "ASSOCIATION_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//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 void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
IList boldTextLinks = data.getLinks(LINK_TARGET_BOLD_TEXT);
IList italicTextLinks = data.getLinks(LINK_TARGET_ITALIC_TEXT);
IList strikeoutTextLinks = data.getLinks(LINK_TARGET_STRIKEOUT_TEXT);
IList underlineTextLinks = data.getLinks(LINK_TARGET_UNDERLINE_TEXT);
IList textFontNameLinks = data.getLinks(LINK_TARGET_TEXT_FONT_NAME);
IList textFontSizeLinks = data.getLinks(LINK_TARGET_TEXT_FONT_SIZE);
if(boldTextLinks != null) {
for(int index = 0; index < boldTextLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) boldTextLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addBoldTextLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
if(italicTextLinks != null) {
for(int index = 0; index < italicTextLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) italicTextLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addItalicTextLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
if(underlineTextLinks != null) {
for(int index = 0; index < underlineTextLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) underlineTextLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addUnderlineTextLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
if(strikeoutTextLinks != null) {
for(int index = 0; index < strikeoutTextLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) strikeoutTextLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addStrikeoutTextLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
if(textFontNameLinks != null) {
for(int index = 0; index < textFontNameLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) textFontNameLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addTextFontNameLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
if(textFontSizeLinks != null) {
for(int index = 0; index < textFontSizeLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) textFontSizeLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addTextFontSizeLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
super.appendLinks(viewBuilder, buffer, data, variableName);
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.StyledText";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//TextFieldBuilder//

View File

@@ -0,0 +1,170 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.controller.ViewController;
import com.foundation.view.IAbstractContainer;
import com.foundation.view.IView;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class TabPanelBuilder extends ContainerBuilder {
protected static final String STYLE_TOP = "top";
protected static final String STYLE_BOTTOM = "bottom";
protected static final String COMPONENT_ABSTRACT_PAGE = "abstract-page";
protected static final String COMPONENT_PAGES = "pages";
protected static final String COMPONENT_PAGE = "page";
protected static final String ASSOCIATION_PAGES = "pages";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
static {
styleMap.put(STYLE_TOP, "STYLE_TOP");
styleMap.put(STYLE_BOTTOM, "STYLE_BOTTOM");
}//static//
/**
* TabPanelBuilder constructor.
*/
public TabPanelBuilder() {
super();
}//TabPanelBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
IList pages = new LiteList(10, 50);
IIterator iterator = null;
boolean hasCreatedPagesHolderVariable = false;
//Collect the pages components which define variable lists of components to show in the tab panel.//
data.getComponents(pages, COMPONENT_ABSTRACT_PAGE, true);
iterator = pages.iterator();
while(iterator.hasNext()) {
IComponentData page = (IComponentData) iterator.next();
if(page.getComponentType().getName().equals(COMPONENT_PAGE)) {
IComponentData pageData = page.getComponent(COMPONENT_COMPONENT, true);
if(pageData != null) {
String initializeMethodName = viewBuilder.addInitializeComponentMethod(pageData);
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
}//if//
else {
//Error: Must have exactly one component in the page.//
//TODO:
}//else//
}//if//
else if(page.getComponentType().getName().equals(COMPONENT_PAGES)) {
IAssociationGroupPart pagesAssociations = page.getAssociations(ASSOCIATION_PAGES);
//Page associations are added to a pages holder, one holder for each grouping of associations.//
if(pagesAssociations != null) {
buffer.append("\t");
if(!hasCreatedPagesHolderVariable) {
buffer.append(getComponentClassName());
buffer.append(".IPagesHolder ");
hasCreatedPagesHolderVariable = true;
}//if//
//Initialize a pages holder for this grouping of associations.//
buffer.append("pagesHolder = ");
buffer.append(variableName);
buffer.append(".addPages();\r\n");
//Add the associations to the pages holder.//
buffer.append("\t");
buffer.append("pagesHolder");
buffer.append(".setPagesAssociation(");
viewBuilder.appendAssociation(page, buffer, variableName, pagesAssociations, "ASSOCIATION_PAGES", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
buffer.append(");\r\n");
}//if//
else {
//Error: Expecting at least one pages association.//
//TODO:
}//else//
}//else if//
else {
//Error: Unexpected component type.//
//TODO:
}//else//
}//while//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition.ComponentData)
*/
public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData data) {
String componentName = viewBuilder.addComponentNameIdentifier(data.getDocumentElement(), viewBuilder.getComponentName(data));
constructor.append("/**\r\n");
constructor.append(" * ");
constructor.append(className);
constructor.append(" constructor.\r\n");
constructor.append(" * @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.\r\n");
constructor.append(" * @param parentComponent The non-null parent view component which this frame will be contained in.\r\n");
constructor.append(" */\r\n");
constructor.append("public ");
constructor.append(className);
constructor.append("(");
constructor.append(ViewController.class.getName());
constructor.append(" controller, ");
constructor.append(IView.class.getName());
constructor.append(" parentComponent) {\r\n");
constructor.append("\tsuper((");
constructor.append(IAbstractContainer.class.getName());
constructor.append(") parentComponent, ");
appendComponentConstructorParameters(viewBuilder, constructor, data, null, componentName);
constructor.append(");\r\n\r\n");
constructor.append("\tsetController(controller);\r\n");
constructor.append("}//" + className + "()//\r\n");
}//buildConstructors()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.TabPanel";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//TabPanelBuilder//

View File

@@ -0,0 +1,145 @@
/*
* Copyright (c) 2005,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.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.view.JefColor;
import com.foundation.view.JefFont;
import com.foundation.view.JefGradient;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
import com.foundation.view.resource.ResourceReference;
public abstract class TableComponentBuilder extends CollectionComponentBuilder {
protected static final String PROPERTY_DECORATE_ITEMS = "decorate-items";
protected static final String PROPERTY_ROW_BACKGROUND_COLOR = "row-background-color";
protected static final String PROPERTY_ROW_FOREGROUND_COLOR = "row-foreground-color";
protected static final String PROPERTY_ROW_BACKGROUND_COLOR_ALT = "row-background-color-alt";
protected static final String PROPERTY_ROW_FOREGROUND_COLOR_ALT = "row-foreground-color-alt";
protected static final String PROPERTY_ROW_SELECTION_GRADIENT = "row-selection-gradient";
protected static final String PROPERTY_ROW_FONT = "row-font";
protected static final String PROPERTY_ROW_HEIGHT = "row-height";
protected static final String ASSOCIATION_ROW_BACKGROUND_COLOR_CUSTOM = "row-background-color-custom";
protected static final String ASSOCIATION_ROW_FOREGROUND_COLOR_CUSTOM = "row-foreground-color-custom";
protected static final String ASSOCIATION_ROW_BACKGROUND_COLOR = "row-background-color";
protected static final String ASSOCIATION_ROW_FOREGROUND_COLOR = "row-foreground-color";
protected static final String ASSOCIATION_ROW_BACKGROUND_COLOR_ALT = "row-background-color-alt";
protected static final String ASSOCIATION_ROW_FOREGROUND_COLOR_ALT = "row-foreground-color-alt";
protected static final String ASSOCIATION_ROW_SELECTION_GRADIENT = "row-selection-gradient";
protected static final String ASSOCIATION_ROW_FONT = "row-font";
protected static final String ASSOCIATION_ROW_HEIGHT = "row-height";
protected static final IHashMap styleMap = new LiteHashMap(CollectionComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(CollectionComponentBuilder.linkMap);
/**
* TableComponentBuilder constructor.
*/
public TableComponentBuilder() {
super();
}//TableComponentBuilder()//
/* (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) {
Boolean decorateItems = (Boolean) data.getPropertyValue(PROPERTY_DECORATE_ITEMS);
Object rowBackgroundColor = (Object) data.getPropertyValue(PROPERTY_ROW_BACKGROUND_COLOR);
Object rowForegroundColor = (Object) data.getPropertyValue(PROPERTY_ROW_FOREGROUND_COLOR);
Object rowBackgroundColorAlt = (Object) data.getPropertyValue(PROPERTY_ROW_BACKGROUND_COLOR_ALT);
Object rowForegroundColorAlt = (Object) data.getPropertyValue(PROPERTY_ROW_FOREGROUND_COLOR_ALT);
Object rowSelectionGradient = (Object) data.getPropertyValue(PROPERTY_ROW_SELECTION_GRADIENT);
Object rowFont = (Object) data.getPropertyValue(PROPERTY_ROW_FONT);
Integer rowHeight = (Integer) data.getPropertyValue(PROPERTY_ROW_HEIGHT);
if(decorateItems != null) {
buffer.append("\t" + variableName + ".setDecorateItems(" + decorateItems + ");\r\n");
}//if//
if(rowBackgroundColor != null) {
if(rowBackgroundColor instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setRowBackgroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowBackgroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setRowBackgroundColor(new " + JefColor.class.getName() + "(\"" + rowBackgroundColor + "\"));\r\n");
}//else//
}//if//
if(rowForegroundColor != null) {
if(rowForegroundColor instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setRowForegroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowForegroundColor).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setRowForegroundColor(new " + JefColor.class.getName() + "(\"" + rowForegroundColor + "\"));\r\n");
}//else//
}//if//
if(rowBackgroundColorAlt != null) {
if(rowBackgroundColorAlt instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setRowBackgroundColorAlt(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowBackgroundColorAlt).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setRowBackgroundColorAlt(new " + JefColor.class.getName() + "(\"" + rowBackgroundColorAlt + "\"));\r\n");
}//else//
}//if//
if(rowForegroundColorAlt != null) {
if(rowForegroundColorAlt instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setRowForegroundColorAlt(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowForegroundColorAlt).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setRowForegroundColorAlt(new " + JefColor.class.getName() + "(\"" + rowForegroundColorAlt + "\"));\r\n");
}//else//
}//if//
if(rowSelectionGradient != null) {
if(rowSelectionGradient instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setRowSelectionGradient(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowSelectionGradient).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setRowSelectionGradient(new " + JefGradient.class.getName() + "(\"" + rowSelectionGradient + "\"));\r\n");
}//else//
}//if//
if(rowFont != null) {
if(rowFont instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setRowFont(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowFont).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setRowFont(" + JefFont.class.getName() + ".getJefFonts(\"" + JefFont.getJefFontsString((JefFont[]) rowFont) + "\"));\r\n");
}//else//
}//if//
if(rowHeight != null) {
buffer.append("\t" + variableName + ".setRowHeight(new Integer(" + rowHeight + "));\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_BACKGROUND_COLOR_CUSTOM, variableName, "setRowBackgroundColorCustomAssociation", "ASSOCIATION_ROW_BACKGROUND_COLOR_CUSTOM", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_FOREGROUND_COLOR_CUSTOM, variableName, "setRowForegroundColorCustomAssociation", "ASSOCIATION_ROW_FOREGROUND_COLOR_CUSTOM", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_BACKGROUND_COLOR, variableName, "setRowBackgroundColorAssociation", "ASSOCIATION_ROW_BACKGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_FOREGROUND_COLOR, variableName, "setRowForegroundColorAssociation", "ASSOCIATION_ROW_FOREGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_BACKGROUND_COLOR_ALT, variableName, "setRowBackgroundColorAltAssociation", "ASSOCIATION_ROW_BACKGROUND_COLOR_ALT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_FOREGROUND_COLOR_ALT, variableName, "setRowForegroundColorAltAssociation", "ASSOCIATION_ROW_FOREGROUND_COLOR_ALT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_SELECTION_GRADIENT, variableName, "setRowSelectionGradientAssociation", "ASSOCIATION_ROW_SELECTION_GRADIENT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_FONT, variableName, "setRowFontAssociation", "ASSOCIATION_ROW_FONT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_HEIGHT, variableName, "setRowHeightAssociation", "ASSOCIATION_ROW_HEIGHT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//TableComponentBuilder//

View File

@@ -0,0 +1,582 @@
/*
* Copyright (c) 2003,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 java.math.BigDecimal;
import com.common.util.*;
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.resource.ResourceReference;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class TextBuilder extends ScrollableComponentBuilder {
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_ECHO_CHAR = "echo-char";
protected static final String FORMAT_PROPERTY_USE_NULL = "use-null";
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(ScrollableComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ScrollableComponentBuilder.linkMap);
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//
/**
* TextFieldBuilder constructor.
*/
public TextBuilder() {
}//TextFieldBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Ensure the multi-line style is only used with the text-format.//
if(data.getStyles().containsValue(STYLE_MULTI)) {
if(!allowMultiLineStyle(data)) {
data.getStyles().replace(STYLE_MULTI, STYLE_SINGLE);
}//if//
}//if//
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()//
/**
* Determines whether the multi style should be allowed.
* @param data The component data for the text control.
* @return Whether the text control can use the multi-line style based on the format information.
*/
protected boolean allowMultiLineStyle(IComponentData data) {
boolean result = true;
IComponentData formatComponent = data.getComponent(COMPONENT_FORMAT, true);
if(formatComponent != null) {
if(!formatComponent.getComponentType().getName().equals("text-format")) {
result = false;
}//if//
}//if//
return result;
}//allowMultiLineStyle()//
/* (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) {
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 + ".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) {
Object text = (Object) 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) {
if(text instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setValue(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) text).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setValue(\"" + text + "\");\r\n");
}//else//
}//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.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.TextField";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//TextFieldBuilder//

View File

@@ -0,0 +1,100 @@
/*
* Copyright (c) 2006,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;
import com.common.util.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class ToolBarBuilder extends ComponentBuilder {
protected static final String STYLE_FLAT = "flat";
protected static final String STYLE_RIGHT = "right";
protected static final String STYLE_WRAP = "wrap";
protected static final String STYLE_HORIZONTAL = "horizontal";
protected static final String STYLE_VERTICAL = "vertical";
protected static final String STYLE_SHADOW_OUT = "shadow out";
protected static final String COMPONENT_ABSTRACT_TOOL_ITEM = "tool-item-abstract";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
static {
styleMap.put(STYLE_FLAT, "STYLE_FLAT");
styleMap.put(STYLE_RIGHT, "STYLE_RIGHT");
styleMap.put(STYLE_WRAP, "STYLE_WRAP");
styleMap.put(STYLE_HORIZONTAL, "STYLE_HORIZONTAL");
styleMap.put(STYLE_VERTICAL, "STYLE_VERTICAL");
styleMap.put(STYLE_SHADOW_OUT, "STYLE_SHADOW_OUT");
}//static//
/**
* CoolBarBuilder constructor.
*/
public ToolBarBuilder() {
super();
}//CoolBarBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
IList components = new LiteList(10, 20);
IIterator itemIterator = null;
//Search for all sub-parts that extend the tool-item type.//
data.getComponents(components, COMPONENT_ABSTRACT_TOOL_ITEM, true);
itemIterator = components.iterator();
//Call the initialize method on the contained tool items.//
while(itemIterator.hasNext()) {
IComponentData next = (IComponentData) itemIterator.next();
String initializeMethodName = viewBuilder.addInitializeComponentMethod(next);
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
}//while//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.ToolBar";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//TabPanelBuilder//

View File

@@ -0,0 +1,296 @@
/*
* 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;
import com.common.util.*;
import com.foundation.view.JefImage;
import com.foundation.view.resource.ResourceReference;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class ToolItemBuilder extends AbstractBuilder {
protected static final String STYLE_FLAT = "flat";
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";
//The separator style which is also used for custom controls.//
protected static final String STYLE_SEPARATOR = "separator";
//The drop down style which is currently only used in conjunction with a popup (floating) menu.//
protected static final String STYLE_DROP_DOWN = "drop down";
//The width property can only be used with a separator or custom control.//
protected static final String PROPERTY_WIDTH = "width";
//The text and image are used with any non-separator.//
protected static final String PROPERTY_TEXT = "text";
protected static final String PROPERTY_IMAGE = "image";
protected static final String PROPERTY_ROLLOVER_IMAGE = "rollover-image";
protected static final String PROPERTY_DISABLED_IMAGE = "disabled-image";
protected static final String PROPERTY_TOOL_TIP_TEXT = "tool-tip-text";
protected static final String PROPERTY_IS_ENABLED = "is-enabled";
//The selection state properties are used with the check or radio styles.//
protected static final String PROPERTY_IS_SELECTED = "is-selected";
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 ASSOCIATION_TEXT = "text";
protected static final String ASSOCIATION_IMAGE = "image";
protected static final String ASSOCIATION_ROLLOVER_IMAGE = "rollover-image";
protected static final String ASSOCIATION_DISABLED_IMAGE = "disabled-image";
protected static final String ASSOCIATION_TOOL_TIP_TEXT = "tool-tip-text";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String ASSOCIATION_IS_ENABLED = "is-enabled";
protected static final String METHOD_SELECTION = "selection";
protected static final String LINK_SELECTION = "selection";
protected static final String COMPONENT_MENU_FLOATING = "menu-floating";
private static final String LINK_TARGET_SELECTION = "selection";
private static final String LINK_TARGET_TEXT = "text";
private static final String LINK_TARGET_IMAGE = "image";
private static final String LINK_TARGET_DISABLED_IMAGE = "disabled-image";
private static final String LINK_TARGET_ROLLOVER_IMAGE = "rollover-image";
private static final String LINK_TARGET_TOOL_TIP_TEXT = "tool-tip-text";
private static final String LINK_TARGET_IS_ENABLED = "is-enabled";
protected static final IHashMap styleMap = new LiteHashMap(AbstractBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(AbstractBuilder.linkMap);
static {
styleMap.put(STYLE_FLAT, "STYLE_FLAT");
//These styles are only for push type buttons.//
styleMap.put(STYLE_PUSH, "STYLE_PUSH");
//These styles are only for toggle type buttons.//
styleMap.put(STYLE_CHECK, "STYLE_CHECK");
styleMap.put(STYLE_RADIO, "STYLE_RADIO");
//The separator can be used for custon controls, and the drop down is used with a popup menu.//
styleMap.put(STYLE_SEPARATOR, "STYLE_SEPARATOR");
styleMap.put(STYLE_DROP_DOWN, "STYLE_DROP_DOWN");
linkMap.put(LINK_TARGET_SELECTION, "LINK_TARGET_SELECTION");
linkMap.put(LINK_TARGET_TEXT, "LINK_TARGET_TEXT");
linkMap.put(LINK_TARGET_IMAGE, "LINK_TARGET_IMAGE");
linkMap.put(LINK_TARGET_DISABLED_IMAGE, "LINK_TARGET_DISABLED_IMAGE");
linkMap.put(LINK_TARGET_ROLLOVER_IMAGE, "LINK_TARGET_ROLLOVER_IMAGE");
linkMap.put(LINK_TARGET_TOOL_TIP_TEXT, "LINK_TARGET_TOOL_TIP_TEXT");
linkMap.put(LINK_TARGET_IS_ENABLED, "LINK_TARGET_IS_ENABLED");
}//static//
/**
* CoolItemBuilder constructor.
*/
public ToolItemBuilder() {
super();
}//CoolItemBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
buffer.append("\t" + variableName + " = new " + getComponentClassName().replace('$', '.') + "(");
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.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) {
ISet styles = data.getStyles();
IList components = data.getComponents();
Integer width = (Integer) data.getPropertyValue(PROPERTY_WIDTH);
Object text = (Object) data.getPropertyValue(PROPERTY_TEXT);
Object toolTipText = (Object) data.getPropertyValue(PROPERTY_TOOL_TIP_TEXT);
Object image = (Object) data.getPropertyValue(PROPERTY_IMAGE);
Object rolloverImage = (Object) data.getPropertyValue(PROPERTY_ROLLOVER_IMAGE);
Object disabledImage = (Object) data.getPropertyValue(PROPERTY_DISABLED_IMAGE);
Boolean isSelected = (Boolean) data.getPropertyValue(PROPERTY_IS_SELECTED);
Object isEnabled = (Object) data.getPropertyValue(PROPERTY_IS_ENABLED);
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
Long autoSynchronizeSelectionDelay = (Long) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION_DELAY);
IMethodPart selectionMethod = data.getMethod(METHOD_SELECTION);
boolean isPush = styles.containsValue(STYLE_PUSH);
boolean isToggle = styles.containsValue(STYLE_CHECK) || styles.containsValue(STYLE_RADIO);
boolean isSeparator = styles.containsValue(STYLE_SEPARATOR);
boolean isDropMenu = styles.containsValue(STYLE_DROP_DOWN);
IComponentData floatingMenu = data.getComponent(COMPONENT_MENU_FLOATING, true);
if((isSeparator) && (components.getSize() == 1)) {
IComponentData component = (IComponentData) components.getFirst();
if(component != null) {
String initializeMethodName = viewBuilder.addInitializeComponentMethod(component);
//Initialize the control.//
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(viewBuilder.getComponentAttributeName(data.getParent()));
buffer.append(");\r\n");
//Pass the control to the item.//
buffer.append('\t');
buffer.append(variableName);
buffer.append(".setControl(");
buffer.append(viewBuilder.getComponentAttributeName(component));
buffer.append(");\r\n");
}//if//
}//if//
if(width != null) {
buffer.append("\t" + variableName + ".setWidth(" + width + ");\r\n");
}//if//
if(!isSeparator) {
if((isDropMenu) && (floatingMenu != null)) {
String initializeMethodName;
//Create the initialize menu method but use the tool item's tool bar as the menu parent since only components can have menus as children.//
floatingMenu.setParent(data.getParent());
initializeMethodName = viewBuilder.addInitializeMenuMethod(data, floatingMenu, "DropDownMenu");
floatingMenu.setParent(data);
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(viewBuilder.getComponentAttributeName(data.getParent()));
buffer.append(");\r\n");
buffer.append('\t');
buffer.append(variableName);
buffer.append(".setMenu(");
buffer.append(viewBuilder.getComponentAttributeName(floatingMenu));
buffer.append(");\r\n");
}//if//
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(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(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(rolloverImage != null) {
if(rolloverImage instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setHotImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rolloverImage).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setHotImage(new " + JefImage.class.getName() + "(\"" + rolloverImage + "\"));\r\n");
}//else//
}//if//
if(disabledImage != null) {
if(disabledImage instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDisabledImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) disabledImage).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDisabledImage(new " + JefImage.class.getName() + "(\"" + disabledImage + "\"));\r\n");
}//else//
}//if//
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(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_TOOL_TIP_TEXT, variableName, "setToolTipTextAssociation", "ASSOCIATION_TOOL_TIP_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IMAGE, variableName, "setImageAssociation", "ASSOCIATION_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROLLOVER_IMAGE, variableName, "setHotImageAssociation", "ASSOCIATION_ROLLOVER_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_DISABLED_IMAGE, variableName, "setDisabledTextAssociation", "ASSOCIATION_DISABLED_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IS_ENABLED, variableName, "setIsEnabledAssociation", "ASSOCIATION_IS_ENABLED", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
if(isToggle && autoSynchronizeSelection != null) {
buffer.append("\t" + variableName + ".setAutoSynchronizeSelection(" + autoSynchronizeSelection + ");\r\n");
}//if//
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//
}//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 void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
IList selectionLinks = data.getLinks(LINK_SELECTION);
if(selectionLinks != null) {
for(int index = 0; index < selectionLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) selectionLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addSelectionLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.ToolBar.ToolItem";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//TabPanelBuilder//

View File

@@ -0,0 +1,154 @@
/*
* Copyright (c) 2006,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;
import com.common.util.*;
import com.foundation.view.JefColor;
import com.foundation.view.resource.ResourceReference;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class ToolItemDropColorBuilder extends AbstractBuilder {
protected static final String STYLE_DROP_DOWN = "drop down";
protected static final String PROPERTY_WIDTH = "width";
protected static final String PROPERTY_HEIGHT = "height";
protected static final String PROPERTY_COLOR = "color";
protected static final String PROPERTY_AUTO_SYNCHRONIZE_SELECTION = "auto-synchronize-selection";
protected static final String PROPERTY_TOOL_TIP_TEXT = "tool-tip-text";
protected static final String PROPERTY_IS_ENABLED = "is-enabled";
protected static final String ASSOCIATION_SELECTION = "selection";
protected static final String ASSOCIATION_IS_ENABLED = "is-enabled";
protected static final String ASSOCIATION_TOOL_TIP_TEXT = "tool-tip-text";
protected static final String LINK_COLOR = "color";
private static final String LINK_TARGET_COLOR = "color";
private static final String LINK_TARGET_TOOL_TIP_TEXT = "tool-tip-text";
private static final String LINK_TARGET_IS_ENABLED = "is-enabled";
protected static final IHashMap styleMap = new LiteHashMap(AbstractBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(AbstractBuilder.linkMap);
static {
styleMap.put(STYLE_DROP_DOWN, "STYLE_DROP_DOWN");
linkMap.put(LINK_TARGET_COLOR, "LINK_TARGET_COLOR");
linkMap.put(LINK_TARGET_TOOL_TIP_TEXT, "LINK_TARGET_TOOL_TIP_TEXT");
linkMap.put(LINK_TARGET_IS_ENABLED, "LINK_TARGET_IS_ENABLED");
}//static//
/**
* CoolItemBuilder constructor.
*/
public ToolItemDropColorBuilder() {
super();
}//CoolItemBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
data.getStyles().add(STYLE_DROP_DOWN);
buffer.append("\t" + variableName + " = new " + getComponentClassName().replace('$', '.') + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
appendInitializationBody(viewBuilder, buffer, data, 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) {
Integer width = (Integer) data.getPropertyValue(PROPERTY_WIDTH);
Integer height = (Integer) data.getPropertyValue(PROPERTY_HEIGHT);
Object toolTipText = (Object) data.getPropertyValue(PROPERTY_TOOL_TIP_TEXT);
Object isEnabled = (Object) data.getPropertyValue(PROPERTY_IS_ENABLED);
Boolean autoSynchronizeSelection = (Boolean) data.getPropertyValue(PROPERTY_AUTO_SYNCHRONIZE_SELECTION);
Object color = (Object) data.getPropertyValue(PROPERTY_COLOR);
if(width != null) {
buffer.append("\t" + variableName + ".setWidth(" + width + ");\r\n");
}//if//
if(height != null) {
buffer.append("\t" + variableName + ".setHeight(" + height + ");\r\n");
}//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(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(autoSynchronizeSelection != null) {
buffer.append("\t" + variableName + ".setAutoSynchronizeSelection(" + autoSynchronizeSelection + ");\r\n");
}//if//
if(color != null) {
if(color instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) color).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setColor(new " + JefColor.class.getName() + "(\"" + color + "\"));\r\n");
}//else//
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_TOOL_TIP_TEXT, variableName, "setToolTipTextAssociation", "ASSOCIATION_TOOL_TIP_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_SELECTION, variableName, "setIsEnabledAssociation", "ASSOCIATION_SELECTION", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IS_ENABLED, variableName, "setSelectionAssociation", "ASSOCIATION_IS_ENABLED", IViewSourceBuilder.ACCESS_TYPE_BOTH);
}//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 void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
IList colorLinks = data.getLinks(LINK_COLOR);
if(colorLinks != null) {
for(int index = 0; index < colorLinks.getSize(); index++) {
ILinkPart part = (ILinkPart) colorLinks.get(index);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".addColorLink(");
viewBuilder.appendLink(data, buffer, part);
buffer.append(");\r\n");
}//for//
}//if//
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.ToolItemDropColor";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//TabPanelBuilder//

View File

@@ -0,0 +1,181 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.controller.*;
import com.foundation.view.JefImage;
import com.foundation.view.resource.ResourceReference;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class TrayItemBuilder extends AbstractBuilder {
protected static final String PROPERTY_IS_VISIBLE = "is-visible";
protected static final String PROPERTY_TOOL_TIP_TEXT = "tool-tip-text";
protected static final String PROPERTY_IMAGE = "image";
protected static final String ASSOCIATION_IS_VISIBLE = "is-visible";
protected static final String ASSOCIATION_TOOL_TIP_TEXT = "tool-tip-text";
protected static final String ASSOCIATION_IMAGE = "image";
private static final String LINK_TARGET_IS_VISIBLE = "is-visible";
private static final String LINK_TARGET_TOOL_TIP_TEXT = "tool-tip-text";
protected static final String COMPONENT_MENU_FLOATING = "menu-floating";
protected static final String COMPONENT_VALUE_HOLDER = "value-holder";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
static {
linkMap.put(LINK_TARGET_IS_VISIBLE, "LINK_TARGET_IS_VISIBLE");
linkMap.put(LINK_TARGET_TOOL_TIP_TEXT, "LINK_TARGET_TOOL_TIP_TEXT");
}//static//
/**
* TrayItemBuilder constructor.
*/
public TrayItemBuilder() {
}//TrayItemBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
Object isVisible = (Object) data.getPropertyValue(PROPERTY_IS_VISIBLE);
Object toolTipText = (Object) data.getPropertyValue(PROPERTY_TOOL_TIP_TEXT);
Object image = (Object) data.getPropertyValue(PROPERTY_IMAGE);
IComponentData floatingMenu = data.getComponent(COMPONENT_MENU_FLOATING, true);
IList valueHolders = new LiteList(10, 20);
IIterator valueHolderIterator = null;
//Search for all value holders.//
data.getComponents(valueHolders, COMPONENT_VALUE_HOLDER, true);
valueHolderIterator = valueHolders.iterator();
//Call the initialize method on the contained value holders.//
while(valueHolderIterator.hasNext()) {
IComponentData next = (IComponentData) valueHolderIterator.next();
String initializeMethodName = viewBuilder.addInitializeComponentMethod(next, "com.foundation.view.IAbstractContainer");
buffer.append('\t');
buffer.append(initializeMethodName);
buffer.append('(');
buffer.append(variableName);
buffer.append(");\r\n");
}//while//
if(isVisible != null) {
if(isVisible instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultIsVisible(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) isVisible).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultIsVisible(" + ((Boolean) isVisible).booleanValue() + ");\r\n");
}//else//
}//if//
if(toolTipText != null) {
if(toolTipText instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultToolTipText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) toolTipText).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultToolTipText(\"" + toolTipText + "\");\r\n");
}//else//
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IS_VISIBLE, variableName, "setIsVisibleAssociation", "ASSOCIATION_IS_VISIBLE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_TOOL_TIP_TEXT, variableName, "setToolTipTextAssociation", "ASSOCIATION_TOOL_TIP_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_IMAGE, variableName, "setImageAssociation", "ASSOCIATION_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
if(image != null) {
if(image instanceof ResourceReference) {
buffer.append("\t" + variableName + ".setDefaultImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) image).getResourceUrl() + "\"));\r\n");
}//if//
else {
buffer.append("\t" + variableName + ".setDefaultImage(new " + JefImage.class.getName() + "(\"" + image + "\"));\r\n");
}//else//
}//if//
if(floatingMenu != null) {
String initializeMethodName = viewBuilder.addInitializeMenuMethod(data, 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 void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.TrayItem";
}//getComponentClassName()//
/**
* Gets the platform specific name of the container class.
* @return The qualified name of the container class.
*/
public String getContainerClassName() {
return "com.foundation.view.swt.Container";
}//getContainerClassName()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition.ComponentData)
*/
public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData data) {
String componentName = viewBuilder.addComponentNameIdentifier(data.getDocumentElement(), viewBuilder.getComponentName(data));
constructor.append("/**\r\n");
constructor.append(" * ");
constructor.append(className);
constructor.append(" constructor.\r\n");
constructor.append(" * @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.\r\n");
constructor.append(" */\r\n");
constructor.append("public ");
constructor.append(className);
constructor.append("(");
constructor.append(ViewController.class.getName());
constructor.append(" controller) {\r\n");
constructor.append("\tsuper(");
appendComponentConstructorParameters(viewBuilder, constructor, data, "controller.getContext()", componentName);
constructor.append(");\r\n\r\n");
constructor.append("\tsetController(controller);\r\n");
constructor.append("}//" + className + "()//\r\n");
}//buildConstructors()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//TrayItemBuilder//

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2005,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.common.util.IHashMap;
import com.common.util.LiteHashMap;
import com.foundation.view.builder.IViewSourceBuilder;
import com.foundation.view.definition.IComponentData;
public abstract class TreeComponentBuilder extends CollectionComponentBuilder {
protected static final IHashMap styleMap = new LiteHashMap(CollectionComponentBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(CollectionComponentBuilder.linkMap);
/**
* TreeComponentBuilder constructor.
*/
public TreeComponentBuilder() {
super();
}//TreeComponentBuilder()//
/* (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) {
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//TreeComponentBuilder//

View File

@@ -0,0 +1,76 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class ValueHolderBuilder extends AbstractBuilder {
protected static final String PROPERTY_TYPE = "type";
protected static final String PROPERTY_IGNORE_WARNINGS = "ignore-warnings";
protected static final String ASSOCIATION_PARENT = "parent";
private static final IHashMap styleMap = new LiteHashMap(0);
private static final IHashMap linkMap = new LiteHashMap(0);
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
String controlIdentifier = viewBuilder.addComponentNameIdentifier(data.getDocumentElement(), viewBuilder.getComponentName(data));
String type = (String) data.getPropertyValue(PROPERTY_TYPE);
buffer.append('\t');
buffer.append(variableName);
buffer.append(" = new ");
buffer.append(getComponentClassName());
buffer.append("(parent, ");
buffer.append(controlIdentifier);
buffer.append(", ");
buffer.append(type);
buffer.append(".class);\r\n");
appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationHead()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder2.ComponentBuilder#appendInitializationBody(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, com.foundation.view.definition2.ComponentData, java.lang.String)
*/
public void appendInitializationBody(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data, String variableName) {
Boolean ignoreWarnings = (Boolean) data.getPropertyValue(PROPERTY_IGNORE_WARNINGS);
if(ignoreWarnings != null) {
buffer.append("\t" + variableName + ".ignoreWarnings(" + ignoreWarnings.toString() + ");\r\n");
}//if//
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_PARENT, variableName, "setParentAssociation", "ASSOCIATION_PARENT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
}//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 void appendLinks(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData componentData, String variableName) {
}//appendLinks()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.ValueHolder";
}//getComponentClassName()//
}//ValueHolderBuilder//

View File

@@ -0,0 +1,100 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.controller.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class WindowBuilder extends FrameBuilder {
protected static final String STYLE_MODELESS = "modeless";
protected static final String STYLE_PRIMARY_MODAL = "primary modal";
protected static final String STYLE_APPLICATION_MODAL = "application modal";
protected static final String STYLE_SYSTEM_MODAL = "system modal";
protected static final IHashMap styleMap = new LiteHashMap(FrameBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(FrameBuilder.linkMap);
static {
styleMap.put(STYLE_MODELESS, "STYLE_MODELESS");
styleMap.put(STYLE_PRIMARY_MODAL, "STYLE_PRIMARY_MODAL");
styleMap.put(STYLE_APPLICATION_MODAL, "STYLE_APPLICATION_MODAL");
styleMap.put(STYLE_SYSTEM_MODAL, "STYLE_SYSTEM_MODAL");
}//static//
/**
* Window constructor.
*/
public WindowBuilder() {
super();
}//WindowBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Window";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition2.ComponentData)
*/
public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData data) {
String componentName = viewBuilder.addComponentNameIdentifier(data.getDocumentElement(), viewBuilder.getComponentName(data));
constructor.append("/**\r\n");
constructor.append(" * ");
constructor.append(className);
constructor.append(" constructor.\r\n");
constructor.append(" * @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.\r\n");
constructor.append(" */\r\n");
constructor.append("public ");
constructor.append(className);
constructor.append("(");
constructor.append(ViewController.class.getName());
constructor.append(" controller) {\r\n");
constructor.append("\tsuper(");
appendComponentConstructorParameters(viewBuilder, constructor, data, "(" + ViewController.class.getName() + ") controller.getParent()", componentName);
constructor.append(", controller.getContext(), controller");
constructor.append(");\r\n\r\n");
//constructor.append("\tsetController(controller);\r\n");
constructor.append("}//" + className + "()//\r\n");
}//buildConstructors()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//WindowBuilder//

View File

@@ -0,0 +1,95 @@
/*
* Copyright (c) 2003,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.common.util.*;
import com.foundation.view.builder.*;
import com.foundation.view.definition.*;
public class WizardBuilder extends ContainerBuilder {
protected static final String ATTRIBUTE_PAGE = "page";
protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap);
protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap);
/**
* WizardBuilder constructor.
*/
public WizardBuilder() {
super();
}//WizardBuilder()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#appendInitializationHead(com.foundation.view.builder.IViewSourceBuilder, StringBuffer, ComponentData)
*/
public void appendInitializationHead(IViewSourceBuilder viewBuilder, StringBuffer buffer, IComponentData data) {
String variableName = viewBuilder.getComponentAttributeName(data);
//Write out the constructor here only if this is not the primary component for the view.//
if(!viewBuilder.getPrimaryComponent().equals(data)) {
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
appendComponentConstructorParameters(viewBuilder, buffer, data, "parent");
buffer.append(");\r\n");
buffer.append("\t\r\n");
}//if//
appendInitializationBody(viewBuilder, buffer, data, 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) {
IAttributePart pageAttribute = (IAttributePart) data.getAttribute(ATTRIBUTE_PAGE);
if((pageAttribute != null) && (pageAttribute.getName() != null)) {
String associationIdentifier = viewBuilder.addAttributeAssociationIdentifier(data.getDocumentElement(), variableName, ATTRIBUTE_PAGE);
viewBuilder.addDirectAttributeHandler(data, associationIdentifier, pageAttribute, Integer.class.getName(), IViewSourceBuilder.ACCESS_TYPE_BOTH);
buffer.append("\t");
buffer.append(variableName);
buffer.append(".setPageAttribute(");
viewBuilder.appendAttributeAssociation(buffer, variableName, pageAttribute, associationIdentifier);
buffer.append(");\r\n");
}//if//
IIterator iterator = null;
ICollection components = new com.common.util.LiteList(5,10);
IComponentData next = null;
String nextName = null;
int index = 0;
data.getComponents(components, "component", true);
iterator = components.iterator();
while(iterator.hasNext()) {
next = (IComponentData) iterator.next();
nextName = viewBuilder.getComponentName(next);
viewBuilder.addPublicIdentifier(next.getDocumentElement(), "WIZARD_PAGE_" + nextName, new Integer(index), false);
viewBuilder.addPublicIdentifier(next.getDocumentElement(), "WIZARD_PAGE_" + nextName + "INT", new Integer(index), true);
index++;
}//while//
super.appendInitializationBody(viewBuilder, buffer, data, variableName);
}//appendInitializationBody()//
/* (non-Javadoc)
* @see com.foundation.view.builder.IBuilder#getComponentClassName()
*/
public String getComponentClassName() {
return "com.foundation.view.swt.Wizard";
}//getComponentClassName()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getStyleMap()
*/
public IHashMap getStyleMap() {
return styleMap;
}//getStyleMap()//
/* (non-Javadoc)
* @see com.foundation.view.swt.builder.AbstractBuilder#getLinkMap()
*/
public IHashMap getLinkMap() {
return linkMap;
}//getLinkMap()//
}//WizardBuilder//

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

View File

@@ -0,0 +1,22 @@
<type name="tool-item-drop-color" extends="tool-item-abstract" inherit-styles="true">
<builder jar="tool-item.jar">
<thin-swt class="com.foundation.tcv.swt.builder.ToolItemBuilder"/>
<thick-swt class="com.foundation.view.swt.builder.ToolItemBuilder"/>
</builder>
<style name="drop down"/>
<property name="name" type="string" required="false"/>
<property name="width" type="positive-integer" required="false"/>
<property name="text" type="string" required="false"/>
<property name="image" type="string" required="false"/>
<association function="text" is-multi="false" unique-row-type="true" getter="required" setter="none" data-type="java.lang.String" row-type="none"/>
<association function="image" is-multi="false" unique-row-type="true" getter="required" setter="none" data-type="com.foundation.view.JefImage" row-type="none"/>
<component type="component" required="true" mulitple="false"/>
<link-target function="text" data="java.lang.String"/>
<link-target function="image" data="com.foundation.view.JefImage"/>
</type>