|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.table.AbstractTableModel
org.tentackle.ui.AbstractFormTableModel
org.tentackle.ui.FormTableMap
org.tentackle.ui.FormTableSorter
public class FormTableSorter
A table model and mapper to sort rows.
| Field Summary |
|---|
| Fields inherited from class org.tentackle.ui.FormTableMap |
|---|
model |
| Fields inherited from class javax.swing.table.AbstractTableModel |
|---|
listenerList |
| Constructor Summary | |
|---|---|
FormTableSorter(AbstractFormTableModel model)
Create a form table sorter on top of a given table model. |
|
| Method Summary | |
|---|---|
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 |
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()
Returns the number of rows in the model. |
int[] |
getSorting()
Gets the sort indexes. |
String |
getSortNames()
Gets a string containing the (displayed) field-names of the current sorting. |
FormTableEntry |
getSumEntry()
|
Object |
getValueAt(int rowIndex,
int columnIndex)
Returns the value for the cell at columnIndex and
rowIndex. |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Returns false. |
boolean |
isSorted()
Determines whether the table is sorted. |
void |
mouseClicked(MouseEvent e)
Invoked when the mouse button has been clicked (pressed and released) on a component. |
void |
mouseEntered(MouseEvent e)
Invoked when the mouse enters a component. |
void |
mouseExited(MouseEvent e)
Invoked when the mouse exits a component. |
void |
mousePressed(MouseEvent e)
Invoked when a mouse button has been pressed on a component. |
void |
mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a component. |
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 sumEntry)
Sets a table entry to sum up the rows. |
void |
setTable(FormTable table)
Sets the table. |
void |
setValueAt(Object aValue,
int rowIndex,
int columnIndex)
This empty implementation is provided so users don't have to implement this method if their data model is not editable. |
void |
sort()
Do the sort |
void |
tableChanged(TableModelEvent e)
Table data has changed from unterlying tablemodel: sort data and redisplay. |
| Methods inherited from class org.tentackle.ui.FormTableMap |
|---|
getColumnClass, getColumnCount, getColumnName, getDisplayedColumnName, getModel, getTemplate, isDataChanged, setDataChanged, setModel |
| Methods inherited from class org.tentackle.ui.AbstractFormTableModel |
|---|
getMap, getTable, setEntryAt, setMap |
| 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 |
|---|
public FormTableSorter(AbstractFormTableModel model)
model - the chained table model| Method Detail |
|---|
public void setTable(FormTable 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 AbstractFormTableModeltable - 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 sumEntry)
sumEntry - the summing table entrypublic FormTableEntry getSumEntry()
public int getRowCount()
javax.swing.table.TableModelJTable uses this method to determine how many rows it
should display. This method should be quick, as it
is called frequently during rendering.
getRowCount in interface TableModelgetRowCount in class FormTableMapTableModel.getColumnCount()
public Object getValueAt(int rowIndex,
int columnIndex)
FormTableMapcolumnIndex and
rowIndex.
This method must be overridden for another mapping than 1:1.
getValueAt in interface TableModelgetValueAt in class FormTableMaprowIndex - the row whose value is to be queriedcolumnIndex - the column whose value is to be queried
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 FormTableMapaValue - value to assign to cellrowIndex - row of cellcolumnIndex - column of cellTableModel.getValueAt(int, int),
TableModel.isCellEditable(int, int)
public boolean isCellEditable(int rowIndex,
int columnIndex)
javax.swing.table.AbstractTableModel
isCellEditable in interface TableModelisCellEditable in class FormTableMaprowIndex - the row being queriedcolumnIndex - the column being queried
TableModel.setValueAt(java.lang.Object, int, int)public FormTableEntry getEntryAt(int rowIndex)
AbstractFormTableModel
getEntryAt in class FormTableMaprowIndex - the row of the table entry
public int getMappedIndex(int mappedRow)
AbstractFormTableModel
getMappedIndex in class FormTableMapmappedRow - the original row
public int[] getMappedIndex(int[] mappedRows)
AbstractFormTableModel
getMappedIndex in class FormTableMapmappedRows - the original rows
public int getModelIndex(int row)
AbstractFormTableModel
getModelIndex in class FormTableMaprow - the row of this model
public int[] getModelIndex(int[] rows)
AbstractFormTableModel
getModelIndex in class FormTableMaprows - the array of rows of this model
public 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)
This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.
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 FormTableMape - 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)
java.awt.event.MouseListener
mouseClicked in interface MouseListenerpublic void mouseEntered(MouseEvent e)
java.awt.event.MouseListener
mouseEntered in interface MouseListenerpublic void mouseExited(MouseEvent e)
java.awt.event.MouseListener
mouseExited in interface MouseListenerpublic void mousePressed(MouseEvent e)
java.awt.event.MouseListener
mousePressed in interface MouseListenerpublic void mouseReleased(MouseEvent e)
java.awt.event.MouseListener
mouseReleased in interface MouseListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||