Example usage for org.eclipse.jface.bindings.keys KeyStroke equals

List of usage examples for org.eclipse.jface.bindings.keys KeyStroke equals

Introduction

In this page you can find the example usage for org.eclipse.jface.bindings.keys KeyStroke equals.

Prototype

@Override
    public final boolean equals(final Object object) 

Source Link

Usage

From source file:de.walware.ecommons.ui.dialogs.QuickTreeInformationControl.java

License:Open Source License

private void initIterateKeys() {
    if (this.commandId == null || this.iterationCount == 1) {
        return;//from w w  w  .  ja  v a  2 s  . c  om
    }
    final IBindingService bindingSvc = (IBindingService) PlatformUI.getWorkbench()
            .getService(IBindingService.class);
    if (bindingSvc == null) {
        return;
    }
    {
        final TriggerSequence sequence = bindingSvc.getBestActiveBindingFor(this.commandId);
        final KeyStroke keyStroke = getKeyStroke(sequence);
        if (keyStroke == null) {
            return;
        }
        this.commandBestKeyStrokeFormatted = keyStroke.format();
    }
    {
        final TriggerSequence[] sequences = bindingSvc.getActiveBindingsFor(this.commandId);
        this.commandActiveKeyStrokes = new ArrayList<KeyStroke>(sequences.length);
        for (int i = 0; i < sequences.length; i++) {
            final KeyStroke keyStroke = getKeyStroke(sequences[i]);
            if (keyStroke != null) {
                this.commandActiveKeyStrokes.add(keyStroke);
            }
        }
    }
    this.commandKeyListener = new KeyAdapter() {
        @Override
        public void keyPressed(final KeyEvent event) {
            final KeyStroke keyStroke = SWTKeySupport
                    .convertAcceleratorToKeyStroke(SWTKeySupport.convertEventToUnmodifiedAccelerator(event));
            for (final KeyStroke activeKeyStroke : QuickTreeInformationControl.this.commandActiveKeyStrokes) {
                if (activeKeyStroke.equals(keyStroke)) {
                    event.doit = false;
                    iterate();
                    return;
                }
            }
        }
    };
}

From source file:org.eclipse.handly.ui.quickoutline.OutlinePopup.java

License:Open Source License

/**
 * Returns the invoking key listener. When the invoking key is pressed,
 * this listener changes the mode of the outline popup and updates the
 * text in the popup's info area.//from w w w.ja  v a  2  s. c  o m
 *
 * @return the invoking key listener (never <code>null</code>)
 */
protected final KeyListener getInvokingKeyListener() {
    return new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
            KeyStroke keyStroke = SWTKeySupport.convertAcceleratorToKeyStroke(accelerator);
            if (keyStroke.equals(invokingKeyStroke)) {
                changeOutlineMode();
                updateInfoText();
                e.doit = false;
            }
        }
    };
}

From source file:org.eclipse.rcptt.ui.editors.TextViewerActionsSupport.java

License:Open Source License

private void processKeyDown(KeyEvent e) throws ParseException {
    KeyStroke pressed = KeyStroke.getInstance(e.stateMask, Character.toUpperCase(e.keyCode));

    if (pressed.equals(KeyStroke.getInstance("M1+Z"))) { //$NON-NLS-1$
        undoAction.run();/*from ww w  .ja  v a  2 s  . c om*/
    } else if (pressed.equals(KeyStroke.getInstance("M1+Y"))) { //$NON-NLS-1$
        redoAction.run();
    } else if (pressed.equals(KeyStroke.getInstance("M1+A"))) { //$NON-NLS-1$
        selectAllAction.run();
    } else if (pressed.equals(KeyStroke.getInstance("M1+F"))) { //$NON-NLS-1$
        findAction.run();
    } else if (pressed.equals(KeyStroke.getInstance("Ctrl+Space"))) { //$NON-NLS-1$
        contentAssistAction.run();
    } else if (gotoLineAction != null && pressed.equals(KeyStroke.getInstance("M1+L"))) { //$NON-NLS-1$
        gotoLineAction.run();
    }

}

From source file:org.gemoc.execution.concurrent.ccsljavaxdsml.ui.dashboard.utils.AbstractKeyAdapter.java

License:Open Source License

/**
 * Is given key representation the one that raises the specified key event.
 * /*from w ww.  j  a v  a2  s.c  om*/
 * @param event_p
 * @param keyRepresentation_p
 * @return
 */
protected boolean handle(KeyEvent event_p, String keyRepresentation_p) {
    boolean result = false;
    // Do not handle directly the event, as the key bindings may be different from the formal one (e.g
    // Emacs key binding).
    KeyStroke keyStroke = SWTKeySupport
            .convertAcceleratorToKeyStroke(SWTKeySupport.convertEventToUnmodifiedAccelerator(event_p));
    try {
        result = keyStroke.equals(KeyStroke.getInstance(keyRepresentation_p));
    } catch (ParseException exception_p) {
        // Ignore errors.
    }
    return result;
}