use of org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration in project nebula.widgets.nattable by eclipse.
the class SortIntegrationTest method setup.
@Before
public void setup() {
EventList<RowDataFixture> eventList = GlazedLists.eventList(RowDataListFixture.getList().subList(0, 4));
ConfigRegistry configRegistry = new ConfigRegistry();
this.gridLayerStack = new GlazedListsGridLayer<RowDataFixture>(GlazedLists.threadSafeList(eventList), RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap(), configRegistry);
this.nattable = new NatTableFixture(this.gridLayerStack, false);
this.nattable.setConfigRegistry(configRegistry);
this.nattable.addConfiguration(new DefaultNatTableStyleConfiguration());
this.nattable.addConfiguration(new DefaultSortConfiguration());
this.nattable.configure();
}
use of org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration in project tdq-studio-se by Talend.
the class DataSampleTable method sortByColumn.
// sort by the current selected column
public void sortByColumn(List<ModelElement> columns) {
if (columns == null || columns.size() < 1) {
return;
}
// if the next sort direction is back to original
SortDirectionEnum nextSortDirection = sortState.getNextSortDirection();
List<Object[]> sortedData = bodyDataProvider.getList();
if (SortDirectionEnum.NONE.equals(nextSortDirection) && isContainGID) {
// if the data has GID, back to order by GID
sortedData = MatchRuleAnlaysisUtils.sortResultByGID(propertyNames, sortedData);
} else {
sortedData = MatchRuleAnlaysisUtils.sortDataByColumn(sortState, sortedData, columns);
}
// refresh the table by the sorted data
Composite parent = this.natTable.getParent();
createTableControl(parent, sortedData);
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
// add sort data function
natTable.addConfiguration(new DefaultSortConfiguration());
natTable.configure();
this.natTable.redraw();
parent.getParent().layout();
parent.layout();
}
use of org.eclipse.nebula.widgets.nattable.sort.config.DefaultSortConfiguration in project nebula.widgets.nattable by eclipse.
the class RowSelectionIntegrationTest method setup.
@Before
public void setup() {
IConfigRegistry configRegistry = new ConfigRegistry();
// 10 rows in fixture
this.eventListFixture = GlazedLists.eventList(RowDataListFixture.getList(10));
GlazedListsGridLayer<RowDataFixture> gridLayer = new GlazedListsGridLayer<>(this.eventListFixture, RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap(), configRegistry);
this.nattable = new NatTableFixture(gridLayer, false);
this.nattable.setConfigRegistry(configRegistry);
this.selectionLayer = gridLayer.getBodyLayerStack().getSelectionLayer();
this.bodyDataProvider = gridLayer.getBodyDataProvider();
this.selectionProvider = new RowSelectionProvider<>(this.selectionLayer, this.bodyDataProvider);
this.nattable.addConfiguration(new DefaultSortConfiguration());
// Enable preserve selection on data update
this.selectionLayer.setSelectionModel(new RowSelectionModel<>(this.selectionLayer, this.bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {
@Override
public Serializable getRowId(RowDataFixture rowObject) {
return rowObject.getSecurity_id();
}
}));
// Enable test mode - events can be fired outside the Display thread
gridLayer.getGlazedListsEventLayer().setTestMode(true);
this.nattable.configure();
}
Aggregations