groupByHeaderLayer, 0, 0);
compositeGridLayer.setChildLayer("Grid", gridLayer, 0, 1);
// turn the auto configuration off as we want to add our header menu
// configuration
NatTable natTable = new NatTable(parent, compositeGridLayer, false);
// as the autoconfiguration of the NatTable is turned off, we have to
// add the
// DefaultNatTableStyleConfiguration and the ConfigRegistry manually
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
// add group by configuration
natTable.addConfiguration(new GroupByHeaderMenuConfiguration(natTable,
groupByHeaderLayer));
natTable.addConfiguration(new HeaderMenuConfiguration(natTable) {
@Override
protected PopupMenuBuilder createCornerMenu(NatTable natTable) {
return super.createCornerMenu(natTable)
.withStateManagerMenuItemProvider()
.withMenuItemProvider(new IMenuItemProvider() {
@Override
public void addMenuItem(NatTable natTable,
Menu popupMenu) {
MenuItem menuItem = new MenuItem(popupMenu,
SWT.PUSH);
menuItem.setText("Toggle Group By Header"); //$NON-NLS-1$
menuItem.setEnabled(true);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(
SelectionEvent event) {
groupByHeaderLayer
.setVisible(!groupByHeaderLayer
.isVisible());
}
});
}
}).withMenuItemProvider(new IMenuItemProvider() {
@Override
public void addMenuItem(final NatTable natTable,
Menu popupMenu) {
MenuItem menuItem = new MenuItem(popupMenu,
SWT.PUSH);
menuItem.setText("Collapse All"); //$NON-NLS-1$
menuItem.setEnabled(true);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(
SelectionEvent event) {
natTable.doCommand(new TreeCollapseAllCommand());
}
});
}
}).withMenuItemProvider(new IMenuItemProvider() {
@Override
public void addMenuItem(final NatTable natTable,
Menu popupMenu) {
MenuItem menuItem = new MenuItem(popupMenu,
SWT.PUSH);
menuItem.setText("Expand All"); //$NON-NLS-1$
menuItem.setEnabled(true);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(
SelectionEvent event) {
natTable.doCommand(new TreeExpandAllCommand());
}
});
}
});
}
});
natTable.configure();
natTable.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(
natTable));
return natTable;
}