Search in sources :

Example 1 with IKeyAction

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

the class DefaultDataChangeConfiguration method configureUiBindings.

@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
    uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.MOD1, 's'), new IKeyAction() {

        @Override
        public void run(NatTable natTable, KeyEvent event) {
            natTable.doCommand(new SaveDataChangesCommand());
        }
    });
    uiBindingRegistry.registerKeyBinding(new KeyEventMatcher(SWT.MOD1, 'd'), new IKeyAction() {

        @Override
        public void run(NatTable natTable, KeyEvent event) {
            natTable.doCommand(new DiscardDataChangesCommand());
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) DiscardDataChangesCommand(org.eclipse.nebula.widgets.nattable.datachange.command.DiscardDataChangesCommand) KeyEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher) IKeyAction(org.eclipse.nebula.widgets.nattable.ui.action.IKeyAction) SaveDataChangesCommand(org.eclipse.nebula.widgets.nattable.datachange.command.SaveDataChangesCommand) NatTable(org.eclipse.nebula.widgets.nattable.NatTable)

Example 2 with IKeyAction

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

the class ConfigurableModeEventHandler method keyPressed.

// Event handling /////////////////////////////////////////////////////////
@Override
public void keyPressed(KeyEvent event) {
    IKeyAction keyAction = getUiBindingRegistry().getKeyEventAction(event);
    if (keyAction != null) {
        this.natTable.forceFocus();
        keyAction.run(this.natTable, event);
    }
}
Also used : IKeyAction(org.eclipse.nebula.widgets.nattable.ui.action.IKeyAction)

Aggregations

IKeyAction (org.eclipse.nebula.widgets.nattable.ui.action.IKeyAction)2 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 DiscardDataChangesCommand (org.eclipse.nebula.widgets.nattable.datachange.command.DiscardDataChangesCommand)1 SaveDataChangesCommand (org.eclipse.nebula.widgets.nattable.datachange.command.SaveDataChangesCommand)1 KeyEventMatcher (org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1