86 lines
3.7 KiB
Java
86 lines
3.7 KiB
Java
/*
|
|
* 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// |