1177 lines
47 KiB
Java
1177 lines
47 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.tcv.swt.server;
|
|
|
|
import com.common.util.ICollection;
|
|
import com.common.util.IHashSet;
|
|
import com.common.util.IIterator;
|
|
import com.common.util.IList;
|
|
import com.common.util.LiteHashSet;
|
|
import com.common.util.LiteList;
|
|
import com.foundation.controller.DecorationManager;
|
|
import com.foundation.tcv.swt.server.TableComponent.AbstractColumn;
|
|
import com.foundation.tcv.swt.server.cell.CellComponent;
|
|
import com.foundation.tcv.view.ViewMessage;
|
|
import com.foundation.view.*;
|
|
import com.foundation.view.resource.AbstractResourceService;
|
|
import com.foundation.view.resource.ResourceReference;
|
|
|
|
/*
|
|
* A base class for table or table like controls which have multiple columns or categories of data and a list or collection of model objects representing rows.
|
|
*/
|
|
public class SimpleTable extends TableComponent implements com.foundation.tcv.swt.ISimpleTable {
|
|
/** The background color resource for the column. */
|
|
private MultiResourceAssociation rowBackgroundColor = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_COLOR, false, null);
|
|
/** The foreground color resource for the column. */
|
|
private MultiResourceAssociation rowForegroundColor = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_COLOR, false, null);
|
|
/** The font resource for the column. */
|
|
private MultiResourceAssociation rowFont = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_FONT, false, null);
|
|
/** The events associations that resize all non-auto-fit columns to fit the size of the data in the column. */
|
|
private IHashSet fitEventAssociations = null;
|
|
/** The event associations resize all auto-fill columns to fill empty space in the control. This never makes columns smaller. */
|
|
private IHashSet fillEventAssociations = null;
|
|
/** Whether resizeable columns will be called upon to fit the control's client space when the control resizes or a column resizes. */
|
|
private boolean autoFit = false;
|
|
/** Whether resizeable columns will be streched to fill available space during the control's initialization. */
|
|
private boolean fillOnInitialize = false;
|
|
/** Whether resizeable columns will be streched to fill available space after the control is resized. */
|
|
private boolean fillOnResize = false;
|
|
/** Track the last synchronized top index. */
|
|
private Integer currentTopIndex = new Integer(0);
|
|
/** Whether the sorting is managed by the view versus the model. */
|
|
private boolean inViewSorting = true;
|
|
/** Whether to show the header. */
|
|
private boolean showHeader = true;
|
|
/** Whether to show the grid lines. */
|
|
private boolean showGridLines = false;
|
|
|
|
public static class Renderer {
|
|
public Class type = null;
|
|
public CellComponent component = null;
|
|
|
|
public Renderer(Class type, CellComponent component) {
|
|
this.type = type;
|
|
this.component = component;
|
|
}//Renderer()//
|
|
}//Renderer//
|
|
|
|
/**
|
|
* Encapsulates all the data pertaining to a single column in the table component.
|
|
*/
|
|
public class ColumnData extends AbstractColumn {
|
|
/** The zero based index of this column in the set of columns. Note that this is not display order, just an identifier. */
|
|
private int index = 0;
|
|
/** The text resource for the column. */
|
|
private SingleResourceAssociation headerText = new SingleResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_TEXT, false, "");
|
|
/** The image resource for the column. */
|
|
private SingleResourceAssociation headerImage = new SingleResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_IMAGE, false, null);
|
|
/** The text resource for the cell. */
|
|
private MultiResourceAssociation cellText = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_TEXT, false, null);
|
|
/** The image resource for the cell. */
|
|
private MultiResourceAssociation cellImage = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_IMAGE, false, null);
|
|
/** The background color resource for the cell. */
|
|
private MultiResourceAssociation backgroundColor = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_COLOR, false, null);
|
|
/** The foreground color resource for the cell. */
|
|
private MultiResourceAssociation foregroundColor = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_COLOR, false, null);
|
|
/** The font resource for the cell. */
|
|
private MultiResourceAssociation font = new MultiResourceAssociation(this, this, getViewContext(), ResourceAssociation.TYPE_FONT, false, null);
|
|
/** Whether the column header is resizable. */
|
|
private boolean headerResizable = false;
|
|
/** The alginment of the column data. */
|
|
private int alignment = ALIGNMENT_LEFT;
|
|
/** The width of the column. */
|
|
private int width = 100;
|
|
/** The tool tip text for the column (String or ResourceReference). */
|
|
private Object toolTipText = null;
|
|
/** Whether the column is moveable. */
|
|
private boolean moveable = true;
|
|
/** The collection of Renderer instances in the order they were specified. */
|
|
private IList renderers = null;
|
|
/** The minimum width of the column. */
|
|
private int minimumWidth = 20;
|
|
|
|
/**
|
|
* ColumnData constructor.
|
|
*/
|
|
public ColumnData(int index) {
|
|
this.index = index;
|
|
}//ColumnData()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.IAbstractComponent#verifyThread()
|
|
*/
|
|
public void verifyThread() {
|
|
SimpleTable.this.verifyThread();
|
|
}//verifyThread()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.IAbstractComponent#getName()
|
|
*/
|
|
public String getName() {
|
|
return "__Column__";
|
|
}//getName()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent.AbstractColumn#registerItem(com.foundation.tcv.swt.server.RowObject)
|
|
*/
|
|
protected void registerItem(RowObject rowObject) {
|
|
cellText.registerItem(rowObject.value, rowObject);
|
|
cellImage.registerItem(rowObject.value, rowObject);
|
|
backgroundColor.registerItem(rowObject.value, rowObject);
|
|
foregroundColor.registerItem(rowObject.value, rowObject);
|
|
font.registerItem(rowObject.value, rowObject);
|
|
}//registerItem()//
|
|
/**
|
|
* Provides the column a chance to register the item after the item is created on the client.
|
|
* @param rowObject The row being registered.
|
|
*/
|
|
protected void postRegisterItem(RowObject rowObject) {
|
|
CellComponent cellComponent = getCellComponent(rowObject.value != null ? rowObject.value.getClass() : null);
|
|
|
|
//Register the cell component if we have one. This will send updates to the client, so it must be done after the normal registration.//
|
|
if(cellComponent != null) {
|
|
cellComponent.registerRowItem(rowObject);
|
|
cellComponent.viewRefresh(rowObject);
|
|
}//if//
|
|
}//postRegisterItem()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent.AbstractColumn#unregisterItem(com.foundation.tcv.swt.server.RowObject)
|
|
*/
|
|
protected void unregisterItem(RowObject rowObject) {
|
|
CellComponent cellComponent = getCellComponent(rowObject.getClass());
|
|
|
|
cellText.unregisterItem(rowObject.value);
|
|
cellImage.unregisterItem(rowObject.value);
|
|
backgroundColor.unregisterItem(rowObject.value);
|
|
foregroundColor.unregisterItem(rowObject.value);
|
|
font.unregisterItem(rowObject.value);
|
|
|
|
if(cellComponent != null) {
|
|
cellComponent.unregisterRowItem(rowObject);
|
|
}//if//
|
|
}//unregisterItem()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent.AbstractColumn#unregisterAllItems()
|
|
*/
|
|
protected void unregisterAllItems() {
|
|
cellText.unregisterAllItems();
|
|
cellImage.unregisterAllItems();
|
|
backgroundColor.unregisterAllItems();
|
|
foregroundColor.unregisterAllItems();
|
|
font.unregisterAllItems();
|
|
|
|
if(renderers != null) {
|
|
for(int index = 0; index < renderers.getSize(); index++) {
|
|
((Renderer) renderers.get(index)).component.unregisterRowItems();
|
|
}//for//
|
|
}//if//
|
|
}//unregisterAllItems()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent.AbstractColumn#refreshCellData(com.foundation.tcv.swt.server.RowObject)
|
|
*/
|
|
protected boolean refreshCellData(RowObject rowObject) {
|
|
boolean result = false;
|
|
|
|
result |= cellText.refresh(rowObject.value);
|
|
result |= cellImage.refresh(rowObject.value);
|
|
result |= backgroundColor.refresh(rowObject.value);
|
|
result |= foregroundColor.refresh(rowObject.value);
|
|
result |= font.refresh(rowObject.value);
|
|
|
|
return result;
|
|
}//refreshCellData()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent.AbstractColumn#collectCellData(com.foundation.tcv.swt.server.RowObject, com.foundation.tcv.swt.ITableComponent.TableCellData)
|
|
*/
|
|
protected void collectCellData(RowObject rowObject, TableCellData cellData) {
|
|
CellComponent cellComponent = getCellComponent(rowObject.value != null ? rowObject.value.getClass() : null);
|
|
|
|
super.collectCellData(rowObject, cellData);
|
|
|
|
cellData.setText((String) cellText.getValue(rowObject.value));
|
|
cellData.setForegroundColor(foregroundColor.getValue(rowObject.value));
|
|
cellData.setBackgroundColor(backgroundColor.getValue(rowObject.value));
|
|
cellData.setFont(font.getValue(rowObject.value));
|
|
cellData.setImage(cellImage.getValue(rowObject.value));
|
|
|
|
if(cellComponent != null) {
|
|
//Store the cell component id.//
|
|
((SimpleTableCellData) cellData).setCellComponentId(cellComponent.getNumber());
|
|
}//if//
|
|
}//collectCellData()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent.AbstractColumn#getIndex()
|
|
*/
|
|
protected int getIndex() {
|
|
return index;
|
|
}//getIndex()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent.AbstractColumn#setIndex(int)
|
|
*/
|
|
protected void setIndex(int index) {
|
|
this.index = index;
|
|
}//setIndex()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.IAbstractComponent#getContainer()
|
|
*/
|
|
public IAbstractContainer getContainer() {
|
|
return SimpleTable.this.getContainer();
|
|
}//getContainer()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.IAbstractComponent#onEventFired(com.foundation.view.IEventAssociation, java.lang.Object[])
|
|
*/
|
|
public void onEventFired(IEventAssociation eventAssociation, Object[] eventArguments) {
|
|
}//onEventFired()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.IAbstractComponent#onValueChanged(com.foundation.view.IAttributeAssociation)
|
|
*/
|
|
public void onValueChanged(IAttributeAssociation attributeAssociation) {
|
|
}//onValueChanged()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.ISingleResourceAssociationChangeListener#addMessageHold()
|
|
*/
|
|
public void addMessageHold() {
|
|
SimpleTable.this.addMessageHold();
|
|
}//addMessageHold()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.ISingleResourceAssociationChangeListener#removeMessageHold()
|
|
*/
|
|
public void removeMessageHold() {
|
|
SimpleTable.this.removeMessageHold();
|
|
}//removeMessageHold()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.ISingleResourceAssociationChangeListener#onValueChanged(com.foundation.view.ResourceAssociation, int)
|
|
*/
|
|
public void onValueChanged(ResourceAssociation resourceAssociation, int flags) {
|
|
if(resourceAssociation instanceof SingleResourceAssociation) {
|
|
//TODO:Remove me once we verify it isn't necessary.
|
|
verifyThread();
|
|
internalOnValueChanged((SingleResourceAssociation) resourceAssociation);
|
|
}//if//
|
|
}//onValueChanged()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.IMultiResourceAssociationChangeListener#onValueChanged(com.foundation.view.ResourceAssociation, java.lang.Object, boolean)
|
|
*/
|
|
public void onValueChanged(ResourceAssociation resourceAssociation, Object item, Object data, boolean isUpdate) {
|
|
if(resourceAssociation instanceof MultiResourceAssociation) {
|
|
//TODO:Remove me once we verify it isn't necessary.
|
|
verifyThread();
|
|
internalOnValueChanged((MultiResourceAssociation) resourceAssociation, item, data, isUpdate);
|
|
}//if//
|
|
}//onValueChanged()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.ISingleResourceAssociationChangeListener#onModelExternallyChanged(com.foundation.view.ResourceAssociation, boolean, java.lang.Object)
|
|
*/
|
|
public void onModelExternallyChanged(ResourceAssociation resourceAssociation, boolean isCleared, Object originalValue) {
|
|
verifyThread();
|
|
|
|
if(isInitialized()) {
|
|
internalOnModelExternallyChanged((SingleResourceAssociation) resourceAssociation, isCleared, originalValue);
|
|
}//if//
|
|
}//onModelExternallyChanged()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.IMultiResourceAssociationChangeListener#onModelExternallyChanged(com.foundation.view.ResourceAssociation, java.lang.Object, java.lang.Object, boolean, java.lang.Object)
|
|
*/
|
|
public void onModelExternallyChanged(ResourceAssociation resourceAssociation, Object alteredItem, Object data, boolean isCleared, Object originalValue) {
|
|
verifyThread();
|
|
|
|
if(isInitialized()) {
|
|
internalOnModelExternallyChanged((MultiResourceAssociation) resourceAssociation, alteredItem, data, isCleared, originalValue);
|
|
}//if//
|
|
}//onModelExternallyChanged()//
|
|
/**
|
|
* Called by the resource association when a resource changes value.
|
|
* <p>The change in value will be because the resource context altered its set of current resources and the associated resources was in the set that was altered.</p>
|
|
* @param resourceAssociation The resource association used to register with the resource.
|
|
*/
|
|
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation) {
|
|
if(resourceAssociation == headerText) {
|
|
if(headerText.refresh()) {
|
|
sendMessage(MESSAGE_SET_COLUMN_HEADER_TEXT, headerText.getValue(), null, getIndex(), -1);
|
|
}//if//
|
|
}//if//
|
|
else if(resourceAssociation == headerImage) {
|
|
if(headerImage.refresh()) {
|
|
sendMessage(MESSAGE_SET_COLUMN_HEADER_IMAGE, headerImage.getValue(), null, getIndex(), -1);
|
|
}//if//
|
|
}//else if//
|
|
}//internalOnValueChanged()//
|
|
/**
|
|
* Called by the resource association when a resource changes value.
|
|
* <p>The change in value will be because the resource context altered its set of current resources and the associated resources was in the set that was altered.</p>
|
|
* @param resourceAssociation The resource association used to register with the resource.
|
|
* @param item The item whose value has been altered.
|
|
*/
|
|
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object item, Object data, boolean isUpdate) {
|
|
if(isInitialized()) {
|
|
if(resourceAssociation == cellText) {
|
|
//Refresh the item cell data.//
|
|
if(cellText.refresh(item)) {
|
|
if(item != null) {
|
|
sendMessage(MESSAGE_SET_CELL_TEXT, cellText.getValue(item), null, getIndex(), getRowObject(item).objectId);
|
|
}//if//
|
|
else {
|
|
//Update all cells since the association has a single value for all rows in the column.//
|
|
sendMessage(MESSAGE_SET_CELL_TEXT, cellText.getValue(null), null, getIndex(), -1);
|
|
}//else//
|
|
}//if//
|
|
}//if//
|
|
else if(resourceAssociation == cellImage) {
|
|
//Refresh the item cell data.//
|
|
if(cellImage.refresh(item)) {
|
|
if(item != null) {
|
|
sendMessage(MESSAGE_SET_CELL_IMAGE, cellImage.getValue(item), null, getIndex(), getRowObject(item).objectId);
|
|
}//if//
|
|
else {
|
|
//Update all cells since the association has a single value for all rows in the column.//
|
|
sendMessage(MESSAGE_SET_CELL_IMAGE, cellImage.getValue(null), null, getIndex(), -1);
|
|
}//else//
|
|
}//if//
|
|
}//else if//
|
|
else if(resourceAssociation == backgroundColor) {
|
|
//Refresh the item cell data.//
|
|
if(backgroundColor.refresh(item)) {
|
|
if(item != null) {
|
|
sendMessage(MESSAGE_SET_CELL_BACKGROUND_COLOR, backgroundColor.getValue(item), null, getIndex(), getRowObject(item).objectId);
|
|
}//if//
|
|
else {
|
|
//Update all cells since the association has a single value for all rows in the column.//
|
|
sendMessage(MESSAGE_SET_CELL_BACKGROUND_COLOR, backgroundColor.getValue(null), null, getIndex(), -1);
|
|
}//else//
|
|
}//if//
|
|
}//else if//
|
|
else if(resourceAssociation == foregroundColor) {
|
|
//Refresh the item cell data.//
|
|
if(foregroundColor.refresh(item)) {
|
|
if(item != null) {
|
|
sendMessage(MESSAGE_SET_CELL_FOREGROUND_COLOR, foregroundColor.getValue(item), null, getIndex(), getRowObject(item).objectId);
|
|
}//if//
|
|
else {
|
|
//Update all cells since the association has a single value for all rows in the column.//
|
|
sendMessage(MESSAGE_SET_CELL_FOREGROUND_COLOR, foregroundColor.getValue(null), null, getIndex(), -1);
|
|
}//else//
|
|
}//if//
|
|
}//else if//
|
|
else if(resourceAssociation == font) {
|
|
//Refresh the item cell data.//
|
|
if(font.refresh(item)) {
|
|
if(item != null) {
|
|
sendMessage(MESSAGE_SET_CELL_FONT, font.getValue(item), null, getIndex(), getRowObject(item).objectId);
|
|
}//if//
|
|
else {
|
|
//Update all cells since the association has a single value for all rows in the column.//
|
|
sendMessage(MESSAGE_SET_CELL_FONT, font.getValue(null), null, getIndex(), -1);
|
|
}//else//
|
|
}//if//
|
|
}//else if//
|
|
}//if//
|
|
}//internalOnValueChanged()//
|
|
/**
|
|
* Called by the resource association (target ONLY) when the underlying model has changed, but a user's change is overriding it.
|
|
* @param resourceAssociation The resource association used to register with the resource.
|
|
* @param alteredItem The row item for the row being altered.
|
|
* @param originalValue The original value.
|
|
*/
|
|
public void internalOnModelValueChanged(ResourceAssociation resourceAssociation, Object alteredItem, Object originalValue) {
|
|
}//internalOnModelValueChanged()//
|
|
/**
|
|
* Called by the resource association (target ONLY) when the underlying model has changed, but a user's change is overriding it.
|
|
* @param resourceAssociation The resource association used to register with the resource.
|
|
* @param originalValue The original value.
|
|
*/
|
|
public void internalOnModelValueChanged(ResourceAssociation resourceAssociation, Object originalValue) {
|
|
}//internalOnModelValueChanged()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent.AbstractColumn#initialize()
|
|
*/
|
|
protected void initialize() {
|
|
headerText.initialize();
|
|
headerImage.initialize();
|
|
cellText.initialize();
|
|
cellImage.initialize();
|
|
backgroundColor.initialize();
|
|
foregroundColor.initialize();
|
|
font.initialize();
|
|
}//initialize()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent.AbstractColumn#refresh()
|
|
*/
|
|
protected void refresh() {
|
|
//Force the header data to refresh since it gets set after sending the new header message to the client.//
|
|
if(headerText.refresh()) {
|
|
sendMessage(MESSAGE_SET_COLUMN_HEADER_TEXT, headerText.getValue(), null, getIndex(), -1);
|
|
}//if//
|
|
|
|
if(headerImage.refresh()) {
|
|
sendMessage(MESSAGE_SET_COLUMN_HEADER_IMAGE, headerImage.getValue(), null, getIndex(), -1);
|
|
}//if//
|
|
}//refresh()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent.AbstractColumn#release()
|
|
*/
|
|
protected void release() {
|
|
unregisterAllItems();
|
|
headerText.release();
|
|
headerImage.release();
|
|
cellText.release();
|
|
cellImage.release();
|
|
backgroundColor.release();
|
|
foregroundColor.release();
|
|
font.release();
|
|
}//release()//
|
|
/**
|
|
* Determines whether the column header is resizable by the user.
|
|
* @param headerResizable Whether the header is resizable.
|
|
*/
|
|
public void setHeaderResizeable(boolean headerResizable) {
|
|
if(this.headerResizable != headerResizable) {
|
|
this.headerResizable = headerResizable;
|
|
sendMessage(MESSAGE_SET_HEADER_RESIZEABLE, headerResizable ? Boolean.TRUE : Boolean.FALSE, null, index, -1);
|
|
}//if//
|
|
}//setHeadersResizeable()//
|
|
/**
|
|
* Sets the columns alignment.
|
|
* @param alignment The column's alignment
|
|
*/
|
|
public void setAlignment(int alignment) {
|
|
if(this.alignment != alignment) {
|
|
this.alignment = alignment;
|
|
sendMessage(MESSAGE_SET_COLUMN_ALIGNMENT, null, null, index, alignment);
|
|
}//if//
|
|
}//setWidth()//
|
|
/**
|
|
* Sets the column's width.
|
|
* @param width The number of pixils of width for the column.
|
|
*/
|
|
public void setWidth(int width) {
|
|
if(this.width != width) {
|
|
this.width = width;
|
|
sendMessage(MESSAGE_SET_COLUMN_WIDTH, null, null, index, width);
|
|
}//if//
|
|
}//setWidth()//
|
|
/**
|
|
* Gets the column's minimum width.
|
|
* @return The minimum number of pixels of width for the column.
|
|
*/
|
|
public int getMinimumWidth() {
|
|
return minimumWidth;
|
|
}//getMinimumWidth()//
|
|
/**
|
|
* Sets the column's minimum width.
|
|
* @param width The minimum number of pixels of width for the column.
|
|
*/
|
|
public void setMinimumWidth(int minimumWidth) {
|
|
if(this.minimumWidth != minimumWidth) {
|
|
this.minimumWidth = minimumWidth;
|
|
|
|
sendMessage(MESSAGE_SET_COLUMN_MINIMUM_WIDTH, null, null, index, minimumWidth);
|
|
}//if//
|
|
}//setMinimumWidth()//
|
|
/**
|
|
* Sets the column's tool tip text.
|
|
* @param toolTipText The tool tip for the column.
|
|
*/
|
|
public void setToolTipText(String toolTipText) {
|
|
if(this.toolTipText != toolTipText) {
|
|
this.toolTipText = toolTipText;
|
|
sendMessage(MESSAGE_SET_COLUMN_TOOL_TIP, toolTipText, null, index, -1);
|
|
}//if//
|
|
}//setToolTipText()//
|
|
/**
|
|
* Sets the column's tool tip text.
|
|
* @param toolTipText The tool tip for the column.
|
|
*/
|
|
public void setToolTipText(ResourceReference toolTipText) {
|
|
if(this.toolTipText != toolTipText) {
|
|
this.toolTipText = toolTipText;
|
|
sendMessage(MESSAGE_SET_COLUMN_TOOL_TIP, toolTipText, null, index, -1);
|
|
}//if//
|
|
}//setToolTipText()//
|
|
/**
|
|
* Sets whether the column is moveable by the user.
|
|
* @param moveable Whether the column can be moved.
|
|
*/
|
|
public void setMoveable(boolean moveable) {
|
|
if(this.moveable != moveable) {
|
|
this.moveable = moveable;
|
|
sendMessage(MESSAGE_SET_COLUMN_MOVEABLE, moveable ? Boolean.TRUE : Boolean.FALSE, null, index, -1);
|
|
}//if//
|
|
}//setMoveable()//
|
|
/**
|
|
* Sets the column's default header text which is used when no other text is available.
|
|
* @param headerText The column's default header text.
|
|
*/
|
|
public void setHeaderText(String headerText) {
|
|
verifyThread();
|
|
this.headerText.setDefaultValue(headerText);
|
|
}//setHeaderText()//
|
|
/**
|
|
* Sets the column's default header text which is used when no other text is available.
|
|
* @param headerText The column's default header text.
|
|
*/
|
|
public void setHeaderText(ResourceReference headerText) {
|
|
verifyThread();
|
|
this.headerText.setDefaultValue(headerText);
|
|
}//setHeaderText()//
|
|
/**
|
|
* Sets the column's default header image which is used when no other image is available.
|
|
* @param headerImage The column's default header image.
|
|
*/
|
|
public void setHeaderImage(JefImage headerImage) {
|
|
verifyThread();
|
|
this.headerImage.setDefaultValue(headerImage);
|
|
}//setHeaderImage()//
|
|
/**
|
|
* Sets the column's default header image which is used when no other image is available.
|
|
* @param headerImage The column's default header image.
|
|
*/
|
|
public void setHeaderImage(ResourceReference headerImage) {
|
|
verifyThread();
|
|
this.headerImage.setDefaultValue(headerImage);
|
|
}//setHeaderImage()//
|
|
/**
|
|
* Sets the column's default cell text which is used when no other text is available.
|
|
* @param cellText The column's default cell text.
|
|
*/
|
|
public void setCellText(String cellText) {
|
|
verifyThread();
|
|
this.cellText.setDefaultValue(cellText);
|
|
}//setCellText()//
|
|
/**
|
|
* Sets the column's default cell image which is used when no other image is available.
|
|
* @param cellImage The column's default cell image.
|
|
*/
|
|
public void setCellImage(JefImage cellImage) {
|
|
verifyThread();
|
|
this.cellImage.setDefaultValue(cellImage);
|
|
}//setCellImage()//
|
|
/**
|
|
* Sets the column's default cell image which is used when no other image is available.
|
|
* @param cellImage The column's default cell image.
|
|
*/
|
|
public void setCellImage(ResourceReference cellImage) {
|
|
verifyThread();
|
|
this.cellImage.setDefaultValue(cellImage);
|
|
}//setCellImage()//
|
|
/**
|
|
* Sets the column's default background color which is used when no other background color is available.
|
|
* @param backgroundColor The column's default background color.
|
|
*/
|
|
public void setBackgroundColor(JefColor backgroundColor) {
|
|
verifyThread();
|
|
this.backgroundColor.setDefaultValue(backgroundColor);
|
|
}//setBackgroundColor()//
|
|
/**
|
|
* Sets the column's default background color which is used when no other background color is available.
|
|
* @param backgroundColor The column's default background color.
|
|
*/
|
|
public void setBackgroundColor(ResourceReference backgroundColor) {
|
|
verifyThread();
|
|
this.backgroundColor.setDefaultValue(backgroundColor);
|
|
}//setBackgroundColor()//
|
|
/**
|
|
* Sets the column's default background color which is used when no other foreground color is available.
|
|
* @param foregroundColor The column's default foreground color.
|
|
*/
|
|
public void setForegroundColor(JefColor foregroundColor) {
|
|
verifyThread();
|
|
this.foregroundColor.setDefaultValue(foregroundColor);
|
|
}//setForegroundColor()//
|
|
/**
|
|
* Sets the column's default background color which is used when no other foreground color is available.
|
|
* @param foregroundColor The column's default foreground color.
|
|
*/
|
|
public void setForegroundColor(ResourceReference foregroundColor) {
|
|
verifyThread();
|
|
this.foregroundColor.setDefaultValue(foregroundColor);
|
|
}//setForegroundColor()//
|
|
/**
|
|
* Sets the column's default background color which is used when no other font is available.
|
|
* @param font The column's default font.
|
|
*/
|
|
public void setFont(JefFont[] font) {
|
|
verifyThread();
|
|
this.font.setDefaultValue(font);
|
|
}//setFont()//
|
|
/**
|
|
* Sets the column's default background color which is used when no other font is available.
|
|
* @param font The column's default font.
|
|
*/
|
|
public void setFont(ResourceReference font) {
|
|
verifyThread();
|
|
this.font.setDefaultValue(font);
|
|
}//setFont()//
|
|
/**
|
|
* Sets the association container used to access the header text.
|
|
* @param container The header text association metadata.
|
|
*/
|
|
public void setHeaderTextAssociation(SingleAssociationContainer container) {
|
|
verifyThread();
|
|
this.headerText.setAssociations(container);
|
|
}//setHeaderTextAssociation()//
|
|
/**
|
|
* Sets the association container used to access the header image.
|
|
* @param container The header image association metadata.
|
|
*/
|
|
public void setHeaderImageAssociation(SingleAssociationContainer container) {
|
|
verifyThread();
|
|
this.headerImage.setAssociations(container);
|
|
}//setHeaderImageAssociation()//
|
|
/**
|
|
* Sets the association container used to access the cell text.
|
|
* @param container The cell text association metadata.
|
|
*/
|
|
public void setCellTextAssociation(MultiAssociationContainer container) {
|
|
verifyThread();
|
|
this.cellText.setAssociations(container);
|
|
}//setCellTextAssociation()//
|
|
/**
|
|
* Sets the association container used to access the cell image.
|
|
* @param container The cell image association metadata.
|
|
*/
|
|
public void setCellImageAssociation(MultiAssociationContainer container) {
|
|
verifyThread();
|
|
this.cellImage.setAssociations(container);
|
|
}//setCellImageAssociation()//
|
|
/**
|
|
* Sets the association container used to access the background color.
|
|
* @param container The background color association metadata.
|
|
*/
|
|
public void setBackgroundColorAssociation(MultiAssociationContainer container) {
|
|
verifyThread();
|
|
this.backgroundColor.setAssociations(container);
|
|
}//setBackgroundColorAssociation()//
|
|
/**
|
|
* Sets the association container used to access the foreground color.
|
|
* @param container The foreground color association metadata.
|
|
*/
|
|
public void setForegroundColorAssociation(MultiAssociationContainer container) {
|
|
verifyThread();
|
|
this.foregroundColor.setAssociations(container);
|
|
}//setForegroundColorAssociation()//
|
|
/**
|
|
* Sets the association container used to access the font.
|
|
* @param container The font association metadata.
|
|
*/
|
|
public void setFontAssociation(MultiAssociationContainer container) {
|
|
verifyThread();
|
|
this.font.setAssociations(container);
|
|
}//setFontAssociation()//
|
|
/**
|
|
* Adds a cell component to the column for use with rows that match the given type name.
|
|
* @param typeName The name of the class associated with the rows that will use the component to display cell data.
|
|
* @param component The component that lets the user view and optionally interact with cell data.
|
|
*/
|
|
public void addCellComponent(Class type, CellComponent component) {
|
|
if(renderers == null) {
|
|
renderers = new LiteList(5, 20);
|
|
}//if//
|
|
|
|
renderers.add(new Renderer(type, component));
|
|
}//addCellComponent()//
|
|
/**
|
|
* Gets the cell component for the given row type.
|
|
* @param rowType The type of data displayed on the row for which the cell component will be used.
|
|
* @return The cell component used to render and optionally interact with the cell data. This may be null in which case the default rendering will be used.
|
|
*/
|
|
public CellComponent getCellComponent(Class rowType) {
|
|
CellComponent result = null;
|
|
|
|
if(renderers != null) {
|
|
for(int index = 0; (result == null) && (index < renderers.getSize()); index++) {
|
|
Renderer renderer = (Renderer) renderers.get(index);
|
|
|
|
if(renderer.type.isAssignableFrom(rowType)) {
|
|
result = renderer.component;
|
|
}//if//
|
|
}//for//
|
|
}//if//
|
|
|
|
return result;
|
|
}//getCellComponent()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.IMultiResourceAssociationChangeListener#getResourceService()
|
|
*/
|
|
public AbstractResourceService getResourceService() {
|
|
return SimpleTable.this.getResourceService();
|
|
}//getResourceService()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.ISingleResourceAssociationChangeListener#getDecorationManager()
|
|
*/
|
|
public DecorationManager getDecorationManager() {
|
|
return SimpleTable.this.getDecorationManager();
|
|
}//getDecorationManager()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.ISingleResourceAssociationChangeListener#addDecoration(com.foundation.view.AbstractDecoration)
|
|
*/
|
|
public void addDecoration(AbstractDecoration decoration) {
|
|
}//addDecoration()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.ISingleResourceAssociationChangeListener#removeDecoration(com.foundation.view.AbstractDecoration)
|
|
*/
|
|
public void removeDecoration(AbstractDecoration decoration) {
|
|
}//removeDecoration()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.IMultiResourceAssociationChangeListener#addDecoration(com.foundation.view.ResourceAssociation, java.lang.Object, java.lang.Object, com.foundation.view.AbstractDecoration)
|
|
*/
|
|
public void addDecoration(ResourceAssociation association, Object row, Object data, AbstractDecoration decoration) {
|
|
//TODO: Finish.
|
|
}//addDecoration()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.view.IMultiResourceAssociationChangeListener#removeDecoration(com.foundation.view.ResourceAssociation, java.lang.Object, java.lang.Object, com.foundation.view.AbstractDecoration)
|
|
*/
|
|
public void removeDecoration(ResourceAssociation association, Object row, Object data, AbstractDecoration decoration) {
|
|
//TODO: Finish.
|
|
}//removeDecoration()//
|
|
}//ColumnData//
|
|
/**
|
|
* SimpleTable constructor.
|
|
* <p>Not Supported Styles (Yet): STYLE_CHECK, STYLE_VIRTUAL</p>
|
|
* @param parent The parent container for this component.
|
|
* @param name The name of the component.
|
|
* @param style The style of control to construct.
|
|
* @see #STYLE_MULTI
|
|
* @see #STYLE_SINGLE
|
|
* @see #STYLE_FULL_SELECTION
|
|
* @see #STYLE_HIDE_SELECTION
|
|
*/
|
|
public SimpleTable(Container parent, String name, int style) {
|
|
super(parent, name, style);
|
|
setAllowMultiSelection(((style & STYLE_MULTI) > 0));
|
|
sendMessage(MESSAGE_INITIALIZE, new int[] {parent.getNumber(), style});
|
|
}//SimpleTable()//
|
|
/**
|
|
* Adjusts the visible range of items to show some or all of the selections.
|
|
*/
|
|
public void showSelection() {
|
|
sendMessage(MESSAGE_SHOW_SELECTION, null);
|
|
}//showSelection()//
|
|
/**
|
|
* Sets the component's default background color.
|
|
* @param backgroundColor The default background color.
|
|
*/
|
|
public void setRowBackgroundColor(JefColor backgroundColor) {
|
|
verifyThread();
|
|
this.rowBackgroundColor.setDefaultValue(backgroundColor);
|
|
}//setRowHeaderBackgroundColor()//
|
|
/**
|
|
* Sets the component's default background color.
|
|
* @param backgroundColor The default background color.
|
|
*/
|
|
public void setRowBackgroundColor(ResourceReference backgroundColor) {
|
|
verifyThread();
|
|
this.rowBackgroundColor.setDefaultValue(backgroundColor);
|
|
}//setRowHeaderBackgroundColor()//
|
|
/**
|
|
* Sets the component's default foreground color.
|
|
* @param foregroundColor The default foreground color.
|
|
*/
|
|
public void setRowForegroundColor(JefColor foregroundColor) {
|
|
verifyThread();
|
|
this.rowForegroundColor.setDefaultValue(foregroundColor);
|
|
}//setRowHeaderForegroundColor()//
|
|
/**
|
|
* Sets the component's default foreground color.
|
|
* @param foregroundColor The default foreground color.
|
|
*/
|
|
public void setRowForegroundColor(ResourceReference foregroundColor) {
|
|
verifyThread();
|
|
this.rowForegroundColor.setDefaultValue(foregroundColor);
|
|
}//setRowHeaderForegroundColor()//
|
|
/**
|
|
* Sets the font for the row header. This will be the default font if there is a font attribute associated with this component.
|
|
* @param font The default font metadata.
|
|
*/
|
|
public void setRowFont(JefFont[] font) {
|
|
verifyThread();
|
|
this.rowFont.setDefaultValue(font);
|
|
}//setRowHeaderFont()//
|
|
/**
|
|
* Sets the font for the row header. This will be the default font if there is a font attribute associated with this component.
|
|
* @param font The default font metadata.
|
|
*/
|
|
public void setRowFont(ResourceReference font) {
|
|
verifyThread();
|
|
this.rowFont.setDefaultValue(font);
|
|
}//setRowHeaderFont()//
|
|
/**
|
|
* Sets the association container used to access the row background color.
|
|
* @param container The row background color association metadata.
|
|
*/
|
|
public void setRowBackgroundColorAssociation(MultiAssociationContainer container) {
|
|
verifyThread();
|
|
this.rowBackgroundColor.setAssociations(container);
|
|
}//setRowBackgroundColorAssociation()//
|
|
/**
|
|
* Sets the association container used to access the row foreground color.
|
|
* @param container The row foreground color association metadata.
|
|
*/
|
|
public void setRowForegroundColorAssociation(MultiAssociationContainer container) {
|
|
verifyThread();
|
|
this.rowForegroundColor.setAssociations(container);
|
|
}//setRowForegroundColorAssociation()//
|
|
/**
|
|
* Sets the association container used to access the row font.
|
|
* @param container The row font association metadata.
|
|
*/
|
|
public void setRowFontAssociation(MultiAssociationContainer container) {
|
|
verifyThread();
|
|
this.rowFont.setAssociations(container);
|
|
}//setRowFontAssociation()//
|
|
/**
|
|
* Determines whether the view manages the sorting of data.
|
|
* @param inViewSorting Whether the view should handle data sorting, otherwise the model will handle it.
|
|
*/
|
|
public void setInViewSorting(boolean inViewSorting) {
|
|
this.inViewSorting = inViewSorting;
|
|
//Tell the client to update.//
|
|
sendMessage(MESSAGE_IN_VIEW_SORTING, inViewSorting ? Boolean.TRUE : Boolean.FALSE);
|
|
}//setInViewSorting()//
|
|
/**
|
|
* Determines whether to show the header.
|
|
* @param showHeader Whether the header is visible.
|
|
*/
|
|
public void showHeaders(boolean showHeader) {
|
|
if(this.showHeader != showHeader) {
|
|
this.showHeader = showHeader;
|
|
sendMessage(MESSAGE_SHOW_HEADERS, showHeader ? Boolean.TRUE : Boolean.FALSE);
|
|
}//if//
|
|
}//showHeaders()//
|
|
/**
|
|
* Determines whether to show the grid lines.
|
|
* @param showGridLines Whether the grid lines are visible.
|
|
*/
|
|
public void showGridLines(boolean showGridLines) {
|
|
if(this.showGridLines != showGridLines) {
|
|
this.showGridLines = showGridLines;
|
|
sendMessage(MESSAGE_SHOW_GRID_LINES, showGridLines ? Boolean.TRUE : Boolean.FALSE);
|
|
}//if//
|
|
}//showGridLines()//
|
|
/**
|
|
* Gets the index of the top most visible item.
|
|
* @return The top most visible item's index.
|
|
*/
|
|
public Integer getTopIndex() {
|
|
return currentTopIndex;
|
|
}//getTopIndex()//
|
|
/**
|
|
* Sets the index of the top most visible item.
|
|
* @parma topIndex The top most visible item's index.
|
|
*/
|
|
public void setTopIndex(Integer topIndex) {
|
|
//Tell the client list to update.//
|
|
sendMessage(MESSAGE_SET_TOP_INDEX, topIndex);
|
|
//Save the current top index.//
|
|
this.currentTopIndex = topIndex;
|
|
}//setTopIndex()//
|
|
/**
|
|
* Gets whether resizeable columns will be called upon to fit the control's client space when the control resizes or a column resizes.
|
|
* @return Whether resizeable columns will be told to fit available space.
|
|
*/
|
|
public boolean getAutoFit() {
|
|
return autoFit;
|
|
}//getAutoFill()//
|
|
/**
|
|
* Sets whether resizeable columns will be called upon to fit the control's client space when the control resizes or a column resizes.
|
|
* @param autoFit Whether resizeable columns will be told to fit available space.
|
|
*/
|
|
public void setAutoFit(boolean autoFit) {
|
|
this.autoFit = autoFit;
|
|
sendMessage(MESSAGE_SET_AUTO_FIT, autoFit ? Boolean.TRUE : Boolean.FALSE);
|
|
}//setAutoFit()//
|
|
/**
|
|
* Gets whether resizeable columns will be streched to fill available space during the control's initialization.
|
|
* @return Whether resizeable columns will be expanded to fill in empty space.
|
|
*/
|
|
public boolean getFillOnInitialize() {
|
|
return fillOnInitialize;
|
|
}//getFillOnInitialize()//
|
|
/**
|
|
* Sets whether resizeable columns will be streched to fill available space during the control's initialization.
|
|
* @param fillOnInitialize Whether resizeable columns will be expanded to fill in empty space.
|
|
*/
|
|
public void setFillOnInitialize(boolean fillOnInitialize) {
|
|
this.fillOnInitialize = fillOnInitialize;
|
|
sendMessage(MESSAGE_SET_FILL_ON_INITIALIZE, fillOnInitialize ? Boolean.TRUE : Boolean.FALSE);
|
|
}//setFillOnInitialize()//
|
|
/**
|
|
* Gets whether resizeable columns will be streched to fill available space when resizing the control.
|
|
* @return Whether resizeable columns will be expanded to fill in empty space.
|
|
*/
|
|
public boolean getFillOnResize() {
|
|
return fillOnResize;
|
|
}//getFillOnResize()//
|
|
/**
|
|
* Sets whether resizeable columns will be streched to fill available space when resizing the control.
|
|
* @param fillOnResize Whether resizeable columns will be expanded to fill in empty space.
|
|
*/
|
|
public void setFillOnResize(boolean fillOnResize) {
|
|
this.fillOnResize = fillOnResize;
|
|
sendMessage(MESSAGE_SET_FILL_ON_RESIZE, fillOnResize ? Boolean.TRUE : Boolean.FALSE);
|
|
}//setFillOnResize()//
|
|
/**
|
|
* Adds an association for the fit event.
|
|
* @param association The association.
|
|
*/
|
|
public void addFitEventAssociation(IEventAssociation association) {
|
|
if(fitEventAssociations == null) {
|
|
fitEventAssociations = new LiteHashSet(4);
|
|
}//if//
|
|
|
|
association.setChangeListener(this);
|
|
fitEventAssociations.add(association);
|
|
|
|
if(isInitialized()) {
|
|
association.register();
|
|
}//if//
|
|
}//setFitEventAssociation()//
|
|
/**
|
|
* Adds an association for the fill event.
|
|
* @param association The association.
|
|
*/
|
|
public void addFillEventAssociation(IEventAssociation association) {
|
|
if(fillEventAssociations == null) {
|
|
fillEventAssociations = new LiteHashSet(4);
|
|
}//if//
|
|
|
|
association.setChangeListener(this);
|
|
fillEventAssociations.add(association);
|
|
|
|
if(isInitialized()) {
|
|
association.register();
|
|
}//if//
|
|
}//setFillEventAssociation()//
|
|
/**
|
|
* Adds a new column to the right of the existing columns.
|
|
* <p>Note: I have not yet allowed the removal of columns or addition of columns at specific indices. If we ever do add that option then we have to remember that the client server indicies are immutable, so the passed in index won't be used by the server, but only the client.</p>
|
|
* @return The column that was added. This can be used to setup the column's display properties.
|
|
*/
|
|
public ColumnData addColumn() {
|
|
ColumnData result = new ColumnData(getColumnCount());
|
|
|
|
addColumn(result);
|
|
|
|
return result;
|
|
}//addColumn()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent#itemSorted(int[])
|
|
*/
|
|
protected void itemSorted(int[] mapping) {
|
|
if(!inViewSorting) {
|
|
super.itemSorted(mapping);
|
|
}//if//
|
|
}//itemSorted()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent#createTableCellData()
|
|
*/
|
|
protected TableCellData createTableCellData() {
|
|
return new SimpleTableCellData();
|
|
}//createTableCellData()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewInitialize()
|
|
*/
|
|
protected void internalViewInitialize() {
|
|
rowBackgroundColor.initialize();
|
|
rowForegroundColor.initialize();
|
|
rowFont.initialize();
|
|
super.internalViewInitialize();
|
|
|
|
if(fillEventAssociations != null) {
|
|
IIterator iterator = fillEventAssociations.iterator();
|
|
|
|
while(iterator.hasNext()) {
|
|
((IEventAssociation) iterator.next()).register();
|
|
}//while//
|
|
}//if//
|
|
|
|
if(fitEventAssociations != null) {
|
|
IIterator iterator = fitEventAssociations.iterator();
|
|
|
|
while(iterator.hasNext()) {
|
|
((IEventAssociation) iterator.next()).register();
|
|
}//while//
|
|
}//if//
|
|
}//internalViewInitialize()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.AbstractComponent#internalViewRelease()
|
|
*/
|
|
protected void internalViewRelease() {
|
|
rowBackgroundColor.release();
|
|
rowForegroundColor.release();
|
|
rowFont.release();
|
|
|
|
if(fillEventAssociations != null) {
|
|
IIterator iterator = fillEventAssociations.iterator();
|
|
|
|
while(iterator.hasNext()) {
|
|
((IEventAssociation) iterator.next()).unregister();
|
|
}//while//
|
|
}//if//
|
|
|
|
if(fitEventAssociations != null) {
|
|
IIterator iterator = fitEventAssociations.iterator();
|
|
|
|
while(iterator.hasNext()) {
|
|
((IEventAssociation) iterator.next()).unregister();
|
|
}//while//
|
|
}//if//
|
|
|
|
super.internalViewRelease();
|
|
}//internalViewRelease()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent#internalViewRefresh()
|
|
*/
|
|
protected void internalViewRefresh() {
|
|
super.internalViewRefresh();
|
|
}//internalViewRefresh()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.Component#internalOnEventFired(com.foundation.view.IEventAssociation, java.lang.Object[])
|
|
*/
|
|
protected void internalOnEventFired(IEventAssociation eventAssociation, Object[] eventArguments) {
|
|
if((fillEventAssociations != null) && (fillEventAssociations.containsValue(eventAssociation))) {
|
|
sendMessage(MESSAGE_FILL, null);
|
|
}//if//
|
|
else if((fitEventAssociations != null) && (fitEventAssociations.containsValue(eventAssociation))) {
|
|
sendMessage(MESSAGE_FIT, null);
|
|
}//else if//
|
|
else {
|
|
super.internalOnEventFired(eventAssociation, eventArguments);
|
|
}//else//
|
|
}//internalOnEventFired()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.CollectionComponent#internalOnValueChanged(com.foundation.view.SingleResourceAssociation)
|
|
*/
|
|
protected void internalOnValueChanged(SingleResourceAssociation resourceAssociation, int flags) {
|
|
super.internalOnValueChanged(resourceAssociation, flags);
|
|
}//internalOnValueChanged()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.AbstractComponent#internalOnValueChanged(com.foundation.view.MultiResourceAssociation, java.lang.Object)
|
|
*/
|
|
protected void internalOnValueChanged(MultiResourceAssociation resourceAssociation, Object item, Object data, boolean isUpdate) {
|
|
if(isInitialized()) {
|
|
if(resourceAssociation == rowBackgroundColor) {
|
|
//Verify that the item cell data has actually been altered.//
|
|
if(rowBackgroundColor.refresh(item)) {
|
|
RowObject row = (RowObject) getRowObject(item);
|
|
|
|
sendMessage(MESSAGE_SET_ROW_BACKGROUND_COLOR, rowBackgroundColor.getValue(item), null, row.objectId, -1);
|
|
}//if//
|
|
}//if//
|
|
else if(resourceAssociation == rowForegroundColor) {
|
|
//Verify that the item cell data has actually been altered.//
|
|
if(rowForegroundColor.refresh(item)) {
|
|
RowObject row = (RowObject) getRowObject(item);
|
|
|
|
sendMessage(MESSAGE_SET_ROW_FOREGROUND_COLOR, rowForegroundColor.getValue(item), null, row.objectId, -1);
|
|
}//if//
|
|
}//else if//
|
|
else if(resourceAssociation == rowFont) {
|
|
//Verify that the item cell data has actually been altered.//
|
|
if(rowFont.refresh(item)) {
|
|
RowObject row = (RowObject) getRowObject(item);
|
|
|
|
sendMessage(MESSAGE_SET_ROW_FONT, rowFont.getValue(item), null, row.objectId, -1);
|
|
}//if//
|
|
}//else if//
|
|
else {
|
|
super.internalOnValueChanged(resourceAssociation, item, data, isUpdate);
|
|
}//else//
|
|
}//if//
|
|
}//internalOnValueChanged()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent#registerItem(com.foundation.tcv.swt.server.RowObject)
|
|
*/
|
|
protected void registerItem(RowObject rowObject) {
|
|
super.registerItem(rowObject);
|
|
|
|
rowBackgroundColor.registerItem(rowObject.value, rowObject);
|
|
rowForegroundColor.registerItem(rowObject.value, rowObject);
|
|
rowFont.registerItem(rowObject.value, rowObject);
|
|
}//registerItem()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.CollectionComponent#sendAddItemMessage(com.foundation.tcv.swt.server.RowObject, int)
|
|
*/
|
|
protected void sendAddItemMessage(RowObject rowObject, int itemIndex) {
|
|
//The standard cell data is packaged up and sent in bulk to the client for each cell, but the 'extra' data, perticularly for the cell components, must wait until after the item is added on the client before being initialized and refreshed.//
|
|
super.sendAddItemMessage(rowObject, itemIndex);
|
|
|
|
//Have each column perform post item added registration. This allows us to register the row data with parts that send messages to the client.//
|
|
for(int index = 0; index < getColumnCount(); index++) {
|
|
((ColumnData) getColumn(index)).postRegisterItem(rowObject);
|
|
}//for//
|
|
}//sendAddItemMessage()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent#unregisterItem(com.foundation.tcv.swt.server.RowObject)
|
|
*/
|
|
protected void unregisterItem(RowObject rowObject) {
|
|
super.unregisterItem(rowObject);
|
|
|
|
rowBackgroundColor.unregisterItem(rowObject.value);
|
|
rowForegroundColor.unregisterItem(rowObject.value);
|
|
rowFont.unregisterItem(rowObject.value);
|
|
}//unregisterItem()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.TableComponent#unregisterItems()
|
|
*/
|
|
protected void unregisterItems() {
|
|
super.unregisterItems();
|
|
|
|
rowBackgroundColor.unregisterAllItems();
|
|
rowForegroundColor.unregisterAllItems();
|
|
rowFont.unregisterAllItems();
|
|
}//unregisterItems()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.view.IViewComponent#processMessage(com.foundation.tcv.model.ViewMessage)
|
|
*/
|
|
public Object processMessage(ViewMessage viewMessage) {
|
|
Object retVal = null;
|
|
|
|
switch(viewMessage.getMessageNumber()) {
|
|
case MESSAGE_SYNCHRONIZE_TOP_INDEX: {
|
|
currentTopIndex = (Integer) viewMessage.getMessageData();
|
|
break;
|
|
}//case//
|
|
case MESSAGE_SEND_DOUBLE_CLICK: {
|
|
if(getDoubleClickMethod() != null) {
|
|
if(getDoubleClickMethod().getIsValueHolderAssociated()) {
|
|
getDoubleClickMethod().invoke(null, true); //For now we will assume no parameters. It would be nice to pass the selection perhaps.//
|
|
}//if//
|
|
else {
|
|
Object selection = null;
|
|
|
|
//Determine which selection to invoke the method on.//
|
|
if(getAllowMultiSelection()) {
|
|
ICollection selections = getModelSelections();
|
|
|
|
if((selections != null) && (selections.getSize() > 0)) {
|
|
selection = selections.iterator().next();
|
|
}//if//
|
|
}//if//
|
|
else {
|
|
selection = getModelSelection();
|
|
}//else//
|
|
|
|
if(selection != null) {
|
|
//Invoke the method on the selection object if there is one.//
|
|
getDoubleClickMethod().invoke(selection, null, true);
|
|
}//if//
|
|
}//else//
|
|
}//if//
|
|
break;
|
|
}//case//
|
|
default: {
|
|
retVal = super.processMessage(viewMessage);
|
|
}//default//
|
|
}//switch//
|
|
|
|
return retVal;
|
|
}//processMessage()//
|
|
/* (non-Javadoc)
|
|
* @see com.foundation.tcv.swt.server.AbstractComponent#getClientClassName()
|
|
*/
|
|
protected String getClientClassName() {
|
|
return "com.foundation.tcv.swt.client.SimpleTable";
|
|
}//getClientClassName()//
|
|
}//SimpleTable// |