T - the sorted typepublic class FormTableSorter<T> extends FormTableMap<T> implements MouseListener
modellistenerList| Constructor and Description |
|---|
FormTableSorter(AbstractFormTableModel<T> model)
Create a form table sorter on top of a given table model.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMouseListenerForHeaderOfTable()
Installs a Mouse-Listener to the table header.
Mouse clicks on a column header will be treated as follows: single click: add column to sort criteria double click: add column and run the sort Pressing the shift key switches to descending order for the column. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a property change listener (used if sorting has changed)
|
void |
addSortIndex(int column)
Adds a sort index.
|
void |
clearMapping()
Clears the mapping.
|
void |
clearSorting()
Clears the sorting
|
FormTableEntry<T> |
getEntryAt(int rowIndex)
Gets the form table entry at given row.
|
int |
getMappedIndex(int mappedRow)
Gets the mapped row index according to a given model row.
Inversion of getModelIndex(). |
int[] |
getMappedIndex(int[] mappedRows)
Gets the mapped row indexes according to given model rows.
Inversion of getModelIndex(). |
int |
getModelIndex(int row)
Gets the row in the original model according to the
mapping.
The default implementation returns the same row. |
int[] |
getModelIndex(int[] rows)
Gets the rows in the original model according to the
mapping.
The default implementation returns the same rows. |
int |
getRowCount() |
int[] |
getSorting()
Gets the sort indexes.
|
String |
getSortNames()
Gets a string containing the (displayed) field-names of the current sorting.
|
FormTableEntry<T> |
getSumEntry() |
Object |
getValueAt(int rowIndex,
int columnIndex) |
boolean |
isCellEditable(int rowIndex,
int columnIndex) |
boolean |
isSorted()
Determines whether the table is sorted.
|
void |
mouseClicked(MouseEvent e) |
void |
mouseEntered(MouseEvent e) |
void |
mouseExited(MouseEvent e) |
void |
mousePressed(MouseEvent e) |
void |
mouseReleased(MouseEvent e) |
void |
removeMouseListenerForHeaderOfTable()
Removes the mouse header listeners.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener.
|
void |
setSorting(int[] sortby)
Sets the sort indexes
|
void |
setSumEntry(FormTableEntry<T> sumEntry)
Sets a table entry to sum up the rows.
|
void |
setTable(FormTable<T> table)
Sets the table.
|
void |
setValueAt(Object aValue,
int rowIndex,
int columnIndex) |
void |
sort()
Do the sort
|
void |
tableChanged(TableModelEvent e)
Table data has changed from unterlying tablemodel:
sort data and redisplay.
|
getColumnClass, getColumnCount, getColumnName, getDisplayedColumnName, getModel, getTemplate, isDataChanged, setDataChanged, setModelgetMap, getTable, setEntryAt, setMapaddTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListenerpublic FormTableSorter(AbstractFormTableModel<T> model)
model - the chained table modelpublic void setTable(FormTable<T> table)
If the table is set the selections will be kept across sortings. Otherwise the selections will be cleared. A mouse listener will also be registered for the table.
setTable in class AbstractFormTableModel<T>table - the form table or null if this model is not the direct data model for the table
(i.e. somewhere in a chain)addMouseListenerForHeaderOfTable()public void setSumEntry(FormTableEntry<T> sumEntry)
sumEntry - the summing table entrypublic FormTableEntry<T> getSumEntry()
public int getRowCount()
getRowCount in interface TableModelgetRowCount in class FormTableMap<T>public Object getValueAt(int rowIndex, int columnIndex)
FormTableMapThis method must be overridden for another mapping than 1:1.
getValueAt in interface TableModelgetValueAt in class FormTableMap<T>public void setValueAt(Object aValue, int rowIndex, int columnIndex)
FormTableMapThis method must be overridden for another mapping than 1:1.
setValueAt in interface TableModelsetValueAt in class FormTableMap<T>public boolean isCellEditable(int rowIndex,
int columnIndex)
isCellEditable in interface TableModelisCellEditable in class FormTableMap<T>public FormTableEntry<T> getEntryAt(int rowIndex)
AbstractFormTableModelgetEntryAt in class FormTableMap<T>rowIndex - the row of the table entrypublic int getMappedIndex(int mappedRow)
AbstractFormTableModelgetMappedIndex in class FormTableMap<T>mappedRow - the original rowpublic int[] getMappedIndex(int[] mappedRows)
AbstractFormTableModelgetMappedIndex in class FormTableMap<T>mappedRows - the original rowspublic int getModelIndex(int row)
AbstractFormTableModelgetModelIndex in class FormTableMap<T>row - the row of this modelpublic int[] getModelIndex(int[] rows)
AbstractFormTableModelgetModelIndex in class FormTableMap<T>rows - the array of rows of this modelpublic void addSortIndex(int column)
column - the column index to addpublic void sort()
public void clearMapping()
public void clearSorting()
public int[] getSorting()
public void setSorting(int[] sortby)
sortby - the array of column indexes, null to clear sortingpublic boolean isSorted()
public String getSortNames()
public void tableChanged(TableModelEvent e)
Event handler for TableModelListener: table data has changed.
This method must be overridden for another mapping than 1:1.
The default implementation just invokes fireTableChanged.
tableChanged in interface TableModelListenertableChanged in class FormTableMap<T>e - the table model eventpublic void addPropertyChangeListener(PropertyChangeListener listener)
listener - the listener to addpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener - the listener to removepublic void addMouseListenerForHeaderOfTable()
public void removeMouseListenerForHeaderOfTable()
public void mouseClicked(MouseEvent e)
mouseClicked in interface MouseListenerpublic void mouseEntered(MouseEvent e)
mouseEntered in interface MouseListenerpublic void mouseExited(MouseEvent e)
mouseExited in interface MouseListenerpublic void mousePressed(MouseEvent e)
mousePressed in interface MouseListenerpublic void mouseReleased(MouseEvent e)
mouseReleased in interface MouseListenerTentackle - a domain driven enterprise framework