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

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

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

Binding.getTriggerSequence介绍

[英]Returns the sequence of trigger for a given binding. The triggers can be anything, but above all it must be hashable. This trigger sequence is used by the binding manager to distinguish between different bindings.
[中]返回给定绑定的触发器序列。触发器可以是任何东西,但最重要的是它必须是可散列的。绑定管理器使用此触发序列来区分不同的绑定。

代码示例

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

  1. public Collection<TriggerSequence> getSequencesFor(ParameterizedCommand command) {
  2. Collection<Binding> bindings = manager.getSequencesFor(contextSet, command);
  3. ArrayList<TriggerSequence> sequences = new ArrayList<TriggerSequence>(bindings.size());
  4. for (Binding binding : bindings) {
  5. sequences.add(binding.getTriggerSequence());
  6. }
  7. return sequences;
  8. }

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

  1. public TriggerSequence getBestSequenceFor(ParameterizedCommand command) {
  2. Binding binding = manager.getBestSequenceFor(contextSet, command);
  3. return binding == null ? null : binding.getTriggerSequence();
  4. }

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

  1. @Override
  2. public TriggerSequence getBestSequenceFor(ParameterizedCommand command) {
  3. Binding binding = manager.getBestSequenceFor(contextSet, command);
  4. return binding == null ? null : binding.getTriggerSequence();
  5. }

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

  1. @Override
  2. public Collection<TriggerSequence> getSequencesFor(ParameterizedCommand command) {
  3. Collection<Binding> bindings = manager.getSequencesFor(contextSet, command);
  4. ArrayList<TriggerSequence> sequences = new ArrayList<TriggerSequence>(bindings.size());
  5. for (Binding binding : bindings) {
  6. sequences.add(binding.getTriggerSequence());
  7. }
  8. return sequences;
  9. }

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

  1. @Override
  2. public Map getPartialMatches(TriggerSequence trigger) {
  3. final Collection<Binding> partialMatches = bindingService.getPartialMatches(trigger);
  4. final Map<TriggerSequence, Binding> result = new HashMap<>(
  5. partialMatches.size());
  6. for (Binding binding : partialMatches) {
  7. result.put(binding.getTriggerSequence(), binding);
  8. }
  9. return result;
  10. }

代码示例来源: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.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 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.ui.workbench

  1. private Binding findPotentialConflict(Binding binding) {
  2. BindingTable table = tableManager.getTable(binding.getContextId());
  3. if (table != null) {
  4. Binding perfectMatch = table.getPerfectMatch(binding.getTriggerSequence());
  5. if (perfectMatch != null) {
  6. return perfectMatch;
  7. }
  8. }
  9. return bindingService.getPerfectMatch(binding.getTriggerSequence());
  10. }

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

  1. public int compare(Binding o1, Binding o2) {
  2. int rc = compareSchemes(activeSchemeIds, o1.getSchemeId(), o2.getSchemeId());
  3. if (rc != 0) {
  4. return rc;
  5. }
  6. /*
  7. * Check to see which has the least number of triggers in the trigger sequence.
  8. */
  9. final Trigger[] bestTriggers = o1.getTriggerSequence().getTriggers();
  10. final Trigger[] currentTriggers = o2.getTriggerSequence().getTriggers();
  11. int compareTo = bestTriggers.length - currentTriggers.length;
  12. if (compareTo != 0) {
  13. return compareTo;
  14. }
  15. /*
  16. * Compare the number of keys pressed in each trigger sequence. Some types of keys count
  17. * less than others (i.e., some types of modifiers keys are less likely to be chosen).
  18. */
  19. compareTo = countStrokes(bestTriggers) - countStrokes(currentTriggers);
  20. if (compareTo != 0) {
  21. return compareTo;
  22. }
  23. // If this is still a tie, then just chose the shortest text.
  24. return o1.getTriggerSequence().format().length()
  25. - o2.getTriggerSequence().format().length();
  26. }

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

  1. protected Optional<TriggerSequence> getKeybindingSequence(IBindingService bindingService,
  2. ECommandService eCommandService, BindingTableManager bindingTableManager, IContextService contextService,
  3. String commandId) {
  4. TriggerSequence triggerSequence = bindingService.getBestActiveBindingFor(commandId);
  5. // FIXME Bug 491701 - [KeyBinding] get best active binding is not
  6. // working
  7. if (triggerSequence == null) {
  8. ParameterizedCommand cmd = eCommandService.createCommand(commandId, null);
  9. ContextSet contextSet = bindingTableManager
  10. .createContextSet(Arrays.asList(contextService.getDefinedContexts()));
  11. Binding binding = bindingTableManager.getBestSequenceFor(contextSet, cmd);
  12. if (binding != null) {
  13. triggerSequence = binding.getTriggerSequence();
  14. }
  15. }
  16. return Optional.ofNullable(triggerSequence);
  17. }

代码示例来源: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. /**
  2. * Compute the best binding for the command and sets the trigger
  3. *
  4. */
  5. protected void updateQuickAccessTriggerSequence() {
  6. triggerSequence = bindingService.getBestActiveBindingFor(QUICK_ACCESS_COMMAND_ID);
  7. // FIXME Bug 491701 - [KeyBinding] get best active binding is not working
  8. if (triggerSequence == null) {
  9. ParameterizedCommand cmd = eCommandService.createCommand(QUICK_ACCESS_COMMAND_ID, null);
  10. ContextSet contextSet = manager.createContextSet(Arrays.asList(contextService.getDefinedContexts()));
  11. Binding binding = manager.getBestSequenceFor(contextSet, cmd);
  12. triggerSequence = (binding == null) ? null : binding.getTriggerSequence();
  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. 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.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. }

代码示例来源: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.platform/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. * 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. }

相关文章