com.arsdigita.bebop.table
Class TableColumn

java.lang.Object
  extended bycom.arsdigita.bebop.Completable
      extended bycom.arsdigita.bebop.SimpleComponent
          extended bycom.arsdigita.bebop.table.TableColumn
All Implemented Interfaces:
Cloneable, Component, Lockable
Direct Known Subclasses:
DataTable.SortableTableColumn

public class TableColumn
extends SimpleComponent
implements Lockable

One column in a table. The TableColumn stores important display-related information about a table column, such as the column header, the renderers for the column header and ordinary cells in this column and from which column in the table model values should be taken when rendering table cells. The set of table columns for a table is maintained by a TableColumnModel.

TableColumn allows the column ordering to be different between the underlying TableModel and the view presented by the Table: each column contains a modelIndex property. This is the column that is retrieved from the TableModel when the values are displayed, regardless of the position of the TableColumn in the TableColumnModel. This makes it possible to display the same table model in several tables with reordered or omitted columns.

The TableColumn stores also the value and key used for the header of the column. These objects are passed to the header cell renderer when the header of the table is rendered. The value is usually used to generate the visible information for the table header, and is often a string. The key is usually used to identify the underlying object, or to just identify the column, and can be any object whose toString() method returns a representation that can be included in a URL. In the simplest case, this may just be an Integer containing the index of the column in the column model.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/table/TableColumn.java#9 $
Author:
David Lutterkort
See Also:
Table, TableColumnModel

Field Summary
static String versionId
           
 
Fields inherited from class com.arsdigita.bebop.SimpleComponent
m_attr
 
Fields inherited from interface com.arsdigita.bebop.Component
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE
 
Constructor Summary
TableColumn()
          Creates a new table column with modelIndex 0 and header value and key equal to null.
TableColumn(int modelIndex)
          Creates a new table column with the given modelIndex and header value and key equal to null.
TableColumn(int modelIndex, Object value)
          Creates a new table column with the given modelIndex and header value.
TableColumn(int modelIndex, Object value, Object key)
          Creates a new table column with the given modelIndex and header value and key.
 
Method Summary
 void exportCellAttributes(Element e)
          Add all the XML attributes for this column.
 void generateXML(PageState s, Element e)
          Throw an UnsupportedOperationException.
 TableCellRenderer getCellRenderer()
          Return the renderer used for the cells in this column.
 Object getHeaderKey()
          Get the key used to identify the header of this column.
 TableCellRenderer getHeaderRenderer()
          Return the renderer used for the column header.
 Object getHeaderValue()
          Get the display value used for the header.
 int getModelIndex()
          Get the index of the column from which values are taken in the TableModel.
 String getWidth()
          Get the width for this column.
 void setAlign(String v)
          Set the horizontal alignment this column.
 void setCellRenderer(TableCellRenderer v)
          Set the renderer used for cells in this column.
 void setClassAttr(String c)
          Sets the class attribute for the column's cells.
 void setHeadAlign(String v)
          Set the horizontal alignment this column's header.
 void setHeadClassAttr(String c)
          Sets the class attribute for the column's header cell.
 void setHeaderKey(Object key)
          Set the key used to identify the header of this column.
 void setHeaderRenderer(TableCellRenderer v)
          Set the renderer used for the column header.
 void setHeaderValue(Object value)
          Set the display value for the header.
 void setHeadStyleAttr(String style)
          Sets the style attribute for the column's header cell.
 void setHeadVAlign(String v)
          Set the vertical alignment this column's header.
 void setModelIndex(int v)
          Set the index of the column in the TableModel from which the values are taken when this column is rendered.
 void setStyleAttr(String style)
          Sets the style attribute for the column's cells.
 void setVAlign(String v)
          Set the vertical alignment this column.
 void setWidth(String v)
          Set the width of this column.
 
Methods inherited from class com.arsdigita.bebop.SimpleComponent
children, clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, lock, register, register, respond, setAttribute, setIdAttr, setKey, setMetaDataAttribute, setVisible
 
Methods inherited from class com.arsdigita.bebop.Completable
addCompletionListener, fireCompletionEvent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.arsdigita.util.Lockable
isLocked, lock
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

TableColumn

public TableColumn()
Creates a new table column with modelIndex 0 and header value and key equal to null.


TableColumn

public TableColumn(int modelIndex)
Creates a new table column with the given modelIndex and header value and key equal to null.

Parameters:
modelIndex - the index of the column in the table model from which to retrieve values

TableColumn

public TableColumn(int modelIndex,
                   Object value)
Creates a new table column with the given modelIndex and header value. The header key is equal to null.

Parameters:
modelIndex - the index of the column in the table model from which to retrieve values.
value - the value for the column header.

TableColumn

public TableColumn(int modelIndex,
                   Object value,
                   Object key)
Creates a new table column with the given modelIndex and header value and key.

Parameters:
modelIndex - the index of the column in the table model from which to retrieve values.
value - the value for the column header.
key - the key for the column header.
Method Detail

getHeaderRenderer

public final TableCellRenderer getHeaderRenderer()
Return the renderer used for the column header. This is null by default, in which case the default renderer for the TableHeader of the table to which this column belongs is used.

Returns:
the renderer used for the column header.

setHeaderRenderer

public void setHeaderRenderer(TableCellRenderer v)
Set the renderer used for the column header. The header key and value objects are passed to the renderer when the column header will be rendererd.

Parameters:
v - the new renderer for the column header.
See Also:
getHeaderRenderer(), getCellRenderer()

getCellRenderer

public final TableCellRenderer getCellRenderer()
Return the renderer used for the cells in this column. This is null by default, in which case the default renderer of the table to which this column belongs is used.

Returns:
the renderer used for the cells in this column.

setCellRenderer

public void setCellRenderer(TableCellRenderer v)
Set the renderer used for cells in this column.

Parameters:
v - the new renderer for the cells in this column.
See Also:
getCellRenderer(), getHeaderRenderer()

getHeaderValue

public final Object getHeaderValue()
Get the display value used for the header. This is the object that is passed to the renderer, often a string.

Returns:
the display value for the header.

setHeaderValue

public void setHeaderValue(Object value)
Set the display value for the header. This object is passed through to the header renderer without any modifications.

Parameters:
value - the new display value for the header.
See Also:
getHeaderValue()

getHeaderKey

public final Object getHeaderKey()
Get the key used to identify the header of this column. In the simplest case, this is an Integer containing the index of the column.

Returns:
the key used to identify the header of this column.

setHeaderKey

public void setHeaderKey(Object key)
Set the key used to identify the header of this column.

Parameters:
key - the new key for identifying the header of this column.
See Also:
getHeaderKey()

getModelIndex

public final int getModelIndex()
Get the index of the column from which values are taken in the TableModel.

Returns:
the index of the column in the table model from which values are taken.
See Also:
setModelIndex

setModelIndex

public void setModelIndex(int v)
Set the index of the column in the TableModel from which the values are taken when this column is rendered.

Parameters:
v - the new index of the column in the table model from which to take values.

getWidth

public String getWidth()
Get the width for this column.

Returns:
the width of this column.
See Also:
setWidth

setWidth

public void setWidth(String v)
Set the width of this column. The string v is added as an attribute to the XML element for this column in the table header.

Parameters:
v - the width of this column

setAlign

public void setAlign(String v)
Set the horizontal alignment this column. The string v is added as an attribute to the XML element for each cell in this column

Parameters:
v - the width of this column

setHeadAlign

public void setHeadAlign(String v)
Set the horizontal alignment this column's header. The string v is added as an attribute to the XML element for the column's header cell.

Parameters:
v - the width of this column

setVAlign

public void setVAlign(String v)
Set the vertical alignment this column. The string v is added as an attribute to the XML element for each cell in this column

Parameters:
v - the width of this column

setHeadVAlign

public void setHeadVAlign(String v)
Set the vertical alignment this column's header. The string v is added as an attribute to the XML element for this column's header cell.

Parameters:
v - the width of this column

setStyleAttr

public void setStyleAttr(String style)
Sets the style attribute for the column's cells. style should be a valid CSS style, since its value will be copied verbatim to the output and appear as a style attribute in the top level XML or HTML output element.

Specified by:
setStyleAttr in interface Component
Overrides:
setStyleAttr in class SimpleComponent
Parameters:
style - a valid CSS style description for use in the style attribute of an HTML tag
See Also:
Standard Attributes

setHeadStyleAttr

public void setHeadStyleAttr(String style)
Sets the style attribute for the column's header cell. style should be a valid CSS style, since its value will be copied verbatim to the output and appear as a style attribute in the top level XML or HTML output element.

Parameters:
style - a valid CSS style description for use in the style attribute of an HTML tag
See Also:
Standard Attributes

setClassAttr

public void setClassAttr(String c)
Sets the class attribute for the column's cells. style should be the name of a defined CSS class, since its value will be copied verbatim to the output and appear as a class attribute in the top level XML or HTML output element.

Specified by:
setClassAttr in interface Component
Overrides:
setClassAttr in class SimpleComponent
Parameters:
c - a valid XML name
See Also:
Standard Attributes

setHeadClassAttr

public void setHeadClassAttr(String c)
Sets the class attribute for the column's header cell. style should be the name of a defined CSS class, since its value will be copied verbatim to the output and appear as a class attribute in the top level XML or HTML output element.

See Also:
Standard Attributes

exportCellAttributes

public void exportCellAttributes(Element e)
Add all the XML attributes for this column.

Parameters:
e - the XML element to which attributes will be added.

generateXML

public void generateXML(PageState s,
                        Element e)
Throw an UnsupportedOperationException. This method can only be called if the table column is not properly contained in a table.

Specified by:
generateXML in interface Component
Overrides:
generateXML in class SimpleComponent
Parameters:
s - represents the current request
e - the parent element


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC