Search in sources :

Example 11 with NatEventData

use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.

the class CellLabelMouseEventMatcher method matches.

@Override
public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
    NatEventData eventData = NatEventData.createInstanceFromEvent(event);
    LabelStack customLabels = natTable.getConfigLabelsByPosition(eventData.getColumnPosition(), eventData.getRowPosition());
    return super.matches(natTable, event, regionLabels) && customLabels.getLabels().contains(this.labelToMatch);
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) NatEventData(org.eclipse.nebula.widgets.nattable.ui.NatEventData)

Example 12 with NatEventData

use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.

the class MenuItemProviders method renameColumnGroupMenuItemProvider.

public static IMenuItemProvider renameColumnGroupMenuItemProvider(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();
                    natTable.doCommand(new DisplayColumnGroupRenameDialogCommand(natTable, columnPosition));
                }
            });
        }
    };
}
Also used : DisplayColumnGroupRenameDialogCommand(org.eclipse.nebula.widgets.nattable.group.command.DisplayColumnGroupRenameDialogCommand) 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)

Example 13 with NatEventData

use of org.eclipse.nebula.widgets.nattable.ui.NatEventData 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

NatEventData (org.eclipse.nebula.widgets.nattable.ui.NatEventData)13 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 Menu (org.eclipse.swt.widgets.Menu)7 MenuItem (org.eclipse.swt.widgets.MenuItem)7 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 IMenuItemProvider (org.eclipse.nebula.widgets.nattable.ui.menu.IMenuItemProvider)3 ClearFilterCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearFilterCommand)2 DisplayColumnGroupRenameDialogCommand (org.eclipse.nebula.widgets.nattable.group.command.DisplayColumnGroupRenameDialogCommand)2 RemoveColumnGroupCommand (org.eclipse.nebula.widgets.nattable.group.command.RemoveColumnGroupCommand)2 LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)2 Timer (java.util.Timer)1 UngroupByColumnIndexCommand (org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.command.UngroupByColumnIndexCommand)1 CellVisualChangeEvent (org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent)1 SortColumnCommand (org.eclipse.nebula.widgets.nattable.sort.command.SortColumnCommand)1 IMouseAction (org.eclipse.nebula.widgets.nattable.ui.action.IMouseAction)1 PopupMenuBuilder (org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 Display (org.eclipse.swt.widgets.Display)1 Event (org.eclipse.swt.widgets.Event)1