use of org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand in project nebula.widgets.nattable by eclipse.
the class MenuItemProviders method hideColumnMenuItemProvider.
/**
* Will create and return the {@link IMenuItemProvider} that adds the action
* for executing the {@link ColumnHideCommand} to a popup menu. This command
* is intended to hide the current selected column immediately.
* <p>
* The {@link MenuItem} will be shown with the given menu label.
*
* @param menuLabel
* The text that will be showed for the generated
* {@link MenuItem}
* @return The {@link IMenuItemProvider} for the {@link MenuItem} that
* executes the {@link ColumnHideCommand}.
*/
public static IMenuItemProvider hideColumnMenuItemProvider(final String menuLabel) {
return new IMenuItemProvider() {
@Override
public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
menuItem.setText(Messages.getLocalizedMessage(menuLabel));
// $NON-NLS-1$
menuItem.setImage(GUIHelper.getImage("hide_column"));
menuItem.setEnabled(true);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int columnPosition = getNatEventData(event).getColumnPosition();
natTable.doCommand(new ColumnHideCommand(natTable, columnPosition));
}
});
}
};
}
Aggregations