103 lines
4.3 KiB
Java
103 lines
4.3 KiB
Java
|
|
/*
|
||
|
|
* 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//
|