DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer,
columnHeaderLayer);
// build the grid layer
GridLayer gridLayer = new GridLayer(viewportLayer, columnHeaderLayer,
rowHeaderLayer, cornerLayer);
// turn the auto configuration off as we want to add our header menu
// configuration
final NatTable natTable = new NatTable(panel, gridLayer, false);
// as the autoconfiguration of the NatTable is turned off, we have to
// add the
// DefaultNatTableStyleConfiguration manually
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
// add the header menu configuration for adding the column header menu
// with hide/show actions
natTable.addConfiguration(new AbstractHeaderMenuConfiguration(natTable) {
@Override
protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
return super.createColumnHeaderMenu(natTable)
.withHideColumnMenuItem().withShowAllColumnsMenuItem()
.withStateManagerMenuItemProvider();
}
@Override
protected PopupMenuBuilder createRowHeaderMenu(NatTable natTable) {
return super.createRowHeaderMenu(natTable)
.withHideRowMenuItem().withShowAllRowsMenuItem()
.withStateManagerMenuItemProvider();
}
@Override
protected PopupMenuBuilder createCornerMenu(NatTable natTable) {
return super.createCornerMenu(natTable)
.withShowAllColumnsMenuItem().withShowAllRowsMenuItem()
.withStateManagerMenuItemProvider();
}
});
natTable.configure();
panel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(panel);
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
gridLayer
.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(
natTable));
return panel;
}