Class HierarchicalWrapperSortModel
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.extension.glazedlists.hierarchical.HierarchicalWrapperSortModel
-
- All Implemented Interfaces:
ISortModel
public class HierarchicalWrapperSortModel extends Object implements ISortModel
ISortModel
that is used to support sorting ofHierarchicalWrapper
in aSortedList
. Internally uses theHierarchicalWrapperComparator
to keep the tree structure while supporting dynamic column based sorting.- Since:
- 1.6
-
-
Constructor Summary
Constructors Constructor Description HierarchicalWrapperSortModel(ca.odell.glazedlists.SortedList<HierarchicalWrapper> sortedList, IColumnAccessor<HierarchicalWrapper> columnAccessor, Map<Integer,List<Integer>> levelIndexMapping, DataLayer columnHeaderDataLayer, ConfigRegistry configRegistry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Remove all sortingComparator<?>
getColumnComparator(int columnIndex)
List<Comparator>
getComparatorsForColumnIndex(int columnIndex)
SortDirectionEnum
getSortDirection(int columnIndex)
List<Integer>
getSortedColumnIndexes()
int
getSortOrder(int columnIndex)
boolean
isColumnIndexSorted(int columnIndex)
void
sort(int columnIndex, SortDirectionEnum sortDirection, boolean accumulate)
This method is called by theSortCommandHandler
in response to a sort command.
-
-
-
Constructor Detail
-
HierarchicalWrapperSortModel
public HierarchicalWrapperSortModel(ca.odell.glazedlists.SortedList<HierarchicalWrapper> sortedList, IColumnAccessor<HierarchicalWrapper> columnAccessor, Map<Integer,List<Integer>> levelIndexMapping, DataLayer columnHeaderDataLayer, ConfigRegistry configRegistry)
- Parameters:
sortedList
- TheSortedList
that should be sorted.columnAccessor
- TheIColumnAccessor
to access the data value for a specific column.levelIndexMapping
- The mapping from hierarchical level to column indexes for that level.columnHeaderDataLayer
- TheDataLayer
of the column header, needed to retrieve the configuredComparator
.configRegistry
- TheConfigRegistry
needed to evaluate the configuredComparator
.
-
-
Method Detail
-
getSortedColumnIndexes
public List<Integer> getSortedColumnIndexes()
- Specified by:
getSortedColumnIndexes
in interfaceISortModel
- Returns:
- List of column indexes that are sorted.
-
isColumnIndexSorted
public boolean isColumnIndexSorted(int columnIndex)
- Specified by:
isColumnIndexSorted
in interfaceISortModel
- Parameters:
columnIndex
- The column index to check.- Returns:
true
if the column with the given index is sorted at the moment.
-
getSortDirection
public SortDirectionEnum getSortDirection(int columnIndex)
- Specified by:
getSortDirection
in interfaceISortModel
- Parameters:
columnIndex
- The column index for which the sort direction is requested.- Returns:
- the direction in which the column with the given index is currently sorted
-
getSortOrder
public int getSortOrder(int columnIndex)
- Specified by:
getSortOrder
in interfaceISortModel
- Parameters:
columnIndex
- The column index for which the sort order is requested.- Returns:
- when multiple columns are sorted, this returns the order of the
column index in the sort
Example: If column indexes 3, 6, 9 are sorted (in that order) the sort order for index 6 is 1.
-
getComparatorsForColumnIndex
public List<Comparator> getComparatorsForColumnIndex(int columnIndex)
- Specified by:
getComparatorsForColumnIndex
in interfaceISortModel
- Parameters:
columnIndex
- The index of the column for which the row objects should be sorted.- Returns:
- The collection of Comparators used to sort row objects by column values.
-
getColumnComparator
public Comparator<?> getColumnComparator(int columnIndex)
- Specified by:
getColumnComparator
in interfaceISortModel
- Parameters:
columnIndex
- The index of the column for which theComparator
is requested.- Returns:
- The
Comparator
that is used for sorting the values of a specified column. Needed in case of data model wrapping, e.g. GroupBy
-
sort
public void sort(int columnIndex, SortDirectionEnum sortDirection, boolean accumulate)
Description copied from interface:ISortModel
This method is called by theSortCommandHandler
in response to a sort command. It is responsible for sorting the requested column.- Specified by:
sort
in interfaceISortModel
- Parameters:
columnIndex
- The column index to sort.sortDirection
- The sort direction to apply.accumulate
- flag indicating if the column should added to a previous sort.
-
clear
public void clear()
Description copied from interface:ISortModel
Remove all sorting- Specified by:
clear
in interfaceISortModel
-
-