本文整理了Java中org.eclipse.jface.bindings.Binding.getParameterizedCommand()
方法的一些代码示例,展示了Binding.getParameterizedCommand()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding.getParameterizedCommand()
方法的具体详情如下:
包路径:org.eclipse.jface.bindings.Binding
类名称: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
private ParameterizedCommand getCommand(Object element) {
if (element instanceof BindingElement) {
Object modelObject = ((BindingElement) element).getModelObject();
if (modelObject instanceof Binding) {
return ((Binding) modelObject).getParameterizedCommand();
} else if (modelObject instanceof ParameterizedCommand) {
return (ParameterizedCommand) modelObject;
}
}
return null;
}
}
代码示例来源:origin: org.eclipse.e4.ui/bindings
public int compare(Binding binding1, Binding binding2) {
ParameterizedCommand cmdA = binding1.getParameterizedCommand();
ParameterizedCommand cmdB = binding2.getParameterizedCommand();
int result = 0;
try {
result = cmdA.getName().compareTo(cmdB.getName());
} catch (NotDefinedException e) {
// whaaa?
}
return result;
}
});
代码示例来源:origin: org.eclipse.e4.ui/bindings
public int compare(Binding a, Binding b) {
Binding bindingA = a;
Binding bindingB = b;
ParameterizedCommand commandA = bindingA.getParameterizedCommand();
ParameterizedCommand commandB = bindingB.getParameterizedCommand();
try {
return commandA.getName().compareTo(commandB.getName());
} catch (NotDefinedException e) {
// should not happen
return 0;
}
}
});
代码示例来源: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.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 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.e4.ui/bindings
/**
* Determines whether the key sequence is a perfect match for any command. If there is a match,
* then the corresponding command identifier is returned.
*
* @param keySequence
* The key sequence to check for a match; must never be <code>null</code>.
* @return The perfectly matching command; <code>null</code> if no command matches.
*/
private ParameterizedCommand getPerfectMatch(KeySequence keySequence) {
Binding perfectMatch = getBindingService().getPerfectMatch(keySequence);
return perfectMatch == null ? null : perfectMatch.getParameterizedCommand();
}
代码示例来源:origin: org.eclipse.e4.ui/bindings
/**
* Handles the default selection event on the table of possible completions. This attempts to
* execute the given command.
*/
private void executeKeyBinding(Event trigger) {
int selectionIndex = completionsTable.getSelectionIndex();
// Try to execute the corresponding command.
if (selectionIndex >= 0) {
Binding binding = bindings.get(selectionIndex);
try {
// workbenchKeyboard.updateShellKludge(null);
workbenchKeyboard.executeCommand(binding.getParameterizedCommand(), trigger);
} catch (CommandException e) {
// WorkbenchPlugin.log(binding.getParameterizedCommand().toString(), e);
// TODO we probably need to log something here.
System.err.println(binding.getParameterizedCommand().toString() + " : " + e); //$NON-NLS-1$
}
}
}
代码示例来源: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
/**
* Handles the default selection event on the table of possible completions. This attempts to
* execute the given command.
*/
private void executeKeyBinding(Event trigger) {
int selectionIndex = completionsTable.getSelectionIndex();
// Try to execute the corresponding command.
if (selectionIndex >= 0) {
close();
Binding binding = bindings.get(selectionIndex);
try {
// workbenchKeyboard.updateShellKludge(null);
workbenchKeyboard.executeCommand(binding.getParameterizedCommand(), trigger);
} catch (CommandException e) {
// WorkbenchPlugin.log(binding.getParameterizedCommand().toString(), e);
// TODO we probably need to log something here.
System.err.println(binding.getParameterizedCommand().toString() + " : " + e); //$NON-NLS-1$
}
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.bindings
/**
* @param keySequence
* @param context2
* @return
*/
private Collection<Binding> getExecutableMatches(KeySequence keySequence, IEclipseContext context2) {
Binding binding = getBindingService().getPerfectMatch(keySequence);
if (binding != null) {
return Collections.singleton(binding);
}
Collection<Binding> conflicts = getBindingService().getConflictsFor(keySequence);
if (conflicts != null) {
return conflicts.stream()
.filter(match -> getHandlerService().canExecute(match.getParameterizedCommand(), context2))
.collect(Collectors.toSet());
}
return Collections.emptySet();
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
public String getPerfectMatch(KeySequence keySequence) {
try {
final org.eclipse.jface.bindings.keys.KeySequence sequence = org.eclipse.jface.bindings.keys.KeySequence
.getInstance(keySequence.toString());
final Binding binding = bindingManager.getPerfectMatch(sequence);
if (binding == null) {
return null;
}
return binding.getParameterizedCommand().getId();
} catch (final ParseException e) {
return null;
}
}
代码示例来源: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
/**
* Makes a copy of the
*
* @param element
*/
public void copy(BindingElement element) {
if (element == null || !(element.getModelObject() instanceof Binding)) {
return;
}
BindingElement be = new BindingElement(controller);
ParameterizedCommand parameterizedCommand = ((Binding) element
.getModelObject()).getParameterizedCommand();
be.init(parameterizedCommand);
be.setParent(this);
bindingElements.add(be);
commandToElement.put(parameterizedCommand, be);
controller.firePropertyChange(this, PROP_BINDING_ADD, null, be);
setSelectedElement(be);
}
代码示例来源: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
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.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;
}
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!