// set the modern theme
firstNatTable.setTheme(new ModernNatTableThemeConfiguration());
// add overlay painter for full borders
firstNatTable.addOverlayPainter(new NatTableBorderOverlayPainter());
// create the second table
// create the body layer stack
final IRowDataProvider<Person> secondBodyDataProvider = new ListDataProvider<Person>(
getFlandersList(), columnPropertyAccessor);
final DataLayer secondBodyDataLayer = new DataLayer(
secondBodyDataProvider);
final SelectionLayer secondSelectionLayer = new SelectionLayer(
secondBodyDataLayer);
ViewportLayer secondViewportLayer = new ViewportLayer(
secondSelectionLayer);
// use a RowSelectionModel that will perform row selections and is able
// to identify a row via unique ID
secondSelectionLayer.setSelectionModel(new RowSelectionModel<Person>(
secondSelectionLayer, secondBodyDataProvider, rowIdAccessor));
// create the column header layer stack
DataLayer secondColumnHeaderDataLayer = new DataLayer(
columnHeaderDataProvider);
ILayer secondColumnHeaderLayer = new ColumnHeaderLayer(
secondColumnHeaderDataLayer, secondViewportLayer,
secondSelectionLayer);
// register custom label styling to indicate if the table is active
secondColumnHeaderDataLayer
.setConfigLabelAccumulator(new IConfigLabelAccumulator() {
@Override
public void accumulateConfigLabels(LabelStack configLabels,
int columnPosition, int rowPosition) {
if (!isFirstSelectionProvider) {
configLabels.addLabelOnTop(ACTIVE_LABEL);
}
}
});
// set the region labels to make default configurations work, e.g.
// selection
CompositeLayer secondCompositeLayer = new CompositeLayer(1, 2);
secondCompositeLayer.setChildLayer(GridRegion.COLUMN_HEADER,
secondColumnHeaderLayer, 0, 0);
secondCompositeLayer.setChildLayer(GridRegion.BODY,
secondViewportLayer, 0, 1);
final NatTable secondNatTable = new NatTable(panel,
secondCompositeLayer, false);
secondNatTable
.addConfiguration(new DefaultNatTableStyleConfiguration());
secondNatTable.addConfiguration(new ActiveTableStyleConfiguration());
secondNatTable.configure();
// set the modern theme
secondNatTable.setTheme(new ModernNatTableThemeConfiguration());
// add overlay painter for full borders
secondNatTable.addOverlayPainter(new NatTableBorderOverlayPainter());
// set ISelectionProvider
final RowSelectionProvider<Person> selectionProvider = new RowSelectionProvider<Person>(
firstSelectionLayer, firstBodyDataProvider);