use of org.eclipse.nebula.widgets.nattable.selection.config.RowOnlySelectionConfiguration in project nebula.widgets.nattable by eclipse.
the class Real_time_data_updates method createExampleControl.
/**
* @see GlazedListsGridLayer to see the required stack setup. Basically the
* {@link DataLayer} needs to be wrapped up with a
* {@link GlazedListsEventLayer} and the backing list needs to be an
* {@link EventList}
*/
@Override
public Control createExampleControl(Composite parent) {
this.eventList = GlazedLists.eventList(RowDataListFixture.getList(this.defaultDatasetSize));
ConfigRegistry configRegistry = new ConfigRegistry();
GlazedListsGridLayer<RowDataFixture> glazedListsGridLayer = new GlazedListsGridLayer<>(this.eventList, RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap(), configRegistry);
this.nattable = new NatTable(parent, glazedListsGridLayer, false);
this.nattable.setConfigRegistry(configRegistry);
this.nattable.addConfiguration(new DefaultNatTableStyleConfiguration());
this.nattable.addConfiguration(new SingleClickSortConfiguration());
SelectionLayer selectionLayer = glazedListsGridLayer.getBodyLayerStack().getSelectionLayer();
ListDataProvider<RowDataFixture> bodyDataProvider = glazedListsGridLayer.getBodyDataProvider();
// Select complete rows
RowOnlySelectionConfiguration<RowDataFixture> selectionConfig = new RowOnlySelectionConfiguration<>();
selectionLayer.addConfiguration(selectionConfig);
this.nattable.addConfiguration(new RowOnlySelectionBindings());
// Preserve selection on updates and sort
selectionLayer.setSelectionModel(new RowSelectionModel<>(selectionLayer, bodyDataProvider, new IRowIdAccessor<RowDataFixture>() {
@Override
public Serializable getRowId(RowDataFixture rowObject) {
return rowObject.getSecurity_id();
}
}));
this.nattable.configure();
// Layout widgets
parent.setLayout(new GridLayout(1, true));
this.nattable.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
setupTextArea(parent);
setupButtons(parent);
return this.nattable;
}
Aggregations