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

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

本文整理了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

public Collection<TriggerSequence> getSequencesFor(ParameterizedCommand command) {
  Collection<Binding> bindings = manager.getSequencesFor(contextSet, command);
  ArrayList<TriggerSequence> sequences = new ArrayList<TriggerSequence>(bindings.size());
  for (Binding binding : bindings) {
    sequences.add(binding.getTriggerSequence());
  }
  return sequences;
}

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

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

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

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

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

@Override
public Collection<TriggerSequence> getSequencesFor(ParameterizedCommand command) {
  Collection<Binding> bindings = manager.getSequencesFor(contextSet, command);
  ArrayList<TriggerSequence> sequences = new ArrayList<TriggerSequence>(bindings.size());
  for (Binding binding : bindings) {
    sequences.add(binding.getTriggerSequence());
  }
  return sequences;
}

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

@Override
public Map getPartialMatches(TriggerSequence trigger) {
  final Collection<Binding> partialMatches = bindingService.getPartialMatches(trigger);
  final Map<TriggerSequence, Binding> result = new HashMap<>(
      partialMatches.size());
  for (Binding binding : partialMatches) {
    result.put(binding.getTriggerSequence(), binding);
  }
  return result;
}

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

private void removeBindingSimple(Binding binding) {
  bindings.remove(binding);
  bindingsByTrigger.remove(binding.getTriggerSequence());
  ArrayList<Binding> sequences = bindingsByCommand.get(binding.getParameterizedCommand());
  if (sequences != null) {
    sequences.remove(binding);
  }
  TriggerSequence[] prefs = binding.getTriggerSequence().getPrefixes();
  for (int i = 1; i < prefs.length; i++) {
    ArrayList<Binding> bindings = bindingsByPrefix.get(prefs[i]);
    if (bindings != null) {
      bindings.remove(binding);
    }
  }
}

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

private void removeBindingSimple(Binding binding) {
  bindings.remove(binding);
  bindingsByTrigger.remove(binding.getTriggerSequence());
  ArrayList<Binding> sequences = bindingsByCommand.get(binding.getParameterizedCommand());
  if (sequences != null) {
    sequences.remove(binding);
  }
  TriggerSequence[] prefs = binding.getTriggerSequence().getPrefixes();
  for (int i = 1; i < prefs.length; i++) {
    ArrayList<Binding> bindings = bindingsByPrefix.get(prefs[i]);
    if (bindings != null) {
      bindings.remove(binding);
    }
  }
}

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

private void addBindingSimple(Binding binding) {
  bindings.add(binding);
  bindingsByTrigger.put(binding.getTriggerSequence(), binding);
  ArrayList<Binding> sequences = bindingsByCommand.get(binding.getParameterizedCommand());
  if (sequences == null) {
    sequences = new ArrayList<Binding>();
    bindingsByCommand.put(binding.getParameterizedCommand(), sequences);
  }
  sequences.add(binding);
  Collections.sort(sequences, BEST_SEQUENCE);
  TriggerSequence[] prefs = binding.getTriggerSequence().getPrefixes();
  for (int i = 1; i < prefs.length; i++) {
    ArrayList<Binding> bindings = bindingsByPrefix.get(prefs[i]);
    if (bindings == null) {
      bindings = new ArrayList<Binding>();
      bindingsByPrefix.put(prefs[i], bindings);
    }
    bindings.add(binding);
  }
}

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

private void addBindingSimple(Binding binding) {
  bindings.add(binding);
  bindingsByTrigger.put(binding.getTriggerSequence(), binding);
  ArrayList<Binding> sequences = bindingsByCommand.get(binding.getParameterizedCommand());
  if (sequences == null) {
    sequences = new ArrayList<Binding>();
    bindingsByCommand.put(binding.getParameterizedCommand(), sequences);
  }
  sequences.add(binding);
  Collections.sort(sequences, BEST_SEQUENCE);
  TriggerSequence[] prefs = binding.getTriggerSequence().getPrefixes();
  for (int i = 1; i < prefs.length; i++) {
    ArrayList<Binding> bindings = bindingsByPrefix.get(prefs[i]);
    if (bindings == null) {
      bindings = new ArrayList<Binding>();
      bindingsByPrefix.put(prefs[i], bindings);
    }
    bindings.add(binding);
  }
}

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

private Binding findPotentialConflict(Binding binding) {
  BindingTable table = tableManager.getTable(binding.getContextId());
  if (table != null) {
    Binding perfectMatch = table.getPerfectMatch(binding.getTriggerSequence());
    if (perfectMatch != null) {
      return perfectMatch;
    }
  }
  return bindingService.getPerfectMatch(binding.getTriggerSequence());
}

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

public int compare(Binding o1, Binding o2) {
  int rc = compareSchemes(activeSchemeIds, o1.getSchemeId(), o2.getSchemeId());
  if (rc != 0) {
    return rc;
  }
  /*
   * Check to see which has the least number of triggers in the trigger sequence.
   */
  final Trigger[] bestTriggers = o1.getTriggerSequence().getTriggers();
  final Trigger[] currentTriggers = o2.getTriggerSequence().getTriggers();
  int compareTo = bestTriggers.length - currentTriggers.length;
  if (compareTo != 0) {
    return compareTo;
  }
  /*
   * Compare the number of keys pressed in each trigger sequence. Some types of keys count
   * less than others (i.e., some types of modifiers keys are less likely to be chosen).
   */
  compareTo = countStrokes(bestTriggers) - countStrokes(currentTriggers);
  if (compareTo != 0) {
    return compareTo;
  }
  // If this is still a tie, then just chose the shortest text.
  return o1.getTriggerSequence().format().length()
      - o2.getTriggerSequence().format().length();
}

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

protected Optional<TriggerSequence> getKeybindingSequence(IBindingService bindingService,
    ECommandService eCommandService, BindingTableManager bindingTableManager, IContextService contextService,
    String commandId) {
  TriggerSequence triggerSequence = bindingService.getBestActiveBindingFor(commandId);
  // FIXME Bug 491701 - [KeyBinding] get best active binding is not
  // working
  if (triggerSequence == null) {
    ParameterizedCommand cmd = eCommandService.createCommand(commandId, null);
    ContextSet contextSet = bindingTableManager
        .createContextSet(Arrays.asList(contextService.getDefinedContexts()));
    Binding binding = bindingTableManager.getBestSequenceFor(contextSet, cmd);
    if (binding != null) {
      triggerSequence = binding.getTriggerSequence();
    }
  }
  return Optional.ofNullable(triggerSequence);
}

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

/**
 * Tests whether this binding is intended to delete another binding. The
 * receiver must have a <code>null</code> command identifier.
 *
 * @param binding
 *            The binding to test; must not be <code>null</code>.
 *            This binding must be a <code>SYSTEM</code> binding.
 * @return <code>true</code> if the receiver deletes the binding defined by
 *             the argument.
 */
final boolean deletes(final Binding binding) {
  boolean deletes = true;
  deletes &= Objects.equals(getContextId(), binding.getContextId());
  deletes &= Objects.equals(getTriggerSequence(), binding
      .getTriggerSequence());
  if (getLocale() != null) {
    deletes &= !Objects.equals(getLocale(), binding.getLocale());
  }
  if (getPlatform() != null) {
    deletes &= !Objects.equals(getPlatform(), binding.getPlatform());
  }
  deletes &= (binding.getType() == SYSTEM);
  deletes &= Objects.equals(getParameterizedCommand(), null);
  return deletes;
}

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

/**
 * Compute the best binding for the command and sets the trigger
 *
 */
protected void updateQuickAccessTriggerSequence() {
  triggerSequence = bindingService.getBestActiveBindingFor(QUICK_ACCESS_COMMAND_ID);
  // FIXME Bug 491701 - [KeyBinding] get best active binding is not working
  if (triggerSequence == null) {
    ParameterizedCommand cmd = eCommandService.createCommand(QUICK_ACCESS_COMMAND_ID, null);
    ContextSet contextSet = manager.createContextSet(Arrays.asList(contextService.getDefinedContexts()));
    Binding binding = manager.getBestSequenceFor(contextSet, cmd);
    triggerSequence = (binding == null) ? null : binding.getTriggerSequence();
  }
}

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

/**
 * @param b
 * @param model
 */
public void init(Binding b, ContextModel model) {
  setCommandInfo(b.getParameterizedCommand());
  setTrigger(b.getTriggerSequence());
  setContext((ContextElement) model.getContextIdToElement().get(
      b.getContextId()));
  setUserDelta(Integer.valueOf(b.getType()));
  setModelObject(b);
}

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

static final boolean deletes(final Binding del, final Binding binding) {
  boolean deletes = true;
  deletes &= Util.equals(del.getContextId(), binding.getContextId());
  deletes &= Util.equals(del.getTriggerSequence(), binding
      .getTriggerSequence());
  if (del.getLocale() != null) {
    deletes &= Util.equals(del.getLocale(), binding.getLocale());
  }
  if (del.getPlatform() != null) {
    deletes &= Util.equals(del.getPlatform(), binding.getPlatform());
  }
  deletes &= (binding.getType() == Binding.SYSTEM);
  deletes &= Util.equals(del.getParameterizedCommand(), null);
  return deletes;
}

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

/**
 * Tests whether this binding is intended to delete another binding. The
 * receiver must have a <code>null</code> command identifier.
 *
 * @param binding
 *            The binding to test; must not be <code>null</code>.
 *            This binding must be a <code>SYSTEM</code> binding.
 * @return <code>true</code> if the receiver deletes the binding defined by
 *             the argument.
 */
final boolean deletes(final Binding binding) {
  boolean deletes = true;
  deletes &= Util.equals(getContextId(), binding.getContextId());
  deletes &= Util.equals(getTriggerSequence(), binding
      .getTriggerSequence());
  if (getLocale() != null) {
    deletes &= !Util.equals(getLocale(), binding.getLocale());
  }
  if (getPlatform() != null) {
    deletes &= !Util.equals(getPlatform(), binding.getPlatform());
  }
  deletes &= (binding.getType() == SYSTEM);
  deletes &= Util.equals(getParameterizedCommand(), null);
  return deletes;
}

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

/**
 * Computes the hash code for this key binding based on all of its
 * attributes.
 * 
 * @return The hash code for this key binding.
 */
public final int hashCode() {
  if (hashCode == HASH_CODE_NOT_COMPUTED) {
    hashCode = HASH_INITIAL;
    hashCode = hashCode * HASH_FACTOR
        + Util.hashCode(getParameterizedCommand());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getContextId());
    hashCode = hashCode * HASH_FACTOR
        + Util.hashCode(getTriggerSequence());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getLocale());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getPlatform());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getSchemeId());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getType());
    if (hashCode == HASH_CODE_NOT_COMPUTED) {
      hashCode++;
    }
  }
  return hashCode;
}

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

/**
 * Computes the hash code for this key binding based on all of its
 * attributes.
 *
 * @return The hash code for this key binding.
 */
@Override
public final int hashCode() {
  if (hashCode == HASH_CODE_NOT_COMPUTED) {
    hashCode = HASH_INITIAL;
    hashCode = hashCode * HASH_FACTOR
        + Util.hashCode(getParameterizedCommand());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getContextId());
    hashCode = hashCode * HASH_FACTOR
        + Util.hashCode(getTriggerSequence());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getLocale());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getPlatform());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getSchemeId());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getType());
    if (hashCode == HASH_CODE_NOT_COMPUTED) {
      hashCode++;
    }
  }
  return hashCode;
}

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

/**
 * Computes the hash code for this key binding based on all of its
 * attributes.
 *
 * @return The hash code for this key binding.
 */
@Override
public final int hashCode() {
  if (hashCode == HASH_CODE_NOT_COMPUTED) {
    hashCode = HASH_INITIAL;
    hashCode = hashCode * HASH_FACTOR
        + Util.hashCode(getParameterizedCommand());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getContextId());
    hashCode = hashCode * HASH_FACTOR
        + Util.hashCode(getTriggerSequence());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getLocale());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getPlatform());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getSchemeId());
    hashCode = hashCode * HASH_FACTOR + Util.hashCode(getType());
    if (hashCode == HASH_CODE_NOT_COMPUTED) {
      hashCode++;
    }
  }
  return hashCode;
}

相关文章