use of org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.command.UngroupByColumnIndexCommand in project nebula.widgets.nattable by eclipse.
the class GroupByHeaderMenuConfiguration method createGroupByHeaderMenu.
/**
* Creates the {@link PopupMenuBuilder} for the groupBy header menu with the
* menu items to ungroup.
*
* @param natTable
* The NatTable where the menu should be attached.
* @return The {@link PopupMenuBuilder} that is used to build the groupBy
* header menu.
*/
protected PopupMenuBuilder createGroupByHeaderMenu(NatTable natTable) {
return new PopupMenuBuilder(natTable).withMenuItemProvider(UNGROUP_BY_MENU_ITEM_ID, new IMenuItemProvider() {
@Override
public void addMenuItem(final NatTable natTable, Menu popupMenu) {
MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
// $NON-NLS-1$
menuItem.setText(Messages.getLocalizedMessage("%GroupByHeaderMenuConfiguration.ungroupBy"));
menuItem.setEnabled(true);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
NatEventData natEventData = MenuItemProviders.getNatEventData(event);
MouseEvent originalEvent = natEventData.getOriginalEvent();
int groupByColumnIndex = GroupByHeaderMenuConfiguration.this.groupByHeaderLayer.getGroupByColumnIndexAtXY(originalEvent.x, originalEvent.y);
natTable.doCommand(new UngroupByColumnIndexCommand(groupByColumnIndex));
}
});
}
});
}
Aggregations