Package org.apache.jorphan.gui
Class ObjectTableSorter
Implementation of a
RowSorter
for ObjectTableModel
- Since:
- 3.2
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
class
View row with model mapping.Nested classes/interfaces inherited from class javax.swing.RowSorter
RowSorter.SortKey
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
int
convertRowIndexToModel
(int index) int
convertRowIndexToView
(int index) Setsprimary comparator
to one that don't sort last row.protected Comparator<ObjectTableSorter.Row>
protected Comparator<?>
getDefaultComparator
(int column) Builds a default comparator based on model column class.Returns Comparator if all sorted columns matches.getModel()
int
Returns Comparator used prior to sorted columns.List<? extends RowSorter.SortKey>
Comparator<?>
getValueComparator
(int column) Returns Comparator used on column.int
protected void
protected boolean
isSortable
(int column) protected boolean
isSorted()
protected boolean
isSorted
(int column) void
protected void
rowsChanged
(int firstRow, int endRow, boolean deleted, boolean inserted) void
rowsDeleted
(int firstRow, int endRow) void
rowsInserted
(int firstRow, int endRow) void
rowsUpdated
(int firstRow, int endRow) void
rowsUpdated
(int firstRow, int endRow, int column) setFallbackComparator
(Comparator<ObjectTableSorter.Row> comparator) Sets a fallback comparator (defaults to model index comparison) if noneprimary
, neithercolumn value comparators
can make differences between two rows.setPrimaryComparator
(Comparator<ObjectTableSorter.Row> primaryComparator) Comparator used prior to sorted columns.void
setSortKey
(RowSorter.SortKey sortkey) void
setSortKeys
(List<? extends RowSorter.SortKey> keys) setValueComparator
(int column, Comparator<?> comparator) Assign comparator to given column, ifnull
a getDefaultComparator(int) default one is used instead.protected void
sort()
Sort tablevoid
toggleSortOrder
(int column) protected void
fill in modelToView list with index of viewprotected void
validate()
Methods inherited from class javax.swing.RowSorter
addRowSorterListener, fireRowSorterChanged, fireSortOrderChanged, removeRowSorterListener
-
Constructor Details
-
ObjectTableSorter
-
-
Method Details
-
getPrimaryComparator
Returns Comparator used prior to sorted columns.- Returns:
- Comparator used prior to sorted columns.
-
getValueComparator
Returns Comparator used on column.- Parameters:
column
- to be compared- Returns:
- Comparator used on column.
-
getFallbackComparator
Returns Comparator if all sorted columns matches. Defaults to model index comparison.- Returns:
- Comparator if all sorted columns matches. Defaults to model index comparison.
-
setPrimaryComparator
Comparator used prior to sorted columns.- Parameters:
primaryComparator
-Comparator
to be used first- Returns:
this
-
fixLastRow
Setsprimary comparator
to one that don't sort last row.- Returns:
this
-
setValueComparator
Assign comparator to given column, ifnull
a getDefaultComparator(int) default one is used instead.- Parameters:
column
- Model column index.comparator
- Column value comparator.- Returns:
this
-
getDefaultComparator
Builds a default comparator based on model column class.Collator.getInstance()
forString
,natural order
forComparable
, no sort support for others.- Parameters:
column
- Model column index.- Returns:
- default
Comparator
-
setFallbackComparator
Sets a fallback comparator (defaults to model index comparison) if noneprimary
, neithercolumn value comparators
can make differences between two rows.- Parameters:
comparator
- to be used, when all otherComparator
s can't see a difference- Returns:
this
-
getModel
- Specified by:
getModel
in classRowSorter<ObjectTableModel>
-
toggleSortOrder
public void toggleSortOrder(int column) - Specified by:
toggleSortOrder
in classRowSorter<ObjectTableModel>
-
convertRowIndexToModel
public int convertRowIndexToModel(int index) - Specified by:
convertRowIndexToModel
in classRowSorter<ObjectTableModel>
-
convertRowIndexToView
public int convertRowIndexToView(int index) - Specified by:
convertRowIndexToView
in classRowSorter<ObjectTableModel>
-
setSortKeys
- Specified by:
setSortKeys
in classRowSorter<ObjectTableModel>
-
setSortKey
-
getSortKeys
- Specified by:
getSortKeys
in classRowSorter<ObjectTableModel>
-
getViewRowCount
public int getViewRowCount()- Specified by:
getViewRowCount
in classRowSorter<ObjectTableModel>
-
getModelRowCount
public int getModelRowCount()- Specified by:
getModelRowCount
in classRowSorter<ObjectTableModel>
-
modelStructureChanged
public void modelStructureChanged()- Specified by:
modelStructureChanged
in classRowSorter<ObjectTableModel>
-
allRowsChanged
public void allRowsChanged()- Specified by:
allRowsChanged
in classRowSorter<ObjectTableModel>
-
rowsInserted
public void rowsInserted(int firstRow, int endRow) - Specified by:
rowsInserted
in classRowSorter<ObjectTableModel>
-
rowsDeleted
public void rowsDeleted(int firstRow, int endRow) - Specified by:
rowsDeleted
in classRowSorter<ObjectTableModel>
-
rowsUpdated
public void rowsUpdated(int firstRow, int endRow) - Specified by:
rowsUpdated
in classRowSorter<ObjectTableModel>
-
rowsChanged
protected void rowsChanged(int firstRow, int endRow, boolean deleted, boolean inserted) -
rowsUpdated
public void rowsUpdated(int firstRow, int endRow, int column) - Specified by:
rowsUpdated
in classRowSorter<ObjectTableModel>
-
isSortable
protected boolean isSortable(int column) -
isSorted
protected boolean isSorted(int column) -
isSorted
protected boolean isSorted() -
invalidate
protected void invalidate() -
validate
protected void validate() -
getComparatorFromSortKey
-
sort
protected void sort()Sort table -
updateModelToView
protected void updateModelToView()fill in modelToView list with index of view
-