use of org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalWrapperComparator in project nebula.widgets.nattable by eclipse.
the class HierarchicalWrapperSortModel method sort.
@Override
public void sort(int columnIndex, SortDirectionEnum sortDirection, boolean accumulate) {
if (columnIndex >= 0) {
if (!accumulate) {
clear();
}
switch(sortDirection) {
case NONE:
// remove
this.sortingState.remove(columnIndex);
break;
case ASC:
case DESC:
this.sortingState.remove(columnIndex);
this.sortingState.put(columnIndex, sortDirection);
break;
default:
break;
}
// perform the sorting
this.sortedList.getReadWriteLock().writeLock().lock();
try {
this.sortedList.setComparator(new HierarchicalWrapperComparator(this.columnAccessor, this.levelIndexMapping, this));
} finally {
this.sortedList.getReadWriteLock().writeLock().unlock();
}
}
}
use of org.eclipse.nebula.widgets.nattable.hierarchical.HierarchicalWrapperComparator in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeLayerGlazedListsTest method setup.
@Before
public void setup() {
// de-normalize the object graph without parent structure objects
List<HierarchicalWrapper> data = HierarchicalHelper.deNormalize(CarService.getInput(), false, CarService.PROPERTY_NAMES_COMPACT);
EventList<HierarchicalWrapper> eventList = GlazedLists.eventList(data);
TransformedList<HierarchicalWrapper, HierarchicalWrapper> rowObjectsGlazedList = GlazedLists.threadSafeList(eventList);
this.columnPropertyAccessor = new HierarchicalReflectiveColumnPropertyAccessor(CarService.PROPERTY_NAMES_COMPACT);
this.sortedList = new SortedList<>(rowObjectsGlazedList, new HierarchicalWrapperComparator(this.columnPropertyAccessor, HierarchicalHelper.getLevelIndexMapping(CarService.PROPERTY_NAMES_COMPACT)));
this.filterList = new FilterList<>(this.sortedList);
this.bodyDataProvider = new ListDataProvider<>(this.filterList, this.columnPropertyAccessor);
HierarchicalSpanningDataProvider spanningDataProvider = new HierarchicalSpanningDataProvider(this.bodyDataProvider, CarService.PROPERTY_NAMES_COMPACT);
this.bodyDataLayer = new SpanningDataLayer(spanningDataProvider);
// simply apply labels for every column by index
this.bodyDataLayer.setConfigLabelAccumulator(new ColumnLabelAccumulator());
// layer for event handling of GlazedLists and PropertyChanges
GlazedListsEventLayer<HierarchicalWrapper> glazedListsEventLayer = new GlazedListsEventLayer<>(this.bodyDataLayer, this.filterList);
glazedListsEventLayer.setTestMode(true);
this.selectionLayer = new SelectionLayer(glazedListsEventLayer);
this.treeLayer = new HierarchicalTreeLayer(this.selectionLayer, this.filterList, CarService.PROPERTY_NAMES_COMPACT);
// create a dummy config registry
this.configRegistry = new ConfigRegistry();
this.configRegistry.registerConfigAttribute(SortConfigAttributes.SORT_COMPARATOR, DefaultComparator.getInstance());
this.columnHeaderDataLayer = new DataLayer(new DefaultColumnHeaderDataProvider(CarService.PROPERTY_NAMES_COMPACT));
}
Aggregations