de.muntjak.tinylookandfeel.controlpanel
Class TinyTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by de.muntjak.tinylookandfeel.controlpanel.NonSortableTableModel
          extended by de.muntjak.tinylookandfeel.controlpanel.TinyTableModel
All Implemented Interfaces:
SortableTableData, java.io.Serializable, javax.swing.table.TableModel

public class TinyTableModel
extends NonSortableTableModel
implements SortableTableData

An example table model implementing SortableTableData. See de.muntjak.tinylookandfeel.controlpanel.NonSortableTableModel for details about the data structure.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class de.muntjak.tinylookandfeel.controlpanel.NonSortableTableModel
NonSortableTableModel.Record, NonSortableTableModel.TableColorIcon
 
Field Summary
 
Fields inherited from class de.muntjak.tinylookandfeel.controlpanel.NonSortableTableModel
data
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface de.muntjak.tinylookandfeel.table.SortableTableData
SORT_ASCENDING, SORT_DESCENDING
 
Constructor Summary
TinyTableModel()
           
 
Method Summary
 boolean isColumnSortable(int column)
          Return true if the specified column is sortable, false otherwise.
 void sortColumns(int[] columns, int[] sortingDirections, javax.swing.JTable table)
          Sort the data according to the given arguments.
 boolean supportsMultiColumnSort()
          Return true if the table model supports multiple sorted columns, false otherwise.
 
Methods inherited from class de.muntjak.tinylookandfeel.controlpanel.NonSortableTableModel
addColumn, createNewData, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeAllRows, removeColumn, setValueAt
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TinyTableModel

public TinyTableModel()
Method Detail

isColumnSortable

public boolean isColumnSortable(int column)
Description copied from interface: SortableTableData
Return true if the specified column is sortable, false otherwise. Non-sortable column headers will not react to mouse clicks or rollovers.

Specified by:
isColumnSortable in interface SortableTableData
Parameters:
column - a column index
Returns:
true if the specified column is sortable, false otherwise

supportsMultiColumnSort

public boolean supportsMultiColumnSort()
Description copied from interface: SortableTableData
Return true if the table model supports multiple sorted columns, false otherwise. (Supporting multi column sort makes sense only with columns containing some equal values.)

The TinyLaF user gestures concerning multi column sort are:

Specified by:
supportsMultiColumnSort in interface SortableTableData
Returns:
true if the table model supports multiple sorted columns, false otherwise

sortColumns

public void sortColumns(int[] columns,
                        int[] sortingDirections,
                        javax.swing.JTable table)
Description copied from interface: SortableTableData
Sort the data according to the given arguments. If argument arrays are empty, the original state of the data will be restored, if there is no original state then no action will be performed.

Note for implementors: If your data is dynamically changing you should think about storing copies of the arguments so you can re-sort data after each change. It may also be a good idea to call fireTableDataChanged() after sorting (this makes sure that the table is updated).

Specified by:
sortColumns in interface SortableTableData
Parameters:
columns - array of column indices sorted by priority (highest priority first)
sortingDirections - array containing the sorting direction for each sorted column. Values are either
  • SORT_ASCENDING - sort column data in ascending order, or
  • SORT_DESCENDING - sort column data in descending order
table - the table displaying the data. Might be useful, for example, to restore selected cells after sorting.