501 lines
25 KiB
Java
501 lines
25 KiB
Java
/*
|
|
* Copyright (c) 2005,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.IHashMap;
|
|
import com.common.util.IList;
|
|
import com.common.util.LiteHashMap;
|
|
import com.common.util.LiteList;
|
|
import com.foundation.view.JefColor;
|
|
import com.foundation.view.JefFont;
|
|
import com.foundation.view.JefImage;
|
|
import com.foundation.view.builder.IViewSourceBuilder;
|
|
import com.foundation.view.builder.ViewBuilderException;
|
|
import com.foundation.view.definition.IEventPart;
|
|
import com.foundation.view.definition.IComponentData;
|
|
import com.foundation.view.resource.ResourceReference;
|
|
|
|
public class SimpleTreeTableBuilder extends TreeComponentBuilder {
|
|
protected static final String STYLE_MULTI = "multi selection";
|
|
protected static final String STYLE_SINGLE = "single selection";
|
|
protected static final String STYLE_CHECK = "check";
|
|
protected static final String STYLE_FULL_SELECTION = "full selection";
|
|
protected static final String STYLE_HIDE_SELECTION = "hide selection";
|
|
protected static final String STYLE_VIRTUAL = "virtual";
|
|
|
|
//protected static final String PROPERTY_IN_VIEW_SORTING = "view-sorting";
|
|
protected static final String PROPERTY_SHOW_HEADERS = "show-headers";
|
|
protected static final String PROPERTY_SHOW_GRID_LINES = "show-grid-lines";
|
|
protected static final String PROPERTY_SELECT_ON_OPEN = "select-on-open";
|
|
protected static final String PROPERTY_AUTO_FIT = "auto-fit";
|
|
protected static final String PROPERTY_FILL_ON_INITIALIZE = "fill-on-initialize";
|
|
protected static final String PROPERTY_FILL_ON_RESIZE = "fill-on-resize";
|
|
protected static final String PROPERTY_ROW_BACKGROUND_COLOR = "row-background-color";
|
|
protected static final String PROPERTY_ROW_FOREGROUND_COLOR = "row-foreground-color";
|
|
protected static final String PROPERTY_ROW_FONT = "row-font";
|
|
protected static final String PROPERTY_ROW_HEIGHT = "row-height";
|
|
protected static final String ASSOCIATION_ROW_BACKGROUND_COLOR = "row-background-color";
|
|
protected static final String ASSOCIATION_ROW_FOREGROUND_COLOR = "row-foreground-color";
|
|
protected static final String ASSOCIATION_ROW_FONT = "row-font";
|
|
protected static final String ASSOCIATION_ROW_HEIGHT = "row-height";
|
|
protected static final String EVENT_FIT = "fit";
|
|
protected static final String EVENT_FILL = "fill";
|
|
|
|
private static final String LINK_TARGET_FIT = "fit";
|
|
private static final String LINK_TARGET_FILL = "fill";
|
|
|
|
/** Used to hold column data which make up the columns of the table. */
|
|
protected static final String COMPONENT_COLUMNS = "columns";
|
|
/** Used to provide metadata for a specific column. */
|
|
protected static final String COMPONENT_COLUMN = "column";
|
|
/** Used to collect display types. */
|
|
protected static final String COMPONENT_DISPLAY_SET = "display-set";
|
|
/** The base type for the component and renderer display containers. */
|
|
protected static final String COMPONENT_DISPLAY_ABSTRACT = "display-abstract";
|
|
/** An extension of display-abstract which encapsulates a component. */
|
|
protected static final String COMPONENT_DISPLAY_COMPONENT = "display-component";
|
|
/** An extension of display-abstract which encapsulates a renderer. */
|
|
protected static final String COMPONENT_DISPLAY_RENDERER= "display-renderer";
|
|
/** Used to specify a component that replaces or augments cell values. */
|
|
protected static final String COMPONENT_CELL_COMPONENT = "cell-component";
|
|
/** Used to specify a renderer that replaces or augments cell values. */
|
|
protected static final String COMPONENT_CELL_RENDERER = "cell-renderer";
|
|
|
|
//Column identifiers.//
|
|
protected static final String PROPERTY_COLUMN_HEADER_TEXT = "header-text";
|
|
protected static final String PROPERTY_COLUMN_HEADER_IMAGE = "header-image";
|
|
protected static final String PROPERTY_COLUMN_RESIZEABLE = "resizable";
|
|
protected static final String PROPERTY_COLUMN_ALIGNMENT = "alignment";
|
|
protected static final String PROPERTY_COLUMN_WIDTH = "width";
|
|
protected static final String PROPERTY_COLUMN_MINIMUM_WIDTH = "minimum-width";
|
|
protected static final String PROPERTY_COLUMN_TOOL_TIP_TEXT = "tool-tip-text";
|
|
protected static final String PROPERTY_COLUMN_MOVEABLE = "moveable";
|
|
protected static final String PROPERTY_COLUMN_CELL_TEXT = "cell-text";
|
|
protected static final String PROPERTY_COLUMN_CELL_IMAGE = "cell-image";
|
|
protected static final String PROPERTY_COLUMN_CELL_BACKGROUND_COLOR = "cell-background-color";
|
|
protected static final String PROPERTY_COLUMN_CELL_FOREGROUND_COLOR = "cell-foreground-color";
|
|
protected static final String PROPERTY_COLUMN_CELL_FONT = "cell-font";
|
|
|
|
protected static final String ASSOCIATION_COLUMN_HEADER_TEXT = "header-text";
|
|
protected static final String ASSOCIATION_COLUMN_HEADER_IMAGE = "header-image";
|
|
|
|
protected static final String ASSOCIATION_COLUMN_CELL_TEXT = "cell-text";
|
|
protected static final String ASSOCIATION_COLUMN_CELL_IMAGE = "cell-image";
|
|
protected static final String ASSOCIATION_COLUMN_CELL_BACKGROUND_COLOR = "cell-background-color";
|
|
protected static final String ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR = "cell-foreground-color";
|
|
protected static final String ASSOCIATION_COLUMN_CELL_FONT = "cell-font";
|
|
protected static final String ASSOCIATION_CHILDREN = "children";
|
|
protected static final String ASSOCIATION_GROUPING = "grouping";
|
|
|
|
protected static final String PROPERTY_CELL_DISPLAY_TYPE = "row-type";
|
|
|
|
protected static final IHashMap styleMap = new LiteHashMap(TreeComponentBuilder.styleMap);
|
|
protected static final IHashMap linkMap = new LiteHashMap(TreeComponentBuilder.linkMap);
|
|
|
|
static {
|
|
styleMap.put(STYLE_MULTI, "STYLE_MULTI");
|
|
styleMap.put(STYLE_SINGLE, "STYLE_SINGLE");
|
|
styleMap.put(STYLE_FULL_SELECTION, "FULL_SELECTION");
|
|
styleMap.put(STYLE_HIDE_SELECTION, "STYLE_HIDE_SELECTION");
|
|
/* Not yet supported.
|
|
styleMap.put(STYLE_CHECK, "STYLE_CHECK");
|
|
styleMap.put(STYLE_VIRTUAL, "STYLE_VIRTUAL");
|
|
*/
|
|
|
|
linkMap.put(LINK_TARGET_FIT, "LINK_TARGET_FIT");
|
|
linkMap.put(LINK_TARGET_FILL, "LINK_TARGET_FILL");
|
|
}//static//
|
|
/**
|
|
* SimpleTreeTableBuilder constructor.
|
|
*/
|
|
public SimpleTreeTableBuilder() {
|
|
super();
|
|
}//SimpleTreeTableBuilder()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.swt.builder.CollectionComponentBuilder#allowMultiSelection(com.foundation.view.definition.ComponentData)
|
|
*/
|
|
public boolean allowMultiSelection(IComponentData data) {
|
|
return false;
|
|
}//allowMultiSelection()//
|
|
/* (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 componentData) {
|
|
String variableName = viewBuilder.getComponentAttributeName(componentData);
|
|
|
|
buffer.append("\t" + variableName + " = new " + getComponentClassName() + "(");
|
|
appendComponentConstructorParameters(viewBuilder, buffer, componentData, "parent");
|
|
buffer.append(");\r\n");
|
|
buffer.append("\t\r\n");
|
|
|
|
appendInitializationBody(viewBuilder, buffer, componentData, 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 inViewSortingProperty = (Boolean) data.getPropertyValue(PROPERTY_IN_VIEW_SORTING);
|
|
Boolean showHeadersProperty = (Boolean) data.getPropertyValue(PROPERTY_SHOW_HEADERS);
|
|
Boolean showGridLinesProperty = (Boolean) data.getPropertyValue(PROPERTY_SHOW_GRID_LINES);
|
|
Boolean setSelectOnOpen = (Boolean) data.getPropertyValue(PROPERTY_SELECT_ON_OPEN);
|
|
Boolean autoFit = (Boolean) data.getPropertyValue(PROPERTY_AUTO_FIT);
|
|
Boolean fillOnInitialize = (Boolean) data.getPropertyValue(PROPERTY_FILL_ON_INITIALIZE);
|
|
Boolean fillOnResize = (Boolean) data.getPropertyValue(PROPERTY_FILL_ON_RESIZE);
|
|
Object rowBackgroundColor = (Object) data.getPropertyValue(PROPERTY_ROW_BACKGROUND_COLOR);
|
|
Object rowForegroundColor = (Object) data.getPropertyValue(PROPERTY_ROW_FOREGROUND_COLOR);
|
|
Object rowFont = (Object) data.getPropertyValue(PROPERTY_ROW_FONT);
|
|
Integer rowHeight = (Integer) data.getPropertyValue(PROPERTY_ROW_HEIGHT);
|
|
IList fitEvents = data.getEvents(EVENT_FIT);
|
|
IList fillEvents = data.getEvents(EVENT_FILL);
|
|
IComponentData columns = data.getComponent(COMPONENT_COLUMNS, false);
|
|
IList columnData = new LiteList(10, 20);
|
|
|
|
//if(inViewSortingProperty != null) {
|
|
// buffer.append("\t" + variableName + ".setInViewSorting(" + inViewSortingProperty + ");\r\n");
|
|
//}//if//
|
|
|
|
if(showHeadersProperty != null) {
|
|
buffer.append("\t" + variableName + ".showHeaders(" + showHeadersProperty + ");\r\n");
|
|
}//if//
|
|
|
|
if(showGridLinesProperty != null) {
|
|
buffer.append("\t" + variableName + ".showGridLines(" + showGridLinesProperty + ");\r\n");
|
|
}//if//
|
|
|
|
if(setSelectOnOpen != null) {
|
|
buffer.append("\t" + variableName + ".setSelectOnOpen(" + setSelectOnOpen + ");\r\n");
|
|
}//if//
|
|
|
|
if(autoFit != null) {
|
|
buffer.append("\t" + variableName + ".setAutoFit(" + autoFit + ");\r\n");
|
|
}//if//
|
|
|
|
if(fillOnInitialize != null) {
|
|
buffer.append("\t" + variableName + ".setFillOnInitialize(" + fillOnInitialize + ");\r\n");
|
|
}//if//
|
|
|
|
if(fillOnResize != null) {
|
|
buffer.append("\t" + variableName + ".setFillOnResize(" + fillOnResize + ");\r\n");
|
|
}//if//
|
|
|
|
if(rowBackgroundColor != null) {
|
|
if(rowBackgroundColor instanceof ResourceReference) {
|
|
buffer.append("\t" + variableName + ".setRowBackgroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowBackgroundColor).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + variableName + ".setRowBackgroundColor(new " + JefColor.class.getName() + "(\"" + rowBackgroundColor + "\"));\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(rowForegroundColor != null) {
|
|
if(rowForegroundColor instanceof ResourceReference) {
|
|
buffer.append("\t" + variableName + ".setRowForegroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowForegroundColor).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + variableName + ".setRowForegroundColor(new " + JefColor.class.getName() + "(\"" + rowForegroundColor + "\"));\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(rowFont != null) {
|
|
if(rowFont instanceof ResourceReference) {
|
|
buffer.append("\t" + variableName + ".setRowFont(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) rowFont).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + variableName + ".setRowFont(" + JefFont.class.getName() + ".getJefFonts(\"" + JefFont.getJefFontsString((JefFont[]) rowFont) + "\"));\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(rowHeight != null) {
|
|
buffer.append("\t" + variableName + ".setRowHeight(new Integer(" + rowHeight + "));\r\n");
|
|
}//if//
|
|
|
|
appendCollectionAssociation(viewBuilder, buffer, data, ASSOCIATION_CHILDREN, variableName, "setChildAssociation", "ASSOCIATION_CHILDREN");
|
|
appendCollectionAssociation(viewBuilder, buffer, data, ASSOCIATION_GROUPING, variableName, "setGroupAssociation", "ASSOCIATION_GROUPING");
|
|
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_BACKGROUND_COLOR, variableName, "setRowBackgroundColorAssociation", "ASSOCIATION_ROW_BACKGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_FOREGROUND_COLOR, variableName, "setRowForegroundColorAssociation", "ASSOCIATION_ROW_FOREGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_FONT, variableName, "setRowFontAssociation", "ASSOCIATION_ROW_FONT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, data, ASSOCIATION_ROW_HEIGHT, variableName, "setRowHeightAssociation", "ASSOCIATION_ROW_HEIGHT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
|
|
if(fitEvents != null) {
|
|
for(int index = 0; index < fitEvents.getSize(); index++) {
|
|
IEventPart eventPart = (IEventPart) fitEvents.get(index);
|
|
|
|
buffer.append("\t");
|
|
buffer.append(variableName);
|
|
buffer.append(".addFitEventAssociation(");
|
|
viewBuilder.appendEventAssociation(buffer, variableName, eventPart);
|
|
buffer.append(");\r\n");
|
|
}//for//
|
|
}//if//
|
|
|
|
if(fillEvents != null) {
|
|
for(int index = 0; index < fillEvents.getSize(); index++) {
|
|
IEventPart eventPart = (IEventPart) fillEvents.get(index);
|
|
|
|
buffer.append("\t");
|
|
buffer.append(variableName);
|
|
buffer.append(".addFillEventAssociation(");
|
|
viewBuilder.appendEventAssociation(buffer, variableName, eventPart);
|
|
buffer.append(");\r\n");
|
|
}//for//
|
|
}//if//
|
|
|
|
if(columns != null) {
|
|
columns.getComponents(columnData, COMPONENT_COLUMN, true);
|
|
|
|
//Add the data for all the columns.//
|
|
for(int columnIndex = 0; columnIndex < columnData.getSize(); columnIndex++) {
|
|
String columnId = variableName + "ColumnPart" + columnIndex;
|
|
IComponentData column = (IComponentData) columnData.get(columnIndex);
|
|
Object headerTextProperty = (Object) column.getPropertyValue(PROPERTY_COLUMN_HEADER_TEXT);
|
|
Object headerImageProperty = (Object) column.getPropertyValue(PROPERTY_COLUMN_HEADER_IMAGE);
|
|
Object columnToolTipProperty = (Object) column.getPropertyValue(PROPERTY_COLUMN_TOOL_TIP_TEXT);
|
|
Boolean resizeableProperty = (Boolean) column.getPropertyValue(PROPERTY_COLUMN_RESIZEABLE);
|
|
Boolean moveableProperty = (Boolean) column.getPropertyValue(PROPERTY_COLUMN_MOVEABLE);
|
|
Integer widthProperty = (Integer) column.getPropertyValue(PROPERTY_COLUMN_WIDTH);
|
|
Integer minimumWidthProperty = (Integer) column.getPropertyValue(PROPERTY_COLUMN_MINIMUM_WIDTH);
|
|
String alignmentProperty = (String) column.getPropertyValue(PROPERTY_COLUMN_ALIGNMENT);
|
|
Object cellText = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_TEXT);
|
|
Object cellImage = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_IMAGE);
|
|
Object cellBackgroundColor = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_BACKGROUND_COLOR);
|
|
Object cellForegroundColor = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_FOREGROUND_COLOR);
|
|
Object cellFont = (Object) data.getPropertyValue(PROPERTY_COLUMN_CELL_FONT);
|
|
IComponentData displaySet = column.getComponent(COMPONENT_DISPLAY_SET, false);
|
|
|
|
buffer.append("\t");
|
|
buffer.append(getColumnClassName());
|
|
buffer.append(" ");
|
|
buffer.append(columnId);
|
|
buffer.append(" = ");
|
|
buffer.append(variableName);
|
|
buffer.append(".addColumn();\r\n");
|
|
|
|
if(headerTextProperty != null) {
|
|
if(headerTextProperty instanceof ResourceReference) {
|
|
buffer.append("\t" + columnId + ".setHeaderText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) headerTextProperty).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + columnId + ".setHeaderText(\"" + headerTextProperty + "\");\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(headerImageProperty != null) {
|
|
if(headerImageProperty instanceof ResourceReference) {
|
|
buffer.append("\t" + columnId + ".setHeaderImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) headerImageProperty).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + columnId + ".setHeaderImage(new " + JefImage.class.getName() + "(\"" + headerImageProperty + "\"));\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(columnToolTipProperty != null) {
|
|
if(columnToolTipProperty instanceof ResourceReference) {
|
|
buffer.append("\t" + columnId + ".setToolTipText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) columnToolTipProperty).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + columnId + ".setToolTipText(\"" + columnToolTipProperty + "\");\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(resizeableProperty != null) {
|
|
buffer.append("\t" + columnId + ".setHeaderResizeable(" + resizeableProperty + ");\r\n");
|
|
}//if//
|
|
|
|
if(moveableProperty != null) {
|
|
buffer.append("\t" + columnId + ".setMoveable(" + moveableProperty + ");\r\n");
|
|
}//if//
|
|
|
|
if(alignmentProperty != null) {
|
|
String code = alignmentProperty.equalsIgnoreCase("center") ? getSimpleTableCenterCode() : alignmentProperty.equalsIgnoreCase("right") ? getSimpleTableRightCode() : getSimpleTableLeftCode();
|
|
|
|
buffer.append("\t" + columnId + ".setAlignment(" + code + ");\r\n");
|
|
}//if//
|
|
|
|
if(widthProperty != null) {
|
|
buffer.append("\t" + columnId + ".setWidth(" + widthProperty + ");\r\n");
|
|
}//if//
|
|
|
|
if(minimumWidthProperty != null) {
|
|
buffer.append("\t" + columnId + ".setMinimumWidth(" + minimumWidthProperty + ");\r\n");
|
|
}//if//
|
|
|
|
if(cellText != null) {
|
|
if(cellText instanceof ResourceReference) {
|
|
buffer.append("\t" + columnId + ".setCellText(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellText).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + columnId + ".setCellText(\"" + cellText + "\");\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(cellImage != null) {
|
|
if(cellImage instanceof ResourceReference) {
|
|
buffer.append("\t" + columnId + ".setCellImage(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellImage).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + columnId + ".setCellImage(new " + JefImage.class.getName() + "(\"" + cellImage + "\"));\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(cellBackgroundColor != null) {
|
|
if(cellBackgroundColor instanceof ResourceReference) {
|
|
buffer.append("\t" + columnId + ".setBackgroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellBackgroundColor).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + columnId + ".setBackgroundColor(new " + JefColor.class.getName() + "(\"" + cellBackgroundColor + "\"));\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(cellForegroundColor != null) {
|
|
if(cellForegroundColor instanceof ResourceReference) {
|
|
buffer.append("\t" + columnId + ".setForegroundColor(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellForegroundColor).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + columnId + ".setForegroundColor(new " + JefColor.class.getName() + "(\"" + cellForegroundColor + "\"));\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
if(cellFont != null) {
|
|
if(cellFont instanceof ResourceReference) {
|
|
buffer.append("\t" + columnId + ".setFont(new " + ResourceReference.class.getName() + "(\"" + ((ResourceReference) cellFont).getResourceUrl() + "\"));\r\n");
|
|
}//if//
|
|
else {
|
|
buffer.append("\t" + columnId + ".setFont(" + JefFont.class.getName() + ".getJefFonts(\"" + JefFont.getJefFontsString((JefFont[]) cellFont) + "\"));\r\n");
|
|
}//else//
|
|
}//if//
|
|
|
|
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_HEADER_TEXT, columnId, "setHeaderTextAssociation", "ASSOCIATION_COLUMN_HEADER_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_HEADER_IMAGE, columnId, "setHeaderImageAssociation", "ASSOCIATION_COLUMN_HEADER_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_TEXT, columnId, "setCellTextAssociation", "ASSOCIATION_COLUMN_CELL_TEXT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_IMAGE, columnId, "setCellImageAssociation", "ASSOCIATION_COLUMN_CELL_IMAGE", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_BACKGROUND_COLOR, columnId, "setBackgroundColorAssociation", "ASSOCIATION_COLUMN_CELL_BACKGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR, columnId, "setForegroundColorAssociation", "ASSOCIATION_COLUMN_CELL_FOREGROUND_COLOR", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
appendAssociation(viewBuilder, buffer, column, ASSOCIATION_COLUMN_CELL_FONT, columnId, "setFontAssociation", "ASSOCIATION_COLUMN_CELL_FONT", IViewSourceBuilder.ACCESS_TYPE_GET_ONLY);
|
|
|
|
if(displaySet != null) {
|
|
IList cellDisplays = new LiteList(10, 20);
|
|
|
|
displaySet.getComponents(cellDisplays, COMPONENT_DISPLAY_ABSTRACT, true);
|
|
|
|
//Setup each of the cell displays for the column.//
|
|
for(int displayIndex = 0; displayIndex < cellDisplays.getSize(); displayIndex++) {
|
|
IComponentData cellDisplay = (IComponentData) cellDisplays.get(displayIndex);
|
|
|
|
if(cellDisplay.getComponentType().getName().equals(COMPONENT_DISPLAY_COMPONENT)) {
|
|
IComponentData cellComponent = cellDisplay.getComponent(COMPONENT_CELL_COMPONENT, true);
|
|
String initializeMethodName = viewBuilder.addInitializeComponentMethod(cellComponent, getComponentClassName());
|
|
String typeProperty = (String) cellDisplay.getPropertyValue(PROPERTY_CELL_DISPLAY_TYPE);
|
|
|
|
buffer.append('\t');
|
|
buffer.append(initializeMethodName);
|
|
buffer.append('(');
|
|
buffer.append(variableName);
|
|
buffer.append(");\r\n");
|
|
|
|
//Add the component to the column's cell-component set.//
|
|
buffer.append('\t');
|
|
buffer.append(columnId);
|
|
buffer.append(".addCellComponent(");
|
|
|
|
if(typeProperty != null) {
|
|
buffer.append(typeProperty);
|
|
buffer.append(".class");
|
|
}//if//
|
|
else {
|
|
buffer.append("null");
|
|
}//else//
|
|
|
|
buffer.append(", ");
|
|
buffer.append(viewBuilder.getComponentAttributeName(cellComponent));
|
|
buffer.append(");\r\n");
|
|
}//if//
|
|
else if(cellDisplay.getComponentType().getName().equals(COMPONENT_DISPLAY_RENDERER)) {
|
|
IComponentData cellRenderer = cellDisplay.getComponent(COMPONENT_CELL_RENDERER, true);
|
|
String initializeMethodName = viewBuilder.addInitializeComponentMethod(cellRenderer);
|
|
String typeProperty = (String) cellDisplay.getPropertyValue(PROPERTY_CELL_DISPLAY_TYPE);
|
|
|
|
buffer.append('\t');
|
|
buffer.append(initializeMethodName);
|
|
buffer.append('(');
|
|
buffer.append(variableName);
|
|
buffer.append(");\r\n");
|
|
|
|
//Add the component to the column's cell-component set.//
|
|
buffer.append('\t');
|
|
buffer.append(columnId);
|
|
buffer.append(".addCellRenderer(");
|
|
|
|
if(typeProperty != null) {
|
|
buffer.append(typeProperty);
|
|
buffer.append(".class");
|
|
}//if//
|
|
else {
|
|
buffer.append("null");
|
|
}//else//
|
|
|
|
buffer.append(", ");
|
|
buffer.append(viewBuilder.getComponentAttributeName(cellRenderer));
|
|
buffer.append(");\r\n");
|
|
}//else if//
|
|
else {
|
|
throw new ViewBuilderException("The display-set must contain either display-component or display-renderer types.", null);
|
|
}//else//
|
|
}//for//
|
|
}//if//
|
|
}//for//
|
|
}//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.SimpleTreeTable";
|
|
}//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()//
|
|
/**
|
|
* Gets the fully qualified class name for the column class used by the source code builder to add a column.
|
|
* @return The simple table's column class name.
|
|
*/
|
|
protected String getColumnClassName() {
|
|
return getComponentClassName() + ".ColumnData";
|
|
}//getColumnClassName()//
|
|
/**
|
|
* Gets the identifier to be used for the CENTER alignemnt identifier.
|
|
* @return The identifier code snipit identifying a center alignment.
|
|
*/
|
|
protected String getSimpleTableCenterCode() {
|
|
return getComponentClassName() + ".ALIGNMENT_CENTER";
|
|
}//getSimpleTableCenterCode()//
|
|
/**
|
|
* Gets the identifier to be used for the CENTER alignemnt identifier.
|
|
* @return The identifier code snipit identifying a center alignment.
|
|
*/
|
|
protected String getSimpleTableLeftCode() {
|
|
return getComponentClassName() + ".ALIGNMENT_LEFT";
|
|
}//getSimpleTableLeftCode()//
|
|
/**
|
|
* Gets the identifier to be used for the CENTER alignemnt identifier.
|
|
* @return The identifier code snipit identifying a center alignment.
|
|
*/
|
|
protected String getSimpleTableRightCode() {
|
|
return getComponentClassName() + ".ALIGNMENT_RIGHT";
|
|
}//getSimpleTableRightCode()//
|
|
}//SimpleTreeTableBuilder// |