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