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

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

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

Binding.getContextId介绍

[英]Returns the identifier of the context in which this binding applies.
[中]返回应用此绑定的上下文的标识符。

代码示例

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

public final void addBinding(final MApplication application, final Binding binding) {
  MBindingTable table = tables.get(binding.getContextId());
  if (table == null) {
    table = createTable(application, binding.getContextId());
  }
  MKeyBinding model = BindingService.createORupdateMKeyBinding(application, table, binding);
  keys.remove(model);
}

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

@Override
public void deactivateBinding(Binding binding) {
  String contextId = binding.getContextId();
  BindingTable table = manager.getTable(contextId);
  if (table == null) {
    //System.err.println("No binding table for " + contextId); //$NON-NLS-1$
    return;
  }
  table.removeBinding(binding);
}

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

public void activateBinding(Binding binding) {
  String contextId = binding.getContextId();
  BindingTable table = manager.getTable(contextId);
  if (table == null) {
    return;
  }
  table.addBinding(binding);
}

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

public void deactivateBinding(Binding binding) {
  String contextId = binding.getContextId();
  BindingTable table = manager.getTable(contextId);
  if (table == null) {
    //System.err.println("No binding table for " + contextId); //$NON-NLS-1$
    return;
  }
  table.removeBinding(binding);
}

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

@Override
public void activateBinding(Binding binding) {
  String contextId = binding.getContextId();
  BindingTable table = manager.getTable(contextId);
  if (table == null) {
    return;
  }
  table.addBinding(binding);
}

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

public String getBindCommand(KeySequence keySequence) {
  Map<?, ?> map = bindingManager.getActiveBindingsDisregardingContext();
  List<?> bindings = (List<?>) map.get(keySequence);
  if (bindings != null) {
    for (Object obj : bindings) {
      Binding binding = (Binding) obj;
      if (GLANCE_CTX.equals(binding.getContextId())) {
        return binding.getParameterizedCommand().getId();
      }
    }
  }
  return null;
}

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

public void addBinding(Binding binding) {
  if (!getId().equals(binding.getContextId())) {
    throw new IllegalArgumentException("Binding context " + binding.getContextId() //$NON-NLS-1$
        + " does not match " + getId()); //$NON-NLS-1$
  }
  ArrayList<Binding> bindingList = orderedBindingsByTrigger.get(binding.getTriggerSequence());
  Binding possibleConflict = bindingsByTrigger.get(binding.getTriggerSequence());
  if (bindingList == null || bindingList.isEmpty()) {
    if (possibleConflict != null) {
      if (bindingList == null) {
        bindingList = new ArrayList<Binding>();
        orderedBindingsByTrigger.put(binding.getTriggerSequence(), bindingList);
      }
      bindingList.add(binding);
      bindingList.add(possibleConflict);
      Collections.sort(bindingList, BEST_SEQUENCE);
    }
  } else {
    bindingList.add(binding);
    Collections.sort(bindingList, BEST_SEQUENCE);
  }
  if (possibleConflict != null && bindingList != null && !bindingList.isEmpty()
      && bindingList.get(0) != possibleConflict) {
    removeBindingSimple(possibleConflict);
    possibleConflict = null;
  }
  evaluateOrderedBindings(binding.getTriggerSequence(), binding);
}

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

/**
 * TODO Promote this method to API.
 * <p>
 * Adds a single new binding to the existing array of bindings. If the array
 * is currently <code>null</code>, then a new array is created and this
 * binding is added to it. This method does not detect duplicates.
 * </p>
 * <p>
 * This method completes in amortized <code>O(1)</code>.
 * </p>
 *
 * @param binding
 *            The binding to be added; must not be <code>null</code>.
 */
public void addBinding(final Binding binding) {
  MBindingTable table = getMTable(binding.getContextId());
  createORupdateMKeyBinding(application, table, binding);
}

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

public void removeBinding(Binding binding) {
  if (!getId().equals(binding.getContextId())) {
    throw new IllegalArgumentException("Binding context " + binding.getContextId() //$NON-NLS-1$
        + " does not match " + getId()); //$NON-NLS-1$
  }
  ArrayList<Binding> bindingList = orderedBindingsByTrigger.get(binding.getTriggerSequence());
  Binding possibleConflict = bindingsByTrigger.get(binding.getTriggerSequence());
  if (possibleConflict == binding) {
    removeBindingSimple(binding);
    if (bindingList != null) {
      bindingList.remove(binding);
      if (bindingList.isEmpty()) {
        orderedBindingsByTrigger.remove(binding.getTriggerSequence());
      } else {
        evaluateOrderedBindings(binding.getTriggerSequence(), null);
      }
    }
  } else if (bindingList != null) {
    bindingList.remove(binding);
    if (bindingList.isEmpty()) {
      orderedBindingsByTrigger.remove(binding.getTriggerSequence());
    } else {
      evaluateOrderedBindings(binding.getTriggerSequence(), null);
    }
  }
}

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

public void removeBinding(Binding binding) {
  if (!getId().equals(binding.getContextId())) {
    throw new IllegalArgumentException("Binding context " + binding.getContextId() //$NON-NLS-1$
        + " does not match " + getId()); //$NON-NLS-1$
  }
  ArrayList<Binding> bindingList = orderedBindingsByTrigger.get(binding.getTriggerSequence());
  Binding possibleConflict = bindingsByTrigger.get(binding.getTriggerSequence());
  if (possibleConflict == binding) {
    removeBindingSimple(binding);
    if (bindingList != null) {
      bindingList.remove(binding);
      if (bindingList.isEmpty()) {
        orderedBindingsByTrigger.remove(binding.getTriggerSequence());
      } else {
        evaluateOrderedBindings(binding.getTriggerSequence(), null);
      }
    }
  } else if (bindingList != null) {
    bindingList.remove(binding);
    if (bindingList.isEmpty()) {
      orderedBindingsByTrigger.remove(binding.getTriggerSequence());
    } else {
      evaluateOrderedBindings(binding.getTriggerSequence(), null);
    }
  }
}

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

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.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

/**
 * Handles the selection event on the table containing the bindings for a
 * particular trigger sequence. This updates the context based on the
 * selected binding.
 */
private void selectedTableBindingsForTriggerSequence() {
  final int selection = tableBindingsForTriggerSequence
      .getSelectionIndex();
  if ((selection >= 0)
      && (selection < tableBindingsForTriggerSequence.getItemCount())) {
    final TableItem item = tableBindingsForTriggerSequence
        .getItem(selection);
    final Binding binding = (Binding) item.getData(ITEM_DATA_KEY);
    setContextId(binding.getContextId());
  }
  update();
}

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

/**
 * 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.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.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.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;
}

相关文章