/* * Copyright (c) 2003,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.*; import com.foundation.controller.ViewController; import com.foundation.view.IAbstractContainer; import com.foundation.view.IView; import com.foundation.view.builder.*; import com.foundation.view.definition.*; public class PanelBuilder extends ContainerBuilder { //protected static final String ATTRIBUTE_INTERNAL_VIEWS = "internal-views"; protected static final IHashMap styleMap = new LiteHashMap(ContainerBuilder.styleMap); protected static final IHashMap linkMap = new LiteHashMap(ContainerBuilder.linkMap); /** * PanelBuilder constructor. */ public PanelBuilder() { }//PanelBuilder()// /* (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) { /* AttributePart internalViewsAttribute = (AttributePart) data.getAttribute(ATTRIBUTE_INTERNAL_VIEWS); if((internalViewsAttribute != null) && (internalViewsAttribute.getName() != null)) { String associationIdentifier = viewBuilder.addAttributeAssociationIdentifier(variableName, ATTRIBUTE_INTERNAL_VIEWS); viewBuilder.addDirectAttributeHandler(data, associationIdentifier, internalViewsAttribute, ICollection.class.getName(), IViewSourceBuilder.ATTRIBUTE_TYPE_GET_ONLY); buffer.append("\t"); buffer.append(variableName); buffer.append(".setInternalViewsAttribute("); viewBuilder.appendAttributeAssociation(buffer, variableName, internalViewsAttribute, associationIdentifier); buffer.append(");\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(ViewController.class.getName()); constructor.append(" controller, "); constructor.append(IView.class.getName()); constructor.append(" parentComponent) {\r\n"); constructor.append("\tsuper(("); constructor.append(IAbstractContainer.class.getName()); 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.view.swt.Panel"; }//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()// }//PanelBuilder//