|
qflib 0.98.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.qfs.lib.gui.TableModelAdapter | +--de.qfs.lib.gui.FilteredAndSortedTableModel
A TableModelAdapter that enables filtering and sorting.
This is the class that does all the hard work needed to implement tables
with filter and sort mechanisms. You will rarely need to use this class
directly as the SortedTableHelper
provides
everything that is necessary to set up filtered and sorted table.
The methods of interest to end users are getMappedRow
, getAddedRows
and clearAddedRows
.
Field Summary | |
protected TableModelFilter |
filter
The filter for the data. |
java.util.List |
indexMap
A list of indexes into the original TableModel. |
protected boolean |
mustSort
Whether indexMap must be sorted before data can be accessed. |
int |
reverseExtra
The extra space the reverseMap was built with. |
int[] |
reverseMap
An array mapping original TableModel indices to mapped inices. |
protected TableModelSorter |
sorter
The sorter for the data. |
protected de.qfs.lib.gui.FilteredAndSortedTableModel.SorterCompare |
sorterCompare
The sorter as Comparator. |
Fields inherited from class de.qfs.lib.gui.TableModelAdapter |
listeners, model |
Constructor Summary | |
FilteredAndSortedTableModel(javax.swing.table.TableModel model)
Construct a new FilteredAndSortedTableModel without filter and sorter. |
|
FilteredAndSortedTableModel(javax.swing.table.TableModel model,
TableModelFilter filter,
TableModelSorter sorter)
Construct a new FilteredAndSortedTableModel. |
Method Summary | |
void |
clearAddedRows()
Reset the buffer for added rows. |
void |
filterChanged(TableModelFilterEvent event)
Notify the FilteredAndSortedTableModel of a change in the TableModelFilter. |
int[] |
getAddedRows()
Due to filtering and sorting, the result of adding rows to a TableModel that is wrapped by a FilteredAndSortedTableModel is hardly predictable. |
TableModelFilter |
getFilter()
Get the filter for the data. |
int |
getMappedRow(int row)
Get the mapped row index for the underlying TableModel. |
int |
getRowCount()
Get the number of rows in the table. |
TableModelSorter |
getSorter()
Get the TableModelSorter for the data. |
java.lang.Object |
getValueAt(int row,
int column)
Return an attribute value for a cell. |
boolean |
isCellEditable(int row,
int column)
Get the number of columns in the table. |
void |
setFilter(TableModelFilter filter)
Set the filter for the data. |
void |
setSavedSelectionModel(javax.swing.ListSelectionModel model)
The FilteredAndSortedTableModel can keep track of the selection state in one ListSelectionModel and keep it up to date during changes to the underlying TableModel. |
void |
setSorter(TableModelSorter sorter)
Set the TableModelSorter for the data. |
void |
setValueAt(java.lang.Object aValue,
int row,
int column)
Set the attribute value for a cell. |
void |
sortOrderChanged(TableModelSorterEvent e)
Notify the FilteredAndSortedTableModel of a change in the sort order. |
void |
tableChanged(javax.swing.event.TableModelEvent e)
Called, when the wrapped model has changed in some way. |
Methods inherited from class de.qfs.lib.gui.TableModelAdapter |
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getModel, removeTableModelListener, setModel |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected TableModelFilter filter
protected TableModelSorter sorter
protected de.qfs.lib.gui.FilteredAndSortedTableModel.SorterCompare sorterCompare
public java.util.List indexMap
protected boolean mustSort
public int[] reverseMap
public int reverseExtra
Constructor Detail |
public FilteredAndSortedTableModel(javax.swing.table.TableModel model)
model
- The TableModel to wrap.public FilteredAndSortedTableModel(javax.swing.table.TableModel model, TableModelFilter filter, TableModelSorter sorter)
model
- The TableModel to wrap.filter
- The TableModelFilter for the data.sorter
- The TableModelSorter that imposes the order on
the data.Method Detail |
public final TableModelFilter getFilter()
public void setFilter(TableModelFilter filter)
filter
- The filter to set.public void sortOrderChanged(TableModelSorterEvent e)
sortOrderChanged
in interface TableModelSorterListener
e
- The event holding the details.public final TableModelSorter getSorter()
public void setSorter(TableModelSorter sorter)
sorter
- The TableModelSorter to set.public void filterChanged(TableModelFilterEvent event)
filterChanged
in interface TableModelFilterListener
event
- Details about the change.public java.lang.Object getValueAt(int row, int column)
getValueAt
in class TableModelAdapter
row
- The row whose value is to be looked up.column
- The column whose value is to be looked up.public void setValueAt(java.lang.Object aValue, int row, int column)
setValueAt
in class TableModelAdapter
value
- The value to set.row
- The row whose value is to be set.column
- The column whose value is to be set.public int getRowCount()
getRowCount
in class TableModelAdapter
public boolean isCellEditable(int row, int column)
isCellEditable
in class TableModelAdapter
public void tableChanged(javax.swing.event.TableModelEvent e)
tableChanged
in class TableModelAdapter
event
- The event that happened.public int getMappedRow(int row)
row
- The index in the FilteredAndSortedTableModel.public int[] getAddedRows()
clearAddedRows
, setSorter
, sortOrderChanged
, setFilter
or
filterChanged
. This method does NOT clear that
state.public void clearAddedRows()
public void setSavedSelectionModel(javax.swing.ListSelectionModel model)
model
- The ListSelectionModel whose selection to save.
|
qflib 0.98.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |