297 lines
13 KiB
Java
297 lines
13 KiB
Java
|
|
/*
|
||
|
|
* Copyright (c) 2004,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;
|
||
|
|
|
||
|
|
import java.io.IOException;
|
||
|
|
import java.io.ObjectInput;
|
||
|
|
import java.io.ObjectOutput;
|
||
|
|
|
||
|
|
public interface ITableComponent extends ICollectionComponent {
|
||
|
|
public static final int MESSAGE_SET_SELECTION = ICollectionComponent.LAST_MESSAGE_NUMBER + 1;
|
||
|
|
public static final int MESSAGE_ADD_SELECTIONS = ICollectionComponent.LAST_MESSAGE_NUMBER + 2;
|
||
|
|
public static final int MESSAGE_REMOVE_SELECTIONS = ICollectionComponent.LAST_MESSAGE_NUMBER + 3;
|
||
|
|
public static final int MESSAGE_ADD_SELECTION = ICollectionComponent.LAST_MESSAGE_NUMBER + 4;
|
||
|
|
public static final int MESSAGE_REMOVE_SELECTION = ICollectionComponent.LAST_MESSAGE_NUMBER + 5;
|
||
|
|
public static final int MESSAGE_REMOVE_ALL_SELECTIONS = ICollectionComponent.LAST_MESSAGE_NUMBER + 6;
|
||
|
|
public static final int MESSAGE_VIEW_SYNCHRONIZE_SELECTION = ICollectionComponent.LAST_MESSAGE_NUMBER + 7;
|
||
|
|
|
||
|
|
public static final int MESSAGE_ADD_COLUMN = ICollectionComponent.LAST_MESSAGE_NUMBER + 8;
|
||
|
|
public static final int MESSAGE_REMOVE_COLUMN = ICollectionComponent.LAST_MESSAGE_NUMBER + 9;
|
||
|
|
|
||
|
|
public static final int MESSAGE_SET_COLUMN_HEADER_TEXT = ICollectionComponent.LAST_MESSAGE_NUMBER + 10;
|
||
|
|
public static final int MESSAGE_SET_COLUMN_HEADER_IMAGE = ICollectionComponent.LAST_MESSAGE_NUMBER + 11;
|
||
|
|
public static final int MESSAGE_SET_CELL_TEXT = ICollectionComponent.LAST_MESSAGE_NUMBER + 12;
|
||
|
|
public static final int MESSAGE_SET_CELL_IMAGE = ICollectionComponent.LAST_MESSAGE_NUMBER + 13;
|
||
|
|
public static final int MESSAGE_SET_CELL_BACKGROUND_COLOR = ICollectionComponent.LAST_MESSAGE_NUMBER + 14;
|
||
|
|
public static final int MESSAGE_SET_CELL_FOREGROUND_COLOR = ICollectionComponent.LAST_MESSAGE_NUMBER + 15;
|
||
|
|
public static final int MESSAGE_SET_CELL_FONT = ICollectionComponent.LAST_MESSAGE_NUMBER + 16;
|
||
|
|
|
||
|
|
public static final int MESSAGE_SET_ROW_FONT = ICollectionComponent.LAST_MESSAGE_NUMBER + 17;
|
||
|
|
public static final int MESSAGE_ORDER_ROWS = ICollectionComponent.LAST_MESSAGE_NUMBER + 18;
|
||
|
|
public static final int MESSAGE_SUSPEND_ROW_COLOR_UPDATES = ICollectionComponent.LAST_MESSAGE_NUMBER + 19;
|
||
|
|
public static final int MESSAGE_RESUME_ROW_COLOR_UPDATES = ICollectionComponent.LAST_MESSAGE_NUMBER + 20;
|
||
|
|
public static final int MESSAGE_SET_ROW_SELECTION_GRADIENT = ICollectionComponent.LAST_MESSAGE_NUMBER + 21;
|
||
|
|
public static final int MESSAGE_SET_ROW_BACKGROUND_COLOR = ICollectionComponent.LAST_MESSAGE_NUMBER + 22;
|
||
|
|
public static final int MESSAGE_SET_ROW_FOREGROUND_COLOR = ICollectionComponent.LAST_MESSAGE_NUMBER + 23;
|
||
|
|
public static final int MESSAGE_SET_ROW_BACKGROUND_COLOR_ALT = ICollectionComponent.LAST_MESSAGE_NUMBER + 24;
|
||
|
|
public static final int MESSAGE_SET_ROW_FOREGROUND_COLOR_ALT = ICollectionComponent.LAST_MESSAGE_NUMBER + 25;
|
||
|
|
public static final int MESSAGE_SET_ROW_CUSTOM_BACKGROUND_COLOR = ICollectionComponent.LAST_MESSAGE_NUMBER + 26;
|
||
|
|
public static final int MESSAGE_SET_ROW_CUSTOM_FOREGROUND_COLOR = ICollectionComponent.LAST_MESSAGE_NUMBER + 27;
|
||
|
|
public static final int MESSAGE_SET_ROW_HEIGHT = ICollectionComponent.LAST_MESSAGE_NUMBER + 28;
|
||
|
|
public static final int MESSAGE_ADD_ROW_HIGHLIGHT_DECORATION = ICollectionComponent.LAST_MESSAGE_NUMBER + 29;
|
||
|
|
public static final int MESSAGE_REMOVE_ROW_HIGHLIGHT_DECORATION = ICollectionComponent.LAST_MESSAGE_NUMBER + 30;
|
||
|
|
public static final int MESSAGE_ADD_ROW_IMAGE_DECORATION = ICollectionComponent.LAST_MESSAGE_NUMBER + 31;
|
||
|
|
public static final int MESSAGE_REMOVE_ROW_IMAGE_DECORATION = ICollectionComponent.LAST_MESSAGE_NUMBER + 32;
|
||
|
|
public static final int LAST_MESSAGE_NUMBER = ICollectionComponent.LAST_MESSAGE_NUMBER + 32;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Encapsulates one row of data which is associated with an object in the table.
|
||
|
|
* Note that an item can exist in the table in more than one place representing more than one row, all with the same object identifier.
|
||
|
|
*/
|
||
|
|
public static class TableRowData implements java.io.Externalizable {
|
||
|
|
/** The row's desired text, or null for the default text. This may be ignored by some tables. */
|
||
|
|
private String text;
|
||
|
|
/** The row's desired image, or null for the default image. */
|
||
|
|
private Object image;
|
||
|
|
/** The row's desired background color, or null for the default color. Note: This comes from the custom color association and it overrides any alternating or default coloring. */
|
||
|
|
private Object backgroundColor;
|
||
|
|
/** The row's desired foreground color, or null for the default color. Note: This comes from the custom color association and it overrides any alternating or default coloring. */
|
||
|
|
private Object foregroundColor;
|
||
|
|
/** The row's desired font, or null for the default font. Note: This comes from the font association and it overrides the component font. */
|
||
|
|
private Object font;
|
||
|
|
/** The data elements for the columns. This is normally an Object[], one element for each column. */
|
||
|
|
private TableCellData[] columnData;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* TableRowData constructor.
|
||
|
|
*/
|
||
|
|
public TableRowData() {
|
||
|
|
}//TableRowData()//
|
||
|
|
/**
|
||
|
|
* TableRowData constructor.
|
||
|
|
* @param objectId The object identifier for the row being added.
|
||
|
|
* @param rowIndex The optional index of the row. A value of -1 indicates append to the end.
|
||
|
|
* @param columnData The data elements for the columns. This is normally an Object[], one element for each column.
|
||
|
|
* @param hiddenData The data elements for the hidden 'columns'.
|
||
|
|
*/
|
||
|
|
public TableRowData(TableCellData[] columnData) {
|
||
|
|
this.columnData = columnData;
|
||
|
|
}//TableRowData()//
|
||
|
|
/**
|
||
|
|
* Gets the row's desired text, or null for the default text.
|
||
|
|
* @return The row's text.
|
||
|
|
*/
|
||
|
|
public String getText() {
|
||
|
|
return text;
|
||
|
|
}//getText()//
|
||
|
|
/**
|
||
|
|
* Sets the row's desired text, or null for the default text.
|
||
|
|
* @param text The row's text.
|
||
|
|
*/
|
||
|
|
public void setText(String text) {
|
||
|
|
this.text = text;
|
||
|
|
}//setText()//
|
||
|
|
/**
|
||
|
|
* Gets the row's desired image, or null for the default image.
|
||
|
|
* @return The row's image (JefImage) or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public Object getImage() {
|
||
|
|
return image;
|
||
|
|
}//getImage()//
|
||
|
|
/**
|
||
|
|
* Sets the row's desired image, or null for the default image.
|
||
|
|
* @param image The row's image (JefImage) or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public void setImage(Object image) {
|
||
|
|
this.image = image;
|
||
|
|
}//setImage()//
|
||
|
|
/**
|
||
|
|
* Gets the row's desired background color, or null for the default color.
|
||
|
|
* @return The row's background color (JefColor), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public Object getBackgroundColor() {
|
||
|
|
return backgroundColor;
|
||
|
|
}//getBackgroundColor()//
|
||
|
|
/**
|
||
|
|
* Gets the row's desired background color, or null for the default color.
|
||
|
|
* @return The row's background color (JefColor), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public void setBackgroundColor(Object backgroundColor) {
|
||
|
|
this.backgroundColor = backgroundColor;
|
||
|
|
}//setBackgroundColor()//
|
||
|
|
/**
|
||
|
|
* Gets the row's desired foreground color, or null for the default color.
|
||
|
|
* @return The row's foreground color (JefColor), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public Object getForegroundColor() {
|
||
|
|
return foregroundColor;
|
||
|
|
}//getForegroundColor()//
|
||
|
|
/**
|
||
|
|
* Sets the row's desired foreground color, or null for the default color.
|
||
|
|
* @param foregroundColor The row's foreground color (JefColor), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public void setForegroundColor(Object foregroundColor) {
|
||
|
|
this.foregroundColor = foregroundColor;
|
||
|
|
}//setForegroundColor()//
|
||
|
|
/**
|
||
|
|
* Gets the row's desired font, or null for the default font.
|
||
|
|
* @return The row's font (JefFont[]), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public Object getFont() {
|
||
|
|
return font;
|
||
|
|
}//getFont()//
|
||
|
|
/**
|
||
|
|
* Sets the row's desired font, or null for the default font.
|
||
|
|
* @param font The row's font (JefFont[]), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public void setFont(Object font) {
|
||
|
|
this.font = font;
|
||
|
|
}//setFont()//
|
||
|
|
/**
|
||
|
|
* Gets the data elements for the columns.
|
||
|
|
* @return The data for all the columns.
|
||
|
|
*/
|
||
|
|
public TableCellData[] getColumnData() {
|
||
|
|
return columnData;
|
||
|
|
}//getColumnData()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see java.io.Externalizable#readExternal(java.io.ObjectInput)
|
||
|
|
*/
|
||
|
|
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
||
|
|
text = in.readUTF();
|
||
|
|
image = in.readObject();
|
||
|
|
backgroundColor = in.readObject();
|
||
|
|
foregroundColor = in.readObject();
|
||
|
|
font = in.readObject();
|
||
|
|
columnData = (TableCellData[]) in.readObject();
|
||
|
|
}//readExternal()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
|
||
|
|
*/
|
||
|
|
public void writeExternal(ObjectOutput out) throws IOException {
|
||
|
|
out.writeUTF(text);
|
||
|
|
out.writeObject(image);
|
||
|
|
out.writeObject(backgroundColor);
|
||
|
|
out.writeObject(foregroundColor);
|
||
|
|
out.writeObject(font);
|
||
|
|
out.writeObject(columnData);
|
||
|
|
}//writeExternal()//
|
||
|
|
}//TableRowData//
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Encapsulates the data for a single cell.
|
||
|
|
*/
|
||
|
|
public class TableCellData implements java.io.Externalizable {
|
||
|
|
/** The cell's desired text, or null for the default text. */
|
||
|
|
private String text;
|
||
|
|
/** The cell's desired image, or null for the default image. */
|
||
|
|
private Object image;
|
||
|
|
/** The cell's desired background color, or null for the default color. */
|
||
|
|
private Object backgroundColor;
|
||
|
|
/** The cell's desired foreground color, or null for the default color. */
|
||
|
|
private Object foregroundColor;
|
||
|
|
/** The cell's desired font, or null for the default font. */
|
||
|
|
private Object font;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* TableCellData constructor.
|
||
|
|
*/
|
||
|
|
public TableCellData() {
|
||
|
|
}//TableCellData()//
|
||
|
|
/**
|
||
|
|
* Gets the cell's desired text, or null for the default text.
|
||
|
|
* @return The cell's text.
|
||
|
|
*/
|
||
|
|
public String getText() {
|
||
|
|
return text;
|
||
|
|
}//getText()//
|
||
|
|
/**
|
||
|
|
* Sets the cell's desired text, or null for the default text.
|
||
|
|
* @param text The cell's text.
|
||
|
|
*/
|
||
|
|
public void setText(String text) {
|
||
|
|
this.text = text;
|
||
|
|
}//setText()//
|
||
|
|
/**
|
||
|
|
* Gets the cell's desired image, or null for the default image.
|
||
|
|
* @return The cell's image (JefImage) or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public Object getImage() {
|
||
|
|
return image;
|
||
|
|
}//getImage()//
|
||
|
|
/**
|
||
|
|
* Sets the cell's desired image, or null for the default image.
|
||
|
|
* @param image The cell's image (JefImage) or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public void setImage(Object image) {
|
||
|
|
this.image = image;
|
||
|
|
}//setImage()//
|
||
|
|
/**
|
||
|
|
* Gets the cell's desired background color, or null for the default color.
|
||
|
|
* @return The cell's background color (JefColor), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public Object getBackgroundColor() {
|
||
|
|
return backgroundColor;
|
||
|
|
}//getBackgroundColor()//
|
||
|
|
/**
|
||
|
|
* Gets the cell's desired background color, or null for the default color.
|
||
|
|
* @return The cell's background color (JefColor), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public void setBackgroundColor(Object backgroundColor) {
|
||
|
|
this.backgroundColor = backgroundColor;
|
||
|
|
}//setBackgroundColor()//
|
||
|
|
/**
|
||
|
|
* Gets the cell's desired foreground color, or null for the default color.
|
||
|
|
* @return The cell's foreground color (JefColor), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public Object getForegroundColor() {
|
||
|
|
return foregroundColor;
|
||
|
|
}//getForegroundColor()//
|
||
|
|
/**
|
||
|
|
* Sets the cell's desired foreground color, or null for the default color.
|
||
|
|
* @param foregroundColor The cell's foreground color (JefColor), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public void setForegroundColor(Object foregroundColor) {
|
||
|
|
this.foregroundColor = foregroundColor;
|
||
|
|
}//setForegroundColor()//
|
||
|
|
/**
|
||
|
|
* Gets the cell's desired font, or null for the default font.
|
||
|
|
* @return The cell's font (JefFont[]), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public Object getFont() {
|
||
|
|
return font;
|
||
|
|
}//getFont()//
|
||
|
|
/**
|
||
|
|
* Sets the cell's desired font, or null for the default font.
|
||
|
|
* @param font The cell's font (JefFont[]), or resource (ResourceReference).
|
||
|
|
*/
|
||
|
|
public void setFont(Object font) {
|
||
|
|
this.font = font;
|
||
|
|
}//setFont()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see java.io.Externalizable#readExternal(java.io.ObjectInput)
|
||
|
|
*/
|
||
|
|
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
||
|
|
text = in.readUTF();
|
||
|
|
image = in.readObject();
|
||
|
|
backgroundColor = in.readObject();
|
||
|
|
foregroundColor = in.readObject();
|
||
|
|
font = in.readObject();
|
||
|
|
}//readExternal()//
|
||
|
|
/* (non-Javadoc)
|
||
|
|
* @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
|
||
|
|
*/
|
||
|
|
public void writeExternal(ObjectOutput out) throws IOException {
|
||
|
|
out.writeUTF(text);
|
||
|
|
out.writeObject(image);
|
||
|
|
out.writeObject(backgroundColor);
|
||
|
|
out.writeObject(foregroundColor);
|
||
|
|
out.writeObject(font);
|
||
|
|
}//writeExternal()//
|
||
|
|
}//TableCellData//
|
||
|
|
}//ITableComponent//
|