org.eclipse.jface.bindings.Binding.getParameterizedCommand()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(12.4k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.eclipse.jface.bindings.Binding.getParameterizedCommand()方法的一些代码示例,展示了Binding.getParameterizedCommand()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding.getParameterizedCommand()方法的具体详情如下:
包路径:org.eclipse.jface.bindings.Binding
类名称:Binding
方法名:getParameterizedCommand

Binding.getParameterizedCommand介绍

[英]Returns the parameterized command to which this binding applies. If the identifier is null, then this binding is "unbinding" an existing binding.
[中]返回应用此绑定的参数化命令。如果标识符为null,则此绑定是“解除绑定”现有绑定。

代码示例

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

  1. private ParameterizedCommand getCommand(Object element) {
  2. if (element instanceof BindingElement) {
  3. Object modelObject = ((BindingElement) element).getModelObject();
  4. if (modelObject instanceof Binding) {
  5. return ((Binding) modelObject).getParameterizedCommand();
  6. } else if (modelObject instanceof ParameterizedCommand) {
  7. return (ParameterizedCommand) modelObject;
  8. }
  9. }
  10. return null;
  11. }
  12. }

代码示例来源:origin: org.eclipse.e4.ui/bindings

  1. public int compare(Binding binding1, Binding binding2) {
  2. ParameterizedCommand cmdA = binding1.getParameterizedCommand();
  3. ParameterizedCommand cmdB = binding2.getParameterizedCommand();
  4. int result = 0;
  5. try {
  6. result = cmdA.getName().compareTo(cmdB.getName());
  7. } catch (NotDefinedException e) {
  8. // whaaa?
  9. }
  10. return result;
  11. }
  12. });

代码示例来源:origin: org.eclipse.e4.ui/bindings

  1. public int compare(Binding a, Binding b) {
  2. Binding bindingA = a;
  3. Binding bindingB = b;
  4. ParameterizedCommand commandA = bindingA.getParameterizedCommand();
  5. ParameterizedCommand commandB = bindingB.getParameterizedCommand();
  6. try {
  7. return commandA.getName().compareTo(commandB.getName());
  8. } catch (NotDefinedException e) {
  9. // should not happen
  10. return 0;
  11. }
  12. }
  13. });

代码示例来源:origin: org.eclipse.e4.ui/bindings

  1. private void addBindingSimple(Binding binding) {
  2. bindings.add(binding);
  3. bindingsByTrigger.put(binding.getTriggerSequence(), binding);
  4. ArrayList<Binding> sequences = bindingsByCommand.get(binding.getParameterizedCommand());
  5. if (sequences == null) {
  6. sequences = new ArrayList<Binding>();
  7. bindingsByCommand.put(binding.getParameterizedCommand(), sequences);
  8. }
  9. sequences.add(binding);
  10. Collections.sort(sequences, BEST_SEQUENCE);
  11. TriggerSequence[] prefs = binding.getTriggerSequence().getPrefixes();
  12. for (int i = 1; i < prefs.length; i++) {
  13. ArrayList<Binding> bindings = bindingsByPrefix.get(prefs[i]);
  14. if (bindings == null) {
  15. bindings = new ArrayList<Binding>();
  16. bindingsByPrefix.put(prefs[i], bindings);
  17. }
  18. bindings.add(binding);
  19. }
  20. }

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.bindings

  1. private void addBindingSimple(Binding binding) {
  2. bindings.add(binding);
  3. bindingsByTrigger.put(binding.getTriggerSequence(), binding);
  4. ArrayList<Binding> sequences = bindingsByCommand.get(binding.getParameterizedCommand());
  5. if (sequences == null) {
  6. sequences = new ArrayList<Binding>();
  7. bindingsByCommand.put(binding.getParameterizedCommand(), sequences);
  8. }
  9. sequences.add(binding);
  10. Collections.sort(sequences, BEST_SEQUENCE);
  11. TriggerSequence[] prefs = binding.getTriggerSequence().getPrefixes();
  12. for (int i = 1; i < prefs.length; i++) {
  13. ArrayList<Binding> bindings = bindingsByPrefix.get(prefs[i]);
  14. if (bindings == null) {
  15. bindings = new ArrayList<Binding>();
  16. bindingsByPrefix.put(prefs[i], bindings);
  17. }
  18. bindings.add(binding);
  19. }
  20. }

代码示例来源:origin: org.eclipse.e4.ui/bindings

  1. private void removeBindingSimple(Binding binding) {
  2. bindings.remove(binding);
  3. bindingsByTrigger.remove(binding.getTriggerSequence());
  4. ArrayList<Binding> sequences = bindingsByCommand.get(binding.getParameterizedCommand());
  5. if (sequences != null) {
  6. sequences.remove(binding);
  7. }
  8. TriggerSequence[] prefs = binding.getTriggerSequence().getPrefixes();
  9. for (int i = 1; i < prefs.length; i++) {
  10. ArrayList<Binding> bindings = bindingsByPrefix.get(prefs[i]);
  11. if (bindings != null) {
  12. bindings.remove(binding);
  13. }
  14. }
  15. }

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.bindings

  1. private void removeBindingSimple(Binding binding) {
  2. bindings.remove(binding);
  3. bindingsByTrigger.remove(binding.getTriggerSequence());
  4. ArrayList<Binding> sequences = bindingsByCommand.get(binding.getParameterizedCommand());
  5. if (sequences != null) {
  6. sequences.remove(binding);
  7. }
  8. TriggerSequence[] prefs = binding.getTriggerSequence().getPrefixes();
  9. for (int i = 1; i < prefs.length; i++) {
  10. ArrayList<Binding> bindings = bindingsByPrefix.get(prefs[i]);
  11. if (bindings != null) {
  12. bindings.remove(binding);
  13. }
  14. }
  15. }

代码示例来源:origin: org.eclipse.e4.ui/bindings

  1. /**
  2. * Determines whether the key sequence is a perfect match for any command. If there is a match,
  3. * then the corresponding command identifier is returned.
  4. *
  5. * @param keySequence
  6. * The key sequence to check for a match; must never be <code>null</code>.
  7. * @return The perfectly matching command; <code>null</code> if no command matches.
  8. */
  9. private ParameterizedCommand getPerfectMatch(KeySequence keySequence) {
  10. Binding perfectMatch = getBindingService().getPerfectMatch(keySequence);
  11. return perfectMatch == null ? null : perfectMatch.getParameterizedCommand();
  12. }

代码示例来源:origin: org.eclipse.e4.ui/bindings

  1. /**
  2. * Handles the default selection event on the table of possible completions. This attempts to
  3. * execute the given command.
  4. */
  5. private void executeKeyBinding(Event trigger) {
  6. int selectionIndex = completionsTable.getSelectionIndex();
  7. // Try to execute the corresponding command.
  8. if (selectionIndex >= 0) {
  9. Binding binding = bindings.get(selectionIndex);
  10. try {
  11. // workbenchKeyboard.updateShellKludge(null);
  12. workbenchKeyboard.executeCommand(binding.getParameterizedCommand(), trigger);
  13. } catch (CommandException e) {
  14. // WorkbenchPlugin.log(binding.getParameterizedCommand().toString(), e);
  15. // TODO we probably need to log something here.
  16. System.err.println(binding.getParameterizedCommand().toString() + " : " + e); //$NON-NLS-1$
  17. }
  18. }
  19. }

代码示例来源:origin: ystrot/glance

  1. public String getBindCommand(KeySequence keySequence) {
  2. Map<?, ?> map = bindingManager.getActiveBindingsDisregardingContext();
  3. List<?> bindings = (List<?>) map.get(keySequence);
  4. if (bindings != null) {
  5. for (Object obj : bindings) {
  6. Binding binding = (Binding) obj;
  7. if (GLANCE_CTX.equals(binding.getContextId())) {
  8. return binding.getParameterizedCommand().getId();
  9. }
  10. }
  11. }
  12. return null;
  13. }

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.bindings

  1. /**
  2. * Handles the default selection event on the table of possible completions. This attempts to
  3. * execute the given command.
  4. */
  5. private void executeKeyBinding(Event trigger) {
  6. int selectionIndex = completionsTable.getSelectionIndex();
  7. // Try to execute the corresponding command.
  8. if (selectionIndex >= 0) {
  9. close();
  10. Binding binding = bindings.get(selectionIndex);
  11. try {
  12. // workbenchKeyboard.updateShellKludge(null);
  13. workbenchKeyboard.executeCommand(binding.getParameterizedCommand(), trigger);
  14. } catch (CommandException e) {
  15. // WorkbenchPlugin.log(binding.getParameterizedCommand().toString(), e);
  16. // TODO we probably need to log something here.
  17. System.err.println(binding.getParameterizedCommand().toString() + " : " + e); //$NON-NLS-1$
  18. }
  19. }
  20. }

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.bindings

  1. /**
  2. * @param keySequence
  3. * @param context2
  4. * @return
  5. */
  6. private Collection<Binding> getExecutableMatches(KeySequence keySequence, IEclipseContext context2) {
  7. Binding binding = getBindingService().getPerfectMatch(keySequence);
  8. if (binding != null) {
  9. return Collections.singleton(binding);
  10. }
  11. Collection<Binding> conflicts = getBindingService().getConflictsFor(keySequence);
  12. if (conflicts != null) {
  13. return conflicts.stream()
  14. .filter(match -> getHandlerService().canExecute(match.getParameterizedCommand(), context2))
  15. .collect(Collectors.toSet());
  16. }
  17. return Collections.emptySet();
  18. }

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

  1. @Override
  2. public String getPerfectMatch(KeySequence keySequence) {
  3. try {
  4. final org.eclipse.jface.bindings.keys.KeySequence sequence = org.eclipse.jface.bindings.keys.KeySequence
  5. .getInstance(keySequence.toString());
  6. final Binding binding = bindingManager.getPerfectMatch(sequence);
  7. if (binding == null) {
  8. return null;
  9. }
  10. return binding.getParameterizedCommand().getId();
  11. } catch (final ParseException e) {
  12. return null;
  13. }
  14. }

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

  1. /**
  2. * @param b
  3. * @param model
  4. */
  5. public void init(Binding b, ContextModel model) {
  6. setCommandInfo(b.getParameterizedCommand());
  7. setTrigger(b.getTriggerSequence());
  8. setContext((ContextElement) model.getContextIdToElement().get(
  9. b.getContextId()));
  10. setUserDelta(Integer.valueOf(b.getType()));
  11. setModelObject(b);
  12. }

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

  1. /**
  2. * Makes a copy of the
  3. *
  4. * @param element
  5. */
  6. public void copy(BindingElement element) {
  7. if (element == null || !(element.getModelObject() instanceof Binding)) {
  8. return;
  9. }
  10. BindingElement be = new BindingElement(controller);
  11. ParameterizedCommand parameterizedCommand = ((Binding) element
  12. .getModelObject()).getParameterizedCommand();
  13. be.init(parameterizedCommand);
  14. be.setParent(this);
  15. bindingElements.add(be);
  16. commandToElement.put(parameterizedCommand, be);
  17. controller.firePropertyChange(this, PROP_BINDING_ADD, null, be);
  18. setSelectedElement(be);
  19. }

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

  1. /**
  2. * Tests whether this binding is intended to delete another binding. The
  3. * receiver must have a <code>null</code> command identifier.
  4. *
  5. * @param binding
  6. * The binding to test; must not be <code>null</code>.
  7. * This binding must be a <code>SYSTEM</code> binding.
  8. * @return <code>true</code> if the receiver deletes the binding defined by
  9. * the argument.
  10. */
  11. final boolean deletes(final Binding binding) {
  12. boolean deletes = true;
  13. deletes &= Objects.equals(getContextId(), binding.getContextId());
  14. deletes &= Objects.equals(getTriggerSequence(), binding
  15. .getTriggerSequence());
  16. if (getLocale() != null) {
  17. deletes &= !Objects.equals(getLocale(), binding.getLocale());
  18. }
  19. if (getPlatform() != null) {
  20. deletes &= !Objects.equals(getPlatform(), binding.getPlatform());
  21. }
  22. deletes &= (binding.getType() == SYSTEM);
  23. deletes &= Objects.equals(getParameterizedCommand(), null);
  24. return deletes;
  25. }

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

  1. static final boolean deletes(final Binding del, final Binding binding) {
  2. boolean deletes = true;
  3. deletes &= Util.equals(del.getContextId(), binding.getContextId());
  4. deletes &= Util.equals(del.getTriggerSequence(), binding
  5. .getTriggerSequence());
  6. if (del.getLocale() != null) {
  7. deletes &= Util.equals(del.getLocale(), binding.getLocale());
  8. }
  9. if (del.getPlatform() != null) {
  10. deletes &= Util.equals(del.getPlatform(), binding.getPlatform());
  11. }
  12. deletes &= (binding.getType() == Binding.SYSTEM);
  13. deletes &= Util.equals(del.getParameterizedCommand(), null);
  14. return deletes;
  15. }

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

  1. /**
  2. * Computes the hash code for this key binding based on all of its
  3. * attributes.
  4. *
  5. * @return The hash code for this key binding.
  6. */
  7. public final int hashCode() {
  8. if (hashCode == HASH_CODE_NOT_COMPUTED) {
  9. hashCode = HASH_INITIAL;
  10. hashCode = hashCode * HASH_FACTOR
  11. + Util.hashCode(getParameterizedCommand());
  12. hashCode = hashCode * HASH_FACTOR + Util.hashCode(getContextId());
  13. hashCode = hashCode * HASH_FACTOR
  14. + Util.hashCode(getTriggerSequence());
  15. hashCode = hashCode * HASH_FACTOR + Util.hashCode(getLocale());
  16. hashCode = hashCode * HASH_FACTOR + Util.hashCode(getPlatform());
  17. hashCode = hashCode * HASH_FACTOR + Util.hashCode(getSchemeId());
  18. hashCode = hashCode * HASH_FACTOR + Util.hashCode(getType());
  19. if (hashCode == HASH_CODE_NOT_COMPUTED) {
  20. hashCode++;
  21. }
  22. }
  23. return hashCode;
  24. }

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

  1. /**
  2. * Computes the hash code for this key binding based on all of its
  3. * attributes.
  4. *
  5. * @return The hash code for this key binding.
  6. */
  7. @Override
  8. public final int hashCode() {
  9. if (hashCode == HASH_CODE_NOT_COMPUTED) {
  10. hashCode = HASH_INITIAL;
  11. hashCode = hashCode * HASH_FACTOR
  12. + Util.hashCode(getParameterizedCommand());
  13. hashCode = hashCode * HASH_FACTOR + Util.hashCode(getContextId());
  14. hashCode = hashCode * HASH_FACTOR
  15. + Util.hashCode(getTriggerSequence());
  16. hashCode = hashCode * HASH_FACTOR + Util.hashCode(getLocale());
  17. hashCode = hashCode * HASH_FACTOR + Util.hashCode(getPlatform());
  18. hashCode = hashCode * HASH_FACTOR + Util.hashCode(getSchemeId());
  19. hashCode = hashCode * HASH_FACTOR + Util.hashCode(getType());
  20. if (hashCode == HASH_CODE_NOT_COMPUTED) {
  21. hashCode++;
  22. }
  23. }
  24. return hashCode;
  25. }

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

  1. /**
  2. * Tests whether this binding is intended to delete another binding. The
  3. * receiver must have a <code>null</code> command identifier.
  4. *
  5. * @param binding
  6. * The binding to test; must not be <code>null</code>.
  7. * This binding must be a <code>SYSTEM</code> binding.
  8. * @return <code>true</code> if the receiver deletes the binding defined by
  9. * the argument.
  10. */
  11. final boolean deletes(final Binding binding) {
  12. boolean deletes = true;
  13. deletes &= Util.equals(getContextId(), binding.getContextId());
  14. deletes &= Util.equals(getTriggerSequence(), binding
  15. .getTriggerSequence());
  16. if (getLocale() != null) {
  17. deletes &= !Util.equals(getLocale(), binding.getLocale());
  18. }
  19. if (getPlatform() != null) {
  20. deletes &= !Util.equals(getPlatform(), binding.getPlatform());
  21. }
  22. deletes &= (binding.getType() == SYSTEM);
  23. deletes &= Util.equals(getParameterizedCommand(), null);
  24. return deletes;
  25. }

相关文章