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