Package org.eclipse.jface.bindings

Examples of org.eclipse.jface.bindings.Binding


   */
  private final void selectedTableKeyBindings() {
    final int selectionIndex = tableBindings.getSelectionIndex();
    if (selectionIndex != -1) {
      final TableItem item = tableBindings.getItem(selectionIndex);
      final Binding binding = (Binding) item.getData(BINDING_KEY);
      editBinding(binding);

    } else {
      editBinding(null);
    }
View Full Code Here


    }

    final TableItem[] items = table.getItems();
    int selection = -1;
    for (int i = 0; i < items.length; i++) {
      final Binding binding = (Binding) items[i].getData(ITEM_DATA_KEY);
      if ((Util.equals(contextId, binding.getContextId()))
          && (Util.equals(triggerSequence, binding
              .getTriggerSequence()))) {
        selection = i;
        break;
      }
    }
View Full Code Here

    // Add each of the bindings, if the command identifier matches.
    final Collection bindings = localChangeManager
        .getActiveBindingsDisregardingContextFlat();
    final Iterator bindingItr = bindings.iterator();
    while (bindingItr.hasNext()) {
      final Binding binding = (Binding) bindingItr.next();
      if (!Util.equals(parameterizedCommand, binding
          .getParameterizedCommand())) {
        continue; // binding does not match
      }

      final TableItem tableItem = new TableItem(tableBindingsForCommand,
          SWT.NULL);
      tableItem.setData(ITEM_DATA_KEY, binding);

      /*
       * Set the associated image based on the type of binding. Either it
       * is a user binding or a system binding.
       *
       * TODO Identify more image types.
       */
      if (binding.getType() == Binding.SYSTEM) {
        tableItem.setImage(0, IMAGE_BLANK);
      } else {
        tableItem.setImage(0, IMAGE_CHANGE);
      }

      String contextName = (String) contextUniqueNamesById.get(binding
          .getContextId());
      if (contextName == null) {
        contextName = Util.ZERO_LENGTH_STRING;
      }
      tableItem.setText(1, contextName);
      tableItem.setText(2, binding.getTriggerSequence().format());
    }
  }
View Full Code Here

    }

    // Add each of the bindings.
    final Iterator bindingItr = bindings.iterator();
    while (bindingItr.hasNext()) {
      final Binding binding = (Binding) bindingItr.next();
      final Context context = contextService.getContext(binding
          .getContextId());
      final ParameterizedCommand parameterizedCommand = binding
          .getParameterizedCommand();
      final Command command = parameterizedCommand.getCommand();
      if ((!context.isDefined()) && (!command.isDefined())) {
        continue;
      }

      final TableItem tableItem = new TableItem(
          tableBindingsForTriggerSequence, SWT.NULL);
      tableItem.setData(ITEM_DATA_KEY, binding);

      /*
       * Set the associated image based on the type of binding. Either it
       * is a user binding or a system binding.
       *
       * TODO Identify more image types.
       */
      if (binding.getType() == Binding.SYSTEM) {
        tableItem.setImage(0, IMAGE_BLANK);
      } else {
        tableItem.setImage(0, IMAGE_CHANGE);
      }

View Full Code Here

       * @return The integer value representing the comparison. The
       *         comparison is based on the current sort order.
       * @since 3.1
       */
      public final int compare(final Object object1, final Object object2) {
        final Binding binding1 = (Binding) object1;
        final Binding binding2 = (Binding) object2;

        /*
         * Get the category name, command name, formatted key sequence
         * and context name for the first binding.
         */
        final Command command1 = binding1.getParameterizedCommand()
            .getCommand();
        String categoryName1 = Util.ZERO_LENGTH_STRING;
        String commandName1 = Util.ZERO_LENGTH_STRING;
        try {
          commandName1 = command1.getName();
          categoryName1 = command1.getCategory().getName();
        } catch (final NotDefinedException e) {
          // Just use the zero-length string.
        }
        final String triggerSequence1 = binding1.getTriggerSequence()
            .format();
        final String contextId1 = binding1.getContextId();
        String contextName1 = Util.ZERO_LENGTH_STRING;
        if (contextId1 != null) {
          final Context context = contextService
              .getContext(contextId1);
          try {
            contextName1 = context.getName();
          } catch (final org.eclipse.core.commands.common.NotDefinedException e) {
            // Just use the zero-length string.
          }
        }

        /*
         * Get the category name, command name, formatted key sequence
         * and context name for the first binding.
         */
        final Command command2 = binding2.getParameterizedCommand()
            .getCommand();
        String categoryName2 = Util.ZERO_LENGTH_STRING;
        String commandName2 = Util.ZERO_LENGTH_STRING;
        try {
          commandName2 = command2.getName();
          categoryName2 = command2.getCategory().getName();
        } catch (final org.eclipse.core.commands.common.NotDefinedException e) {
          // Just use the zero-length string.
        }
        final String keySequence2 = binding2.getTriggerSequence()
            .format();
        final String contextId2 = binding2.getContextId();
        String contextName2 = Util.ZERO_LENGTH_STRING;
        if (contextId2 != null) {
          final Context context = contextService
              .getContext(contextId2);
          try {
            contextName2 = context.getName();
          } catch (final org.eclipse.core.commands.common.NotDefinedException e) {
            // Just use the zero-length string.
          }
        }

        // Compare the items in the current sort order.
        int compare = 0;
        for (int i = 0; i < sortOrder.length; i++) {
          switch (sortOrder[i]) {
          case VIEW_CATEGORY_COLUMN_INDEX:
            compare = Util.compare(categoryName1, categoryName2);
            if (compare != 0) {
              return compare;
            }
            break;
          case VIEW_COMMAND_COLUMN_INDEX:
            compare = Util.compare(commandName1, commandName2);
            if (compare != 0) {
              return compare;
            }
            break;
          case VIEW_KEY_SEQUENCE_COLUMN_INDEX:
            compare = Util.compare(triggerSequence1, keySequence2);
            if (compare != 0) {
              return compare;
            }
            break;
          case VIEW_CONTEXT_COLUMN_INDEX:
            compare = Util.compare(contextName1, contextName2);
            if (compare != 0) {
              return compare;
            }
            break;
          default:
            throw new Error(
                "Programmer error: added another sort column without modifying the comparator."); //$NON-NLS-1$
          }
        }

        return compare;
      }

      /**
       * @see Object#equals(java.lang.Object)
       */
      public final boolean equals(final Object object) {
        return super.equals(object);
      }
    });

    // Add a table item for each item in the list.
    final Iterator keyBindingItr = bindings.iterator();
    while (keyBindingItr.hasNext()) {
      final Binding binding = (Binding) keyBindingItr.next();

      // Get the command and category name.
      final ParameterizedCommand command = binding
          .getParameterizedCommand();
      String commandName = Util.ZERO_LENGTH_STRING;
      String categoryName = Util.ZERO_LENGTH_STRING;
      try {
        commandName = command.getName();
        categoryName = command.getCommand().getCategory().getName();
      } catch (final org.eclipse.core.commands.common.NotDefinedException e) {
        // Just use the zero-length string.
      }

      // Ignore items with a meaningless command name.
      if ((commandName == null) || (commandName.length() == 0)) {
        continue;
      }

      // Get the context name.
      final String contextId = binding.getContextId();
      String contextName = Util.ZERO_LENGTH_STRING;
      if (contextId != null) {
        final Context context = contextService.getContext(contextId);
        try {
          contextName = context.getName();
        } catch (final org.eclipse.core.commands.common.NotDefinedException e) {
          // Just use the zero-length string.
        }
      }

      // Create the table item.
      final TableItem item = new TableItem(tableBindings, SWT.NONE);
      item.setText(VIEW_CATEGORY_COLUMN_INDEX, categoryName);
      item.setText(VIEW_COMMAND_COLUMN_INDEX, commandName);
      item.setText(VIEW_KEY_SEQUENCE_COLUMN_INDEX, binding
          .getTriggerSequence().format());
      item.setText(VIEW_CONTEXT_COLUMN_INDEX, contextName);
      item.setData(BINDING_KEY, binding);
    }

View Full Code Here

        } else {
          parameterizedCommand = readParameters(memento,
              warningsToLog, command);
        }

        final Binding binding = new KeyBinding(keySequence,
            parameterizedCommand, schemeId, contextId, locale,
            platform, null, Binding.USER);
        bindingManager.addBinding(binding);
      }
    }
View Full Code Here

      } else {
        parameterizedCommand = readParameters(configurationElement,
            warningsToLog, command);
      }

      final Binding binding = new KeyBinding(keySequence,
          parameterizedCommand, schemeId, contextId, locale,
          platform, null, Binding.SYSTEM);
      bindings.add(binding);
    }
View Full Code Here

      writeActiveSchemeToPreferences(xmlMemento, activeScheme);
    }
    if (bindings != null) {
      final int bindingsLength = bindings.length;
      for (int i = 0; i < bindingsLength; i++) {
        final Binding binding = bindings[i];
        if (binding.getType() == Binding.USER) {
          writeBindingToPreferences(xmlMemento, binding);
        }
      }
    }
View Full Code Here

          schemeId, contextId, null, null, null, Binding.USER);
      localChangeManager.addBinding(deleteBinding);
      if (previousConflictMatches != null) {
        Iterator i = previousConflictMatches.iterator();
        while (i.hasNext()) {
          Binding b = (Binding) i.next();
          if (b != binding && deletes(deleteBinding, b)) {
            extraSystemDeletes.add(b);
          }
        }
      }
    }

    // update the model
    bindingModel.remove(binding);
    bindingAdd(binding);
    if (!extraSystemDeletes.isEmpty()) {
      Iterator i = extraSystemDeletes.iterator();
      while (i.hasNext()) {
        KeyBinding b = (KeyBinding) i.next();
        KeyBinding newBinding = new KeyBinding(b.getKeySequence(), b
            .getParameterizedCommand(), b.getSchemeId(), b
            .getContextId(), null, null, null, Binding.USER);
        localChangeManager.addBinding(newBinding);

        bindingModel.remove(b);
        bindingModel.add(newBinding);
View Full Code Here

  }

  private final void updateConflicts(final Collection bindings) {
    Iterator i = bindings.iterator();
    while (i.hasNext()) {
      final Binding b = (Binding) i.next();
      if (b.getParameterizedCommand()!=null) {
        updateConflicts(b);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.bindings.Binding

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.