nextapp.echo
Class Table

java.lang.Object
  extended by nextapp.echo.AbstractComponent
      extended by nextapp.echo.Table
All Implemented Interfaces:
java.io.Serializable, Component
Direct Known Subclasses:
SortableTable

public class Table
extends AbstractComponent

A component used to display data in a tabular format.

See Also:
Serialized Form

Field Summary
static java.lang.String AUTO_CREATE_COLUMNS_FROM_MODEL_CHANGED_PROPERTY
           
static java.lang.String BORDER_COLOR_CHANGED_PROPERTY
           
static java.lang.String BORDER_SIZE_CHANGED_PROPERTY
           
static java.lang.String CELL_MARGIN_CHANGED_PROPERTY
           
static TableCellRenderer DEFAULT_TABLE_CELL_RENDERER
          The default renderer for table cells.
static java.lang.String HEIGHT_CHANGED_PROPERTY
           
static java.lang.String HEIGHT_UNITS_CHANGED_PROPERTY
           
static int PERCENT_UNITS
          A constant used in the setWidthUnits() and setHeightUnits() methods.
static int PIXEL_UNITS
          A constant used in the setWidthUnits() and setHeightUnits() methods.
static java.lang.String ROW_HEIGHT_CHANGED_PROPERTY
           
static java.lang.String STYLE_BORDER_COLOR
          A style constant for the Border Color property.
static java.lang.String STYLE_BORDER_SIZE
          A style constant for the Border Size property.
static java.lang.String STYLE_CELL_MARGIN
          A style constant for the Cell Margin property.
static java.lang.String STYLE_COLUMN_WIDTHS
          A style constant for the setting column widths.
static java.lang.String STYLE_HEIGHT
          A style constant for the Height property.
static java.lang.String STYLE_HEIGHT_UNITS
          A style constant for the Height Units property.
static java.lang.String STYLE_ROW_HEIGHTS
          A style constant for the setting row heights.
static java.lang.String STYLE_WIDTH
          A style constant for the Width property.
static java.lang.String STYLE_WIDTH_UNITS
          A style constant for the Width Units property.
static java.lang.String TABLE_COLUMN_MODEL_CHANGED_PROPERTY
           
static java.lang.String TABLE_HEADER_CHANGED_PROPERTY
           
static java.lang.String WIDTH_CHANGED_PROPERTY
           
static java.lang.String WIDTH_UNITS_CHANGED_PROPERTY
           
 
Fields inherited from interface nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, SELECTABLE_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
Table()
          Creates a new table, generating an empty default table model.
Table(int columns, int rows)
          Creates a new table, generating an empty default table model of the given dimensions.
Table(TableModel model)
          Creates a Table using the supplied TableModel.
Table(TableModel model, TableColumnModel columnModel)
          Creates a Table using the supplied TableModel.
 
Method Summary
 void applyStyle(Style style)
          Sets stylistic properties of this component based on a Style object.
 void createDefaultColumnsFromModel()
          Creates a TableColumnModel based on the present TableModel.
 Color getBorderColor()
          Returns the border color.
 int getBorderSize()
          Returns the border size.
 int getCellMargin()
          Returns the cell margin.
 int getColumnCount()
          Returns the number of columns in the table.
 TableColumnModel getColumnModel()
          Returns the table's column model.
 Component getComponent(Coordinate coordinate)
          Deprecated. See getRenderedComponent(Coordinate).
 TableCellRenderer getDefaultRenderer(java.lang.Class columnClass)
          Returns the TableCellRenderer that is used for the specified column.
 int getHeight()
          Returns the overall height of the table.
 int getHeightUnits()
          Returns the units (pixel or percent) in which column heights and overall table height are measured.
 TableModel getModel()
          Returns the table model.
 Component getRenderedComponent(Coordinate coordinate)
          Returns the contents of the table cell at the specified coordinate.
 int getRowCount()
          Returns the number of rows in the table.
 int getRowHeight(int row)
          Returns the height of a table row.
 TableHeader getTableHeader()
          Returns the TableHeader object which is responsible for rendering the table's header.
 int getWidth()
          Returns the overall width of the table.
 int getWidthUnits()
          Returns the units (pixel or percent) in which column widths and overall table width are measured.
 void invalidate()
          Marks the table as needing to be re-rendered.
 boolean isAutoCreateColumnsFromModel()
          Returns true if the TableColumnModel will be directly derived from the TableModel.
 boolean isContainsFastColumns()
           
 boolean isFastColumn(int column)
           
 boolean isRemoveSelectionHandlesIfReadOnly()
           
 void setAutoCreateColumnsFromModel(boolean newValue)
          Sets whether the TableColumnModel will be directly derived from the TableModel.
 void setBorderColor(Color newValue)
          Sets the border color of the table.
 void setBorderSize(int newValue)
          Sets the size of the table's border.
 void setCellMargin(int newValue)
          Sets the cell interior margin.
 void setColumnModel(TableColumnModel newValue)
          Sets the column model for this table.
 void setContainsFastColumns(boolean FastColumns)
           
 void setDefaultRenderer(java.lang.Class columnClass, TableCellRenderer defaultRenderer)
          Sets the default renderer that will be used for the given column class.
 void setFastColumn(int column, boolean value)
           
 void setHeight(int newValue)
          Sets the overall height of the table.
 void setHeightUnits(int newValue)
          Sets the units (pixel or percent) in which row heights and overall table height are measured.
 void setModel(TableModel newValue)
          Sets the TableModel the Table is visualizing.
 void setRemoveSelectionHandlesIfReadOnly(boolean removeSelectionHandlesIfReadOnly)
           
 void setRowHeight(int row, int newValue)
          Sets the height of a row of the table.
 void setTableHeader(TableHeader newValue)
          Sets the TableHeader the table uses to render the table's header.
 void setWidth(int newValue)
          Sets the overall width of the table.
 void setWidthUnits(int newValue)
          Sets the units (pixel or percent) in which column widths and overall table width are measured.
 void validate()
          Updates the Table component to reflect its model.
 
Methods inherited from class nextapp.echo.AbstractComponent
add, add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getClientId, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getListenerList, getLocale, getParent, indexOf, init, isAncestorOf, isDifferent, isEnabled, isFocused, isRecursivelyVisible, isRegistered, isSelectableForScriptRecorder, isShowing, isVisible, processHierarchyEvent, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setClientId, setEnabled, setFocused, setFont, setForeground, setIdentifier, setLocale, setParent, setRegistered, setSelectableForScriptRecorder, setVisible, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PIXEL_UNITS

public static final int PIXEL_UNITS
A constant used in the setWidthUnits() and setHeightUnits() methods. This value specifies that pixel-based units are used in defining the individual column or row sizes and the overall width and height of the table.

See Also:
Constant Field Values

PERCENT_UNITS

public static final int PERCENT_UNITS
A constant used in the setWidthUnits() and setHeightUnits() methods. This value specifies that percent-based are used in defining both the individual column or row sizes and the overall width or height of the table.

See Also:
Constant Field Values

STYLE_BORDER_COLOR

public static final java.lang.String STYLE_BORDER_COLOR
A style constant for the Border Color property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_BORDER_SIZE

public static final java.lang.String STYLE_BORDER_SIZE
A style constant for the Border Size property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_CELL_MARGIN

public static final java.lang.String STYLE_CELL_MARGIN
A style constant for the Cell Margin property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_COLUMN_WIDTHS

public static final java.lang.String STYLE_COLUMN_WIDTHS
A style constant for the setting column widths. Values of this key must be an array of integer primitives.

See Also:
Constant Field Values

STYLE_HEIGHT

public static final java.lang.String STYLE_HEIGHT
A style constant for the Height property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_HEIGHT_UNITS

public static final java.lang.String STYLE_HEIGHT_UNITS
A style constant for the Height Units property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_ROW_HEIGHTS

public static final java.lang.String STYLE_ROW_HEIGHTS
A style constant for the setting row heights. Values of this key must be an array of integer primitives.

See Also:
Constant Field Values

STYLE_WIDTH

public static final java.lang.String STYLE_WIDTH
A style constant for the Width property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

STYLE_WIDTH_UNITS

public static final java.lang.String STYLE_WIDTH_UNITS
A style constant for the Width Units property. Values of this key must be of type java.lang.Integer.

See Also:
Constant Field Values

DEFAULT_TABLE_CELL_RENDERER

public static final TableCellRenderer DEFAULT_TABLE_CELL_RENDERER
The default renderer for table cells.


AUTO_CREATE_COLUMNS_FROM_MODEL_CHANGED_PROPERTY

public static final java.lang.String AUTO_CREATE_COLUMNS_FROM_MODEL_CHANGED_PROPERTY
See Also:
Constant Field Values

BORDER_COLOR_CHANGED_PROPERTY

public static final java.lang.String BORDER_COLOR_CHANGED_PROPERTY
See Also:
Constant Field Values

BORDER_SIZE_CHANGED_PROPERTY

public static final java.lang.String BORDER_SIZE_CHANGED_PROPERTY
See Also:
Constant Field Values

CELL_MARGIN_CHANGED_PROPERTY

public static final java.lang.String CELL_MARGIN_CHANGED_PROPERTY
See Also:
Constant Field Values

TABLE_HEADER_CHANGED_PROPERTY

public static final java.lang.String TABLE_HEADER_CHANGED_PROPERTY
See Also:
Constant Field Values

TABLE_COLUMN_MODEL_CHANGED_PROPERTY

public static final java.lang.String TABLE_COLUMN_MODEL_CHANGED_PROPERTY
See Also:
Constant Field Values

ROW_HEIGHT_CHANGED_PROPERTY

public static final java.lang.String ROW_HEIGHT_CHANGED_PROPERTY
See Also:
Constant Field Values

HEIGHT_CHANGED_PROPERTY

public static final java.lang.String HEIGHT_CHANGED_PROPERTY
See Also:
Constant Field Values

HEIGHT_UNITS_CHANGED_PROPERTY

public static final java.lang.String HEIGHT_UNITS_CHANGED_PROPERTY
See Also:
Constant Field Values

WIDTH_CHANGED_PROPERTY

public static final java.lang.String WIDTH_CHANGED_PROPERTY
See Also:
Constant Field Values

WIDTH_UNITS_CHANGED_PROPERTY

public static final java.lang.String WIDTH_UNITS_CHANGED_PROPERTY
See Also:
Constant Field Values
Constructor Detail

Table

public Table()
Creates a new table, generating an empty default table model.


Table

public Table(int columns,
             int rows)
Creates a new table, generating an empty default table model of the given dimensions.

Parameters:
columns - The initial number of columns in the table.
rows - The initial number of rows in the table.

Table

public Table(TableModel model)
Creates a Table using the supplied TableModel.

Parameters:
model - A TableModel containing the table's data.

Table

public Table(TableModel model,
             TableColumnModel columnModel)
Creates a Table using the supplied TableModel.

Parameters:
model - A TableModel containing the table's data.
Method Detail

applyStyle

public void applyStyle(Style style)
Description copied from interface: Component
Sets stylistic properties of this component based on a Style object. The version of this method in Component will set foreground and background colors and the font from the style if they are present. Components should override this method if they allow more properties to be set from a style object, and should call super.applyStyle() if necessary.

Specified by:
applyStyle in interface Component
Overrides:
applyStyle in class AbstractComponent
Parameters:
style - The style object from which to retrieve properties for this Component.
See Also:
Component.applyStyle(Style)

createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()
Creates a TableColumnModel based on the present TableModel. This method is invoked automatically when the table model's structure changes if the AutoCreateColumnsFromModel flag is set.


getBorderColor

public Color getBorderColor()
Returns the border color.

Returns:
The border color.

getBorderSize

public int getBorderSize()
Returns the border size.

Returns:
The border size in pixels.

getCellMargin

public int getCellMargin()
Returns the cell margin. The default cell margin is 3 pixels.

Returns:
The cell margin in pixels.

getColumnCount

public int getColumnCount()
Returns the number of columns in the table.

Returns:
The number of columns in the table.

getColumnModel

public TableColumnModel getColumnModel()
Returns the table's column model.

Returns:
the table's column model.

getComponent

public Component getComponent(Coordinate coordinate)
Deprecated. See getRenderedComponent(Coordinate).

Returns the contents of the table cell at the specified coordinate. This method should be used only by the rendering peer. This method will not return correct information prior to balidation.


getRenderedComponent

public Component getRenderedComponent(Coordinate coordinate)
Returns the contents of the table cell at the specified coordinate. This method should be used only by the rendering peer. This method will not return correct information prior to validation.

Parameters:
coordinate - The coordinate of the rendered table cell component to return.
Returns:
The component located at the given coordinate.

getDefaultRenderer

public TableCellRenderer getDefaultRenderer(java.lang.Class columnClass)
Returns the TableCellRenderer that is used for the specified column.

Parameters:
columnClass - The class for which to return the default TableCellRenderer.
Returns:
The TableCellRenderer that will be used to render cells whose values are of the type specified in columnClass.

getHeight

public int getHeight()
Returns the overall height of the table. This property is not relevant when row heights are being measured in pixels and all rows have a height value, or if the sum of all row heights (and margins) is greater than the height value.

Returns:
The height of the table. If the height is not defined, EchoConstants.UNDEFINED_SIZE is returned.

getHeightUnits

public int getHeightUnits()
Returns the units (pixel or percent) in which column heights and overall table height are measured.

Returns:
The unit measurement, one of the following values:
  • PIXEL_UNITS (the default)
  • PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS
  • PERCENT_UNITS

getModel

public TableModel getModel()
Returns the table model.

Returns:
The table model.

getRowCount

public int getRowCount()
Returns the number of rows in the table.

Returns:
The number of rows in the table.

getRowHeight

public int getRowHeight(int row)
Returns the height of a table row. If the height is not defined, EchoConstants.UNDEFINED_SIZE is returned. The units for this value may be pixels or percentiles, based on the value of the "HeightUnits" property.

Parameters:
row - The row index.
Returns:
The height of the table row.

getTableHeader

public TableHeader getTableHeader()
Returns the TableHeader object which is responsible for rendering the table's header.

Returns:
The TableHeader used for rendering the header.

getWidth

public int getWidth()
Returns the overall width of the table. This property is not relevant when column widths are being measured in pixels and all columns have a width value, or if the sum of all columns widths (and margins) is greater than the width value.

Returns:
The width of the table. If the width is not defined, UNKNOWN_SIZE is returned.

getWidthUnits

public int getWidthUnits()
Returns the units (pixel or percent) in which column widths and overall table width are measured.

Returns:
The unit measurement, one of the following values:
  • PIXEL_UNITS (the default)
  • PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS
  • PERCENT_UNITS

invalidate

public void invalidate()
Marks the table as needing to be re-rendered.


isAutoCreateColumnsFromModel

public boolean isAutoCreateColumnsFromModel()
Returns true if the TableColumnModel will be directly derived from the TableModel. If this flag is set, changes to the TableModel will cause the TableColumnModel to be recreated. This flag is automatically set to true when the Table is created if a TableColumnModel is no specified in the constructor.

Returns:
True if the TableColumnModel will be directly derived from the TableModel.

setAutoCreateColumnsFromModel

public void setAutoCreateColumnsFromModel(boolean newValue)
Sets whether the TableColumnModel will be directly derived from the TableModel. If this flag is set, changes to the TableModel will cause the TableColumnModel to be recreated. This flag is automatically set to true when the Table is created if a TableColumnModel is no specified in the constructor.

Parameters:
newValue - True if the TableColumnModel should be directly derived from the TableModel.

setBorderColor

public void setBorderColor(Color newValue)
Sets the border color of the table.

Parameters:
newValue - The border color of the table.

setBorderSize

public void setBorderSize(int newValue)
Sets the size of the table's border.

Parameters:
newValue - The size of the table's border, in pixels.

setCellMargin

public void setCellMargin(int newValue)
Sets the cell interior margin. The default size is 3 pixels

Parameters:
newValue - The cell margin, in pixels.

setColumnModel

public void setColumnModel(TableColumnModel newValue)
Sets the column model for this table.

Parameters:
newValue - The new column model for this table.

setDefaultRenderer

public void setDefaultRenderer(java.lang.Class columnClass,
                               TableCellRenderer defaultRenderer)
Sets the default renderer that will be used for the given column class. If the provided renderer is null, removes the default renderer setting for the given column class.

Parameters:
columnClass - The class whose default renderer is to be updated.
defaultRenderer - The new default renderer for the specified column class.

setHeight

public void setHeight(int newValue)
Sets the overall height of the table. Setting this property will have no effect in the event that all rows have a height value, or if the sum of all row heights (and margins) is greater than the height value.

Parameters:
newValue - The new height of the table. To set the height to be undefined, use the EchoConstants.UNDEFINED_SIZE constant.

setHeightUnits

public void setHeightUnits(int newValue)
Sets the units (pixel or percent) in which row heights and overall table height are measured.

Parameters:
newValue - The new unit measurement, one of the following values:
  • PIXEL_UNITS (the default)
  • PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS
  • PERCENT_UNITS

setModel

public void setModel(TableModel newValue)
Sets the TableModel the Table is visualizing.

Parameters:
newValue - The new TableModel.

setRowHeight

public void setRowHeight(int row,
                         int newValue)
Sets the height of a row of the table.

Parameters:
row - The row number.
newValue - The new height of the specified row.

setTableHeader

public void setTableHeader(TableHeader newValue)
Sets the TableHeader the table uses to render the table's header.

Parameters:
newValue - The new TableHeader.

setWidth

public void setWidth(int newValue)
Sets the overall width of the table. Setting this property will have no effect in the event that all columns have a width value, or if the sum of all columns widths (and margins) is greater than the width value.

Parameters:
newValue - The new width of the table. To set the width to be undefined, use the EchoConstants.UNDEFINED_SIZE constant.

setWidthUnits

public void setWidthUnits(int newValue)
Sets the units (pixel or percent) in which column widths and overall table width are measured.

Parameters:
newValue - The new unit measurement, one of the following values:
  • PIXEL_UNITS (the default)
  • PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS
  • PERCENT_UNITS

validate

public void validate()
Updates the Table component to reflect its model.

Specified by:
validate in interface Component
Overrides:
validate in class AbstractComponent
See Also:
Component.validate()

isRemoveSelectionHandlesIfReadOnly

public boolean isRemoveSelectionHandlesIfReadOnly()

setRemoveSelectionHandlesIfReadOnly

public void setRemoveSelectionHandlesIfReadOnly(boolean removeSelectionHandlesIfReadOnly)

isContainsFastColumns

public boolean isContainsFastColumns()

setContainsFastColumns

public void setContainsFastColumns(boolean FastColumns)

isFastColumn

public boolean isFastColumn(int column)

setFastColumn

public void setFastColumn(int column,
                          boolean value)