Search in sources :

Example 1 with RemoveColumnGroupCommand

use of org.eclipse.nebula.widgets.nattable.group.command.RemoveColumnGroupCommand in project nebula.widgets.nattable by eclipse.

the class ColumnGroupMenuItemProviders method removeColumnGroupMenuItemProvider.

public static IMenuItemProvider removeColumnGroupMenuItemProvider(final String menuLabel) {
    return new IMenuItemProvider() {

        @Override
        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem columnStyleEditor = new MenuItem(popupMenu, SWT.PUSH);
            columnStyleEditor.setText(menuLabel);
            columnStyleEditor.setEnabled(true);
            columnStyleEditor.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    NatEventData natEventData = MenuItemProviders.getNatEventData(e);
                    int columnPosition = natEventData.getColumnPosition();
                    int columnIndex = natEventData.getNatTable().getColumnIndexByPosition(columnPosition);
                    natTable.doCommand(new RemoveColumnGroupCommand(columnIndex));
                }
            });
        }
    };
}
Also used : RemoveColumnGroupCommand(org.eclipse.nebula.widgets.nattable.group.command.RemoveColumnGroupCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IMenuItemProvider(org.eclipse.nebula.widgets.nattable.ui.menu.IMenuItemProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) NatEventData(org.eclipse.nebula.widgets.nattable.ui.NatEventData) Menu(org.eclipse.swt.widgets.Menu)

Example 2 with RemoveColumnGroupCommand

use of org.eclipse.nebula.widgets.nattable.group.command.RemoveColumnGroupCommand in project nebula.widgets.nattable by eclipse.

the class MenuItemProviders method removeColumnGroupMenuItemProvider.

public static IMenuItemProvider removeColumnGroupMenuItemProvider(final String menuLabel) {
    return new IMenuItemProvider() {

        @Override
        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem columnStyleEditor = new MenuItem(popupMenu, SWT.PUSH);
            columnStyleEditor.setText(Messages.getLocalizedMessage(menuLabel));
            columnStyleEditor.setEnabled(true);
            columnStyleEditor.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    NatEventData natEventData = MenuItemProviders.getNatEventData(e);
                    int columnPosition = natEventData.getColumnPosition();
                    int columnIndex = natEventData.getNatTable().getColumnIndexByPosition(columnPosition);
                    natTable.doCommand(new RemoveColumnGroupCommand(columnIndex));
                }
            });
        }
    };
}
Also used : RemoveColumnGroupCommand(org.eclipse.nebula.widgets.nattable.group.command.RemoveColumnGroupCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) NatEventData(org.eclipse.nebula.widgets.nattable.ui.NatEventData) Menu(org.eclipse.swt.widgets.Menu)

Aggregations

NatTable (org.eclipse.nebula.widgets.nattable.NatTable)2 RemoveColumnGroupCommand (org.eclipse.nebula.widgets.nattable.group.command.RemoveColumnGroupCommand)2 NatEventData (org.eclipse.nebula.widgets.nattable.ui.NatEventData)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Menu (org.eclipse.swt.widgets.Menu)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2 IMenuItemProvider (org.eclipse.nebula.widgets.nattable.ui.menu.IMenuItemProvider)1