Package org.apache.jorphan.gui
Class ObjectTableSorter
Implementation of a
RowSorter for ObjectTableModel- Since:
- 3.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classclassView row with model mapping.Nested classes/interfaces inherited from class javax.swing.RowSorter
RowSorter.SortKey -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidintconvertRowIndexToModel(int index) intconvertRowIndexToView(int index) Setsprimary comparatorto 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()intReturns Comparator used prior to sorted columns.List<? extends RowSorter.SortKey>Comparator<?>getValueComparator(int column) Returns Comparator used on column.intprotected voidprotected booleanisSortable(int column) protected booleanisSorted()protected booleanisSorted(int column) voidprotected voidrowsChanged(int firstRow, int endRow, boolean deleted, boolean inserted) voidrowsDeleted(int firstRow, int endRow) voidrowsInserted(int firstRow, int endRow) voidrowsUpdated(int firstRow, int endRow) voidrowsUpdated(int firstRow, int endRow, int column) setFallbackComparator(Comparator<ObjectTableSorter.Row> comparator) Sets a fallback comparator (defaults to model index comparison) if noneprimary, neithercolumn value comparatorscan make differences between two rows.setPrimaryComparator(Comparator<ObjectTableSorter.Row> primaryComparator) Comparator used prior to sorted columns.voidsetSortKey(RowSorter.SortKey sortkey) voidsetSortKeys(List<? extends RowSorter.SortKey> keys) setValueComparator(int column, Comparator<?> comparator) Assign comparator to given column, ifnulla getDefaultComparator(int) default one is used instead.protected voidsort()Sort tablevoidtoggleSortOrder(int column) protected voidfill in modelToView list with index of viewprotected voidvalidate()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-Comparatorto be used first- Returns:
this
-
fixLastRow
Setsprimary comparatorto one that don't sort last row.- Returns:
this
-
setValueComparator
Assign comparator to given column, ifnulla 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 orderforComparable, 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 comparatorscan make differences between two rows.- Parameters:
comparator- to be used, when all otherComparators can't see a difference- Returns:
this
-
getModel
- Specified by:
getModelin classRowSorter<ObjectTableModel>
-
toggleSortOrder
public void toggleSortOrder(int column) - Specified by:
toggleSortOrderin classRowSorter<ObjectTableModel>
-
convertRowIndexToModel
public int convertRowIndexToModel(int index) - Specified by:
convertRowIndexToModelin classRowSorter<ObjectTableModel>
-
convertRowIndexToView
public int convertRowIndexToView(int index) - Specified by:
convertRowIndexToViewin classRowSorter<ObjectTableModel>
-
setSortKeys
- Specified by:
setSortKeysin classRowSorter<ObjectTableModel>
-
setSortKey
-
getSortKeys
- Specified by:
getSortKeysin classRowSorter<ObjectTableModel>
-
getViewRowCount
public int getViewRowCount()- Specified by:
getViewRowCountin classRowSorter<ObjectTableModel>
-
getModelRowCount
public int getModelRowCount()- Specified by:
getModelRowCountin classRowSorter<ObjectTableModel>
-
modelStructureChanged
public void modelStructureChanged()- Specified by:
modelStructureChangedin classRowSorter<ObjectTableModel>
-
allRowsChanged
public void allRowsChanged()- Specified by:
allRowsChangedin classRowSorter<ObjectTableModel>
-
rowsInserted
public void rowsInserted(int firstRow, int endRow) - Specified by:
rowsInsertedin classRowSorter<ObjectTableModel>
-
rowsDeleted
public void rowsDeleted(int firstRow, int endRow) - Specified by:
rowsDeletedin classRowSorter<ObjectTableModel>
-
rowsUpdated
public void rowsUpdated(int firstRow, int endRow) - Specified by:
rowsUpdatedin 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:
rowsUpdatedin 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
-