private KeyStroke computeKeyStroke(KeyEvent e) { int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e); return SWTKeySupport.convertAcceleratorToKeyStroke(accelerator); }
/** * Converts the given event into an SWT accelerator value -- considering the * modified character without the shift modifier. This is the second * accelerator value that should be checked when processing incoming key * events. Key strokes with alphabetic natural keys are run through * <code>convertEventToUnmodifiedAccelerator</code>. * * @param event * The event to be converted; must not be <code>null</code>. * @return The combination of the state mask without shift, and the modified * character. */ public static final int convertEventToUnshiftedModifiedAccelerator( final Event event) { // Disregard alphabetic key strokes. if (Character.isLetter((char) event.keyCode)) { return convertEventToUnmodifiedAccelerator(event); } int modifiers = event.stateMask & (SWT.MODIFIER_MASK ^ SWT.SHIFT); char character = topKey(event); return modifiers + toUpperCase(character); }
/** * <p> * Converts the given event into an SWT accelerator value -- considering the * modified character with the shift modifier. This is the third accelerator * value that should be checked when processing incoming key events. * </p> * <p> * For example, on a standard US keyboard, "Ctrl+Shift+5" would be viewed as * "Ctrl+Shift+%". * </p> * * @param event * The event to be converted; must not be <code>null</code>. * @return The combination of the state mask and the unmodified character. */ public static final int convertEventToModifiedAccelerator(final Event event) { int modifiers = event.stateMask & SWT.MODIFIER_MASK; char character = topKey(event); return modifiers + toUpperCase(character); }
final int firstAccelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event); keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(firstAccelerator)); .convertEventToUnshiftedModifiedAccelerator(event); if (secondAccelerator != firstAccelerator) { keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(secondAccelerator)); final int thirdAccelerator = SWTKeySupport.convertEventToModifiedAccelerator(event); if ((thirdAccelerator != secondAccelerator) && (thirdAccelerator != firstAccelerator)) { keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(thirdAccelerator));
/** * <p> * Converts the given event into an SWT accelerator value -- considering the * unmodified character with all modifier keys. This is the first * accelerator value that should be checked. However, all alphabetic * characters are considered as their uppercase equivalents. * </p> * <p> * For example, on a standard US keyboard, "Ctrl+Shift+5" would be viewed as * "Ctrl+%". * </p> * * @param event * The event to be converted; must not be <code>null</code>. * @return The combination of the state mask and the unmodified character. */ public static final int convertEventToUnmodifiedAccelerator( final KeyEvent event) { return convertEventToUnmodifiedAccelerator(event.stateMask, event.keyCode); }
/** * Converts a 2.1.x style key stroke (as parsed from the <code>string</code> * attribute of the <code>keyBinding</code> to a 3.1 key stroke. * * @param r21Stroke * The 2.1.x stroke to convert; must never be <code>null</code>. * @return A 3.1 key stroke; never <code>null</code>. */ private static final KeyStroke convert2_1Stroke(final int r21Stroke) { return SWTKeySupport.convertAcceleratorToKeyStroke(r21Stroke); }
String modifier= SWTKeySupport.getKeyFormatterForPlatform().format(AbstractJavaCompletionProposal.MODIFIER_TOGGLE_COMPLETION_MODE); label.setText(NLS.bind(PreferencesMessages.JavaEditorPreferencePage_completionToggleHint, modifier)); GridData gd= new GridData();
/** * @see org.eclipse.jface.action.ExternalActionManager.ICallback#getAccelerator(String) */ public final Integer getAccelerator(final String commandId) { final TriggerSequence triggerSequence = bindingManager .getBestActiveBindingFor(commandId); if (triggerSequence != null) { final Trigger[] triggers = triggerSequence.getTriggers(); if (triggers.length == 1) { final Trigger trigger = triggers[0]; if (trigger instanceof KeyStroke) { final KeyStroke keyStroke = (KeyStroke) trigger; final int accelerator = SWTKeySupport .convertKeyStrokeToAccelerator(keyStroke); return new Integer(accelerator); } } } return null; }
/** * <p> * Converts the given state mask and key code into an SWT accelerator value -- * considering the unmodified character with all modifier keys. All * alphabetic characters are considered as their uppercase equivalents. * </p> * <p> * For example, on a standard US keyboard, "Ctrl+Shift+5" would be viewed as * "Ctrl+Shift+5". * </p> * * @param stateMask * The integer mask of modifiers keys depressed when this was * pressed. * @param keyCode * The key that was pressed, before being modified. * @return The combination of the state mask and the unmodified character. */ private static final int convertEventToUnmodifiedAccelerator( final int stateMask, final int keyCode) { int modifiers = stateMask & SWT.MODIFIER_MASK; int character = keyCode; return modifiers + toUpperCase(character); }
final int firstAccelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(event); keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(firstAccelerator)); .convertEventToUnshiftedModifiedAccelerator(event); if (secondAccelerator != firstAccelerator) { keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(secondAccelerator)); final int thirdAccelerator = SWTKeySupport.convertEventToModifiedAccelerator(event); if ((thirdAccelerator != secondAccelerator) && (thirdAccelerator != firstAccelerator)) { keyStrokes.add(SWTKeySupport.convertAcceleratorToKeyStroke(thirdAccelerator));
/** * <p> * Converts the given event into an SWT accelerator value -- considering the * unmodified character with all modifier keys. This is the first * accelerator value that should be checked when processing incoming key * events. However, all alphabetic characters are considered as their * uppercase equivalents. * </p> * <p> * For example, on a standard US keyboard, "Ctrl+Shift+5" would be viewed as * "Ctrl+Shift+5". * </p> * * @param event * The event to be converted; must not be <code>null</code>. * @return The combination of the state mask and the unmodified character. */ public static final int convertEventToUnmodifiedAccelerator( final Event event) { return convertEventToUnmodifiedAccelerator(event.stateMask, event.keyCode); }
/** * Converts the provided key combination code to accelerator. * * @param accelerator * The accelerator to convert; should be a valid SWT accelerator * value. * @return The equivalent key stroke; never <code>null</code>. */ private String keyToStr(final int accelerator) { return SWTKeySupport.convertAcceleratorToKeyStroke(accelerator) .format(); }
/** * <p> * Converts the given event into an SWT accelerator value -- considering the * modified character with the shift modifier. This is the third accelerator * value that should be checked when processing incoming key events. * </p> * <p> * For example, on a standard US keyboard, "Ctrl+Shift+5" would be viewed as * "Ctrl+Shift+%". * </p> * * @param event * The event to be converted; must not be <code>null</code>. * @return The combination of the state mask and the unmodified character. */ public static final int convertEventToModifiedAccelerator(final Event event) { int modifiers = event.stateMask & SWT.MODIFIER_MASK; char character = topKey(event); return modifiers + toUpperCase(character); }
String modifier= SWTKeySupport.getKeyFormatterForPlatform().format(AbstractJavaCompletionProposal.MODIFIER_TOGGLE_COMPLETION_MODE); label.setText(NLS.bind(PreferencesMessages.JavaEditorPreferencePage_completionToggleHint, modifier)); GridData gd= new GridData();
/** * @see org.eclipse.jface.action.ExternalActionManager.ICallback#getAccelerator(String) */ @Override public final Integer getAccelerator(final String commandId) { final TriggerSequence triggerSequence = bindingManager .getBestActiveBindingFor(commandId); if (triggerSequence != null) { final Trigger[] triggers = triggerSequence.getTriggers(); if (triggers.length == 1) { final Trigger trigger = triggers[0]; if (trigger instanceof KeyStroke) { final KeyStroke keyStroke = (KeyStroke) trigger; final int accelerator = SWTKeySupport .convertKeyStrokeToAccelerator(keyStroke); return Integer.valueOf(accelerator); } } } return null; }
/** * <p> * Converts the given state mask and key code into an SWT accelerator value -- * considering the unmodified character with all modifier keys. All * alphabetic characters are considered as their uppercase equivalents. * </p> * <p> * For example, on a standard US keyboard, "Ctrl+Shift+5" would be viewed as * "Ctrl+Shift+5". * </p> * * @param stateMask * The integer mask of modifiers keys depressed when this was * pressed. * @param keyCode * The key that was pressed, before being modified. * @return The combination of the state mask and the unmodified character. */ private static final int convertEventToUnmodifiedAccelerator( final int stateMask, final int keyCode) { int modifiers = stateMask & SWT.MODIFIER_MASK; int character = keyCode; return modifiers + toUpperCase(character); }
protected boolean isInvocationEvent(KeyEvent e) { int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e); KeySequence keySequence = KeySequence.getInstance(SWTKeySupport.convertAcceleratorToKeyStroke(accelerator)); return keySequence.startsWith(triggerSequence, true); }
/** * Converts the given event into an SWT accelerator value -- considering the * modified character without the shift modifier. This is the second * accelerator value that should be checked when processing incoming key * events. Key strokes with alphabetic natural keys are run through * <code>convertEventToUnmodifiedAccelerator</code>. * * @param event * The event to be converted; must not be <code>null</code>. * @return The combination of the state mask without shift, and the modified * character. */ public static final int convertEventToUnshiftedModifiedAccelerator( final Event event) { // Disregard alphabetic key strokes. if (Character.isLetter((char) event.keyCode)) { return convertEventToUnmodifiedAccelerator(event); } int modifiers = event.stateMask & (SWT.MODIFIER_MASK ^ SWT.SHIFT); char character = topKey(event); return modifiers + toUpperCase(character); }
/** * <p> * Converts the given event into an SWT accelerator value -- considering the * unmodified character with all modifier keys. This is the first * accelerator value that should be checked. However, all alphabetic * characters are considered as their uppercase equivalents. * </p> * <p> * For example, on a standard US keyboard, "Ctrl+Shift+5" would be viewed as * "Ctrl+%". * </p> * * @param event * The event to be converted; must not be <code>null</code>. * @return The combination of the state mask and the unmodified character. */ public static final int convertEventToUnmodifiedAccelerator( final KeyEvent event) { return convertEventToUnmodifiedAccelerator(event.stateMask, event.keyCode); }
/** * @see org.eclipse.jface.action.ExternalActionManager.ICallback#isAcceleratorInUse(int) */ @Override public final boolean isAcceleratorInUse(final int accelerator) { final KeySequence keySequence = KeySequence .getInstance(SWTKeySupport .convertAcceleratorToKeyStroke(accelerator)); return bindingManager.isPerfectMatch(keySequence) || bindingManager.isPartialMatch(keySequence); }