Package org.eclipse.jface.bindings.keys

Examples of org.eclipse.jface.bindings.keys.KeySequence


        final TriggerSequence[] activeBindingsFor = bindingSvc
                .getActiveBindingsFor(commandId);

        for (final TriggerSequence seq : activeBindingsFor) {
            if (seq instanceof KeySequence) {
                final KeySequence keySequence = (KeySequence) seq;
                final KeyStroke[] keyStrokes = keySequence.getKeyStrokes();

                for (final KeyStroke keyStroke : keyStrokes) {

                    if (keyStroke.getNaturalKey() == event.keyCode
                            && (keyStroke.getModifierKeys() & event.stateMask) != 0) {
View Full Code Here


    /**
     * @see org.eclipse.jface.action.ExternalActionManager.ICallback#isAcceleratorInUse(int)
     */
    public final boolean isAcceleratorInUse(final int accelerator) {
      final KeySequence keySequence = KeySequence
          .getInstance(SWTKeySupport
              .convertAcceleratorToKeyStroke(accelerator));
      return bindingManager.isPerfectMatch(keySequence)
          || bindingManager.isPartialMatch(keySequence);
    }
View Full Code Here

      } else {
        handlerService.updateShellKludge();
      }
    }

    KeySequence errorSequence = null;
    Collection errorMatch = null;

    KeySequence sequenceBeforeKeyStroke = state.getCurrentSequence();
    for (Iterator iterator = potentialKeyStrokes.iterator(); iterator
        .hasNext();) {
      KeySequence sequenceAfterKeyStroke = KeySequence.getInstance(
          sequenceBeforeKeyStroke, (KeyStroke) iterator.next());
      if (isPartialMatch(sequenceAfterKeyStroke)) {
        incrementState(sequenceAfterKeyStroke);
        return true;
View Full Code Here

    final Command command = commandService
        .getCommand("org.eclipse.ui.window.showKeyAssist"); //$NON-NLS-1$
    final TriggerSequence[] keyBindings = bindingService
        .getActiveBindingsFor(new ParameterizedCommand(command, null));
    final int keyBindingsCount = keyBindings.length;
    final KeySequence currentState = keyBindingState.getCurrentSequence();
    final int prefixSize = currentState.getKeyStrokes().length;

    // Try to find the first possible matching key binding.
    KeySequence keySequence = null;
    for (int i = 0; i < keyBindingsCount; i++) {
      keySequence = (KeySequence) keyBindings[i];

      // Now just double-check to make sure the key is still possible.
      if (prefixSize > 0) {
        if (keySequence.startsWith(currentState, false)) {
          /*
           * Okay, so we have a partial match. Replace the key binding
           * with the required suffix completion.
           */
          final KeyStroke[] oldKeyStrokes = keySequence
              .getKeyStrokes();
          final int newSize = oldKeyStrokes.length - prefixSize;
          final KeyStroke[] newKeyStrokes = new KeyStroke[newSize];
          System.arraycopy(oldKeyStrokes, prefixSize, newKeyStrokes,
              0, newSize);
          keySequence = KeySequence.getInstance(newKeyStrokes);
          break;
        }

        /*
         * The prefix doesn't match, so null out the key binding and try
         * again.
         */
        keySequence = null;
        continue;

      }

      // There is no prefix, so just grab the first.
      break;
    }
    if (keySequence == null) {
      return null; // couldn't find a suitable key binding
    }

    return MessageFormat.format(Util.translateString(RESOURCE_BUNDLE,
        "openPreferencePage"), //$NON-NLS-1$
        new Object[] { keySequence.format() });
  }
View Full Code Here

          | lookup.getCtrl() | lookup.getShift();
      final int modifierKeys = acceleratorInt & modifierMask;
      final int naturalKey = acceleratorInt & ~modifierMask;
      final KeyStroke keyStroke = KeyStroke.getInstance(modifierKeys,
          naturalKey);
      final KeySequence keySequence = KeySequence.getInstance(keyStroke);

      final Scheme activeScheme = bindingService.getActiveScheme();

      try {
        final Binding binding = new KeyBinding(keySequence, command,
View Full Code Here

    final IBindingService bindingService = (IBindingService) serviceLocator
        .getService(IBindingService.class);
    final TriggerSequence triggerSequence = bindingService
        .getBestActiveBindingFor(commandId);
    if (triggerSequence instanceof KeySequence) {
      final KeySequence keySequence = (KeySequence) triggerSequence;
      final KeyStroke[] keyStrokes = keySequence.getKeyStrokes();
      if (keyStrokes.length == 1) {
        final KeyStroke keyStroke = keyStrokes[0];
        return keyStroke.getModifierKeys() | keyStroke.getNaturalKey();
      }
    }
View Full Code Here

          contextId = IContextIds.CONTEXT_ID_WINDOW;
        }

        // Read out the key sequence.
        String keySequenceText = readOptional(memento, ATT_KEY_SEQUENCE);
        KeySequence keySequence = null;
        if (keySequenceText == null) {
          keySequenceText = readRequired(memento, ATT_STRING,
              warningsToLog,
              "Key bindings need a key sequence or string"); //$NON-NLS-1$
          if (keySequenceText == null) {
            continue;
          }

          // The key sequence is in the old-style format.
          keySequence = convert2_1Sequence(parse2_1Sequence(keySequenceText));

        } else {
          // The key sequence is in the new-style format.
          try {
            keySequence = KeySequence.getInstance(keySequenceText);
          } catch (final ParseException e) {
            addWarning(warningsToLog, "Could not parse", null, //$NON-NLS-1$
                commandId, "keySequence", keySequenceText); //$NON-NLS-1$
            continue;
          }
          if (keySequence.isEmpty() || !keySequence.isComplete()) {
            addWarning(
                warningsToLog,
                "Key bindings cannot use an empty or incomplete key sequence", //$NON-NLS-1$
                null, commandId, "keySequence", keySequence //$NON-NLS-1$
                    .toString());
            continue;
          }

        }
View Full Code Here

      if ((contextId == null) || (contextId.length() == 0)) {
        contextId = IContextIds.CONTEXT_ID_WINDOW;
      }

      // Read out the key sequence.
      KeySequence keySequence = null;
      String keySequenceText = configurationElement
          .getAttribute(ATT_SEQUENCE);
      if ((keySequenceText == null) || (keySequenceText.length() == 0)) {
        keySequenceText = configurationElement
            .getAttribute(ATT_KEY_SEQUENCE);
      }
      if ((keySequenceText == null) || (keySequenceText.length() == 0)) {
        keySequenceText = configurationElement.getAttribute(ATT_STRING);
        if ((keySequenceText == null)
            || (keySequenceText.length() == 0)) {
          // The key sequence should never be null. This is pointless
          addWarning(
              warningsToLog,
              "Defining a key binding with no key sequence has no effect", //$NON-NLS-1$
              configurationElement, commandId);
          continue;
        }

        // The key sequence is in the old-style format.
        try {
          keySequence = convert2_1Sequence(parse2_1Sequence(keySequenceText));
        } catch (final IllegalArgumentException e) {
          addWarning(warningsToLog, "Could not parse key sequence", //$NON-NLS-1$
              configurationElement, commandId, "keySequence", //$NON-NLS-1$
              keySequenceText);
          continue;
        }

      } else {
        // The key sequence is in the new-style format.
        try {
          keySequence = KeySequence.getInstance(keySequenceText);
        } catch (final ParseException e) {
          addWarning(warningsToLog, "Could not parse key sequence", //$NON-NLS-1$
              configurationElement, commandId, "keySequence", //$NON-NLS-1$
              keySequenceText);
          continue;
        }
        if (keySequence.isEmpty() || !keySequence.isComplete()) {
          addWarning(
              warningsToLog,
              "Key bindings should not have an empty or incomplete key sequence", //$NON-NLS-1$
              configurationElement, commandId, "keySequence", //$NON-NLS-1$
              keySequence.toString());
          continue;
        }

      }
View Full Code Here

   */
  private final void bindingRemove(final KeyBinding binding) {
    ArrayList extraSystemDeletes = new ArrayList();
    final String contextId = binding.getContextId();
    final String schemeId = binding.getSchemeId();
    final KeySequence triggerSequence = binding.getKeySequence();
    if (binding.getType() == Binding.USER) {
      localChangeManager.removeBinding(binding);
    } else {
      // TODO This should be the user's personal scheme.
      Collection previousConflictMatches = (Collection) localChangeManager
View Full Code Here

    long startTime = 0L;
    if (DEBUG) {
      startTime = System.currentTimeMillis();
    }

    final KeySequence keySequence = keySequenceText.getKeySequence();
    if (!keySequence.isComplete()) {
      return;
    }

    if ((keySequence == null) || (keySequence.isEmpty())) {
      ISelection selection = filteredTree.getViewer().getSelection();
      if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        final Object node = structuredSelection.getFirstElement();
        if (node instanceof KeyBinding) {
View Full Code Here

TOP

Related Classes of org.eclipse.jface.bindings.keys.KeySequence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.