93 lines
3.9 KiB
Java
93 lines
3.9 KiB
Java
/*
|
|
* 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// |