swingx
Version 2005-08-19

org.jdesktop.swingx.table
Class TableColumnExt

java.lang.Object
  extended by javax.swing.table.TableColumn
      extended by org.jdesktop.swingx.table.TableColumnExt
All Implemented Interfaces:
Serializable, Cloneable

public class TableColumnExt
extends TableColumn
implements Cloneable

TableColumn extension which adds support for view column configuration features including column-visibility, sorting, and prototype values.

See Also:
Serialized Form

Field Summary
protected  Comparator comparator
          the comparator to use for this column
protected  boolean editable
           
protected  Object prototypeValue
           
protected  Sorter sorter
           
protected  boolean visible
           
 
Fields inherited from class javax.swing.table.TableColumn
CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, COLUMN_WIDTH_PROPERTY, HEADER_RENDERER_PROPERTY, HEADER_VALUE_PROPERTY, headerRenderer, headerValue, identifier, isResizable, maxWidth, minWidth, modelIndex, resizedPostingDisableCount, width
 
Constructor Summary
TableColumnExt()
          Creates new table view column with a model index = 0.
TableColumnExt(int modelIndex)
          Creates new table view column with the specified model index.
TableColumnExt(int modelIndex, int width)
          Creates new table view column with the specified model index and column width.
TableColumnExt(int modelIndex, int width, TableCellRenderer cellRenderer, TableCellEditor cellEditor)
          Creates new table view column with the specified model index, column width, cell renderer and cell editor.
 
Method Summary
 Object clone()
          Returns a clone of this TableColumn.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
           
 Object getClientProperty(Object key)
          Retrieves the object value using the specified key.
 Comparator getComparator()
          returns the Comparator to use for this column.
 Object getPrototypeValue()
           
 boolean getResizable()
          cosmetic override: don't fool users if resize is not possible due to fixed column width.
 Sorter getSorter()
           
 String getSorterClass()
           
 String getTitle()
          Convenience method which returns the headerValue property after converting it to a string.
 boolean isEditable()
           
 boolean isSortable()
           
 boolean isVisible()
           
 void putClientProperty(Object key, Object value)
          Stores the object value using the specified key.
 void setComparator(Comparator comparator)
          sets the comparator to use for this column.
 void setEditable(boolean editable)
          Sets the editable property.
 void setPrototypeValue(Object value)
          Sets the prototypeValue property.
 void setSorterClass(String sorterClassName)
          Sets a user-defined sorter for this column
 void setTitle(String title)
          Sets the title of this view column.
 void setVisible(boolean visible)
          Sets the visible property.
 
Methods inherited from class javax.swing.table.TableColumn
addPropertyChangeListener, createDefaultHeaderRenderer, disableResizedPosting, enableResizedPosting, getCellEditor, getCellRenderer, getHeaderRenderer, getHeaderValue, getIdentifier, getMaxWidth, getMinWidth, getModelIndex, getPreferredWidth, getPropertyChangeListeners, getWidth, removePropertyChangeListener, setCellEditor, setCellRenderer, setHeaderRenderer, setHeaderValue, setIdentifier, setMaxWidth, setMinWidth, setModelIndex, setPreferredWidth, setResizable, setWidth, sizeWidthToFit
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

editable

protected boolean editable

visible

protected boolean visible

prototypeValue

protected Object prototypeValue

sorter

protected Sorter sorter

comparator

protected Comparator comparator
the comparator to use for this column

Constructor Detail

TableColumnExt

public TableColumnExt()
Creates new table view column with a model index = 0.


TableColumnExt

public TableColumnExt(int modelIndex)
Creates new table view column with the specified model index.

Parameters:
modelIndex - index of table model column to which this view column is bound.

TableColumnExt

public TableColumnExt(int modelIndex,
                      int width)
Creates new table view column with the specified model index and column width.

Parameters:
modelIndex - index of table model column to which this view column is bound.
width - pixel width of view column

TableColumnExt

public TableColumnExt(int modelIndex,
                      int width,
                      TableCellRenderer cellRenderer,
                      TableCellEditor cellEditor)
Creates new table view column with the specified model index, column width, cell renderer and cell editor.

Parameters:
modelIndex - index of table model column to which this view column is bound.
width - pixel width of view column
cellRenderer - the cell renderer which will render all cells in this view column
cellEditor - the cell editor which will edit cells in this view column
Method Detail

getResizable

public boolean getResizable()
cosmetic override: don't fool users if resize is not possible due to fixed column width.

Overrides:
getResizable in class TableColumn

setEditable

public void setEditable(boolean editable)
Sets the editable property. This property enables the table view to control whether or not the user is permitted to edit cell values in this view column, even if the model permits. If the table model column corresponding to this view column returns true for isCellEditable and this property is false, then the user will not be permitted to edit values from this view column, dispite the model setting. If the model's isCellEditable returns false, then this property will be ignored and cell edits will not be permitted in this view column.

Parameters:
editable - boolean indicating whether or not the user may edit cell values in this view column
See Also:
isEditable(), TableModel.isCellEditable(int, int)

isEditable

public boolean isEditable()
Returns:
boolean indicating whether or not the user may edit cell values in this view column
See Also:
setEditable(boolean)

setPrototypeValue

public void setPrototypeValue(Object value)
Sets the prototypeValue property. The value should be of a type which corresponds to the column's class as defined by the table model. If non-null, the JXTable instance will use this property to calculate and set the initial preferredWidth of the column. Note that this initial preferredWidth will be overridden if the user resizes columns directly.

Parameters:
value - Object containing the value of the prototype to be used to calculate the initial preferred width of the column
See Also:
getPrototypeValue(), JXTable.getPreferredScrollableViewportSize()

getPrototypeValue

public Object getPrototypeValue()
Returns:
Object containing the value of the prototype to be used to calculate the initial preferred width of the column
See Also:
setPrototypeValue(java.lang.Object)

setSorterClass

public void setSorterClass(String sorterClassName)
Sets a user-defined sorter for this column

Parameters:
sorterClassName - String containing the name of the class which performs sorting on this view column

getSorterClass

public String getSorterClass()
Returns:
String containing the name of the class which performs sorting on this view column

getSorter

public Sorter getSorter()
Returns:
Sorter instance which performs sorting on this view column

getComparator

public Comparator getComparator()
returns the Comparator to use for this column.

Returns:
Comparator to use for this column

setComparator

public void setComparator(Comparator comparator)
sets the comparator to use for this column. Updates the column's sorter with the given comparator. NOTE: it's up to clients to not re-set the sorter's comparator somewhere else - the column cannot guarantee to keep both in synch!

Parameters:
comparator -

isSortable

public boolean isSortable()
Returns:
boolean indicating whether this view column is sortable

setTitle

public void setTitle(String title)
Sets the title of this view column. This is a convenience wrapper for setHeaderValue.

Parameters:
title - String containing the title of this view column

getTitle

public String getTitle()
Convenience method which returns the headerValue property after converting it to a string.

Returns:
String containing the title of this view column or null if no headerValue is set.

setVisible

public void setVisible(boolean visible)
Sets the visible property. This property controls whether or not this view column is currently visible in the table.

Parameters:
visible - boolean indicating whether or not this view column is visible in the table
See Also:
setVisible(boolean)

isVisible

public boolean isVisible()
Returns:
boolean indicating whether or not this view column is visible in the table
See Also:
setVisible(boolean)

putClientProperty

public void putClientProperty(Object key,
                              Object value)
Stores the object value using the specified key.

Parameters:
key - Object which is used as key to retrieve value
value - Object containing value of client property
Throws:
IllegalArgumentException - if key == null
See Also:
getClientProperty(java.lang.Object)

getClientProperty

public Object getClientProperty(Object key)
Retrieves the object value using the specified key.

Parameters:
key - Object which is used as key to retrieve value
Returns:
Object containing value of client property
See Also:
putClientProperty(java.lang.Object, java.lang.Object)

clone

public Object clone()
Returns a clone of this TableColumn. Some implementations of TableColumn may assume that all TableColumnModels are unique, therefore it is recommended that the same TableColumn instance not be added more than once to a TableColumnModel. To show TableColumns with the same column of data from the model, create a new instance with the same modelIndex.

Overrides:
clone in class Object
Returns:
a clone of this TableColumn

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)

swingx
Version 2005-08-19