org.jcreme.swing.table
Class SortableTableColumn

java.lang.Object
  extended byjavax.swing.table.TableColumn
      extended byorg.jcreme.swing.table.SortableTableColumn
All Implemented Interfaces:
java.io.Serializable

public class SortableTableColumn
extends javax.swing.table.TableColumn

This is an extension of the standard table columns. The additional features are the ability to handle an order and a comparator. These can be used to implement sorted tables.

Version:
$Revision: 1.1 $
Author:
$Author: dbregeon $
See Also:
Serialized Form

Field Summary
 
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
SortableTableColumn()
          Creates new SortableTableColumn
SortableTableColumn(int modelIndex)
          Creates new SortableTableColumn
SortableTableColumn(int modelIndex, int width)
          Creates new SortableTableColumn
SortableTableColumn(int modelIndex, int width, javax.swing.table.TableCellRenderer cellRenderer, javax.swing.table.TableCellEditor cellEditor)
          Creates new SortableTableColumn
 
Method Summary
 void addTableColumnOrderListener(TableColumnOrderListener listener)
          Enables to add a listener that will be activated every time changes happen in the column that may alter the order of the values.
protected  void fireTableColumnOrderEvent(TableColumnOrderEvent event)
          The method called to activate the listeners.
 java.lang.Class getColumnClass()
          Gives access to the Class of the elements presented in this Column.
 ComparatorType getComparator()
          Gives access to the comparator that is in use in this column.
 SortOrder getOrder()
          Gives access to the sort order of the column.
 java.lang.Integer getOrderInSort()
          Gives access to the order of the column in the sort.
 void removeTableColumnOrderListener(TableColumnOrderListener listener)
          Removes a listener from the list of the registered listeners.
 void setColumnClass(java.lang.Class clazz)
          Enables to change the Class of the elements presented in this Column.
 void setComparator(ComparatorType cmp)
          This method enables to set a custom comparator for this column.
 void setOrder(SortOrder order)
          This method enables to set the sort order (ascending, descending, none) for the given column.
 void setOrderInSort(java.lang.Integer orderInSort)
          Enables to change the order of the column in the sort.
 
Methods inherited from class javax.swing.table.TableColumn
addPropertyChangeListener, createDefaultHeaderRenderer, disableResizedPosting, enableResizedPosting, getCellEditor, getCellRenderer, getHeaderRenderer, getHeaderValue, getIdentifier, getMaxWidth, getMinWidth, getModelIndex, getPreferredWidth, getPropertyChangeListeners, getResizable, getWidth, removePropertyChangeListener, setCellEditor, setCellRenderer, setHeaderRenderer, setHeaderValue, setIdentifier, setMaxWidth, setMinWidth, setModelIndex, setPreferredWidth, setResizable, setWidth, sizeWidthToFit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortableTableColumn

public SortableTableColumn()
Creates new SortableTableColumn


SortableTableColumn

public SortableTableColumn(int modelIndex)
Creates new SortableTableColumn

Parameters:
modelIndex - the index of the column in the column model.

SortableTableColumn

public SortableTableColumn(int modelIndex,
                           int width)
Creates new SortableTableColumn

Parameters:
modelIndex - the index of the column in the column model.
width - the width of the column.

SortableTableColumn

public SortableTableColumn(int modelIndex,
                           int width,
                           javax.swing.table.TableCellRenderer cellRenderer,
                           javax.swing.table.TableCellEditor cellEditor)
Creates new SortableTableColumn

Parameters:
modelIndex - the index of the column in the column model.
width - the width of the column.
cellRenderer - the renderer to use to display the values in this column.
cellEditor - the editor to use to edit the values in this column.
Method Detail

setOrder

public void setOrder(SortOrder order)
This method enables to set the sort order (ascending, descending, none) for the given column. The column will not be used in any sort if it has a SortOrder NONE or null.

Parameters:
order - the custom order. Erase any previously set SortOrder if it is null or SortOrder.NONE.

getOrder

public SortOrder getOrder()
Gives access to the sort order of the column.

Returns:
the SortOrder associated to the column.

setOrderInSort

public void setOrderInSort(java.lang.Integer orderInSort)
Enables to change the order of the column in the sort.

Parameters:
orderInSort - the new order of the column in the sort.

getOrderInSort

public java.lang.Integer getOrderInSort()
Gives access to the order of the column in the sort.

Returns:
the current order of the column in the sort.

setColumnClass

public void setColumnClass(java.lang.Class clazz)
Enables to change the Class of the elements presented in this Column.

Parameters:
clazz -

getColumnClass

public java.lang.Class getColumnClass()
Gives access to the Class of the elements presented in this Column.

Returns:
the Class of the elements in this Column.

setComparator

public void setComparator(ComparatorType cmp)
This method enables to set a custom comparator for this column.

Parameters:
cmp - the custom comparator. Erase any previously set comparator if it is null.

getComparator

public ComparatorType getComparator()
Gives access to the comparator that is in use in this column.

Returns:
the comparator to used on values found in this column.

addTableColumnOrderListener

public void addTableColumnOrderListener(TableColumnOrderListener listener)
Enables to add a listener that will be activated every time changes happen in the column that may alter the order of the values. (namely the order or the comparator).

Parameters:
listener - the listener to notify.

removeTableColumnOrderListener

public void removeTableColumnOrderListener(TableColumnOrderListener listener)
Removes a listener from the list of the registered listeners.

Parameters:
listener - the listener to remove.

fireTableColumnOrderEvent

protected void fireTableColumnOrderEvent(TableColumnOrderEvent event)
The method called to activate the listeners.

Parameters:
event - the event to send to the listeners.


Copyright 2006 null. All Rights Reserved.