/* * Copyright (c) 2007,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.tcv.swt.builder; import com.common.util.IHashMap; import com.common.util.LiteHashMap; import com.foundation.controller.RemoteViewController; import com.foundation.view.IView; import com.foundation.view.builder.IViewSourceBuilder; import com.foundation.view.definition.IComponentData; import com.foundation.view.swt.builder.ContainerBuilder; public class ViewContainerBuilder extends ContainerBuilder { protected static final String PROPERTY_CONTROLLER_CLASS_NAME = "controller-class-name"; protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap); protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap); /** * ViewContainerBuilder constructor. */ public ViewContainerBuilder() { super(); }//ViewContainerBuilder()// /* (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); //Write out the constructor here only if this is not the primary component for the view.// if(!viewBuilder.getPrimaryComponent().equals(data)) { buffer.append("\t" + variableName + " = new " + getComponentClassName() + "("); appendComponentConstructorParameters(viewBuilder, buffer, data, "parent"); buffer.append(");\r\n"); buffer.append("\t\r\n"); }//if// 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 controllerClassName = (String) data.getPropertyValue(PROPERTY_CONTROLLER_CLASS_NAME); if(controllerClassName != null) { buffer.append("\t" + variableName + ".setControllerClassName(\"" + controllerClassName + "\");\r\n"); }//if// super.appendInitializationBody(viewBuilder, buffer, data, variableName); }//appendInitializationBody()// /* (non-Javadoc) * @see com.foundation.view.builder.IBuilder#buildConstructors(com.foundation.view.builder.IViewSourceBuilder, java.lang.StringBuffer, java.lang.String, com.foundation.view.definition.ComponentData) */ public void buildConstructors(IViewSourceBuilder viewBuilder, StringBuffer constructor, String className, IComponentData data) { String componentName = viewBuilder.addComponentNameIdentifier(data.getDocumentElement(), viewBuilder.getComponentName(data)); constructor.append("/**\r\n"); constructor.append(" * "); constructor.append(className); constructor.append(" constructor.\r\n"); constructor.append(" * @param controller The view controller which will be assigned to the value holder(s) that don't depend on another value holder for their value.\r\n"); constructor.append(" * @param parentComponent The non-null parent view component which this frame will be contained in.\r\n"); constructor.append(" */\r\n"); constructor.append("public "); constructor.append(className); constructor.append("("); constructor.append(RemoteViewController.class.getName()); constructor.append(" controller, "); constructor.append(IView.class.getName()); constructor.append(" parentComponent) {\r\n"); constructor.append("\tsuper(("); constructor.append("com.foundation.tcv.swt.server.Container"); constructor.append(") parentComponent, "); appendComponentConstructorParameters(viewBuilder, constructor, data, null, componentName); constructor.append(");\r\n\r\n"); constructor.append("\tsetController(controller);\r\n"); constructor.append("}//" + className + "()//\r\n"); }//buildConstructors()// /* (non-Javadoc) * @see com.foundation.view.builder.IBuilder#getComponentClassName() */ public String getComponentClassName() { return "com.foundation.tcv.swt.server.ViewContainer"; }//getComponentClassName()// /* (non-Javadoc) * @see com.foundation.view.builder.IBuilder#getPrimaryInitializationMethodName() */ public String getPrimaryInitializationMethodName() { return "internalViewInitialize"; }//getPrimaryInitializationMethodName()// /* (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()// }//ViewContainerBuilder//