本文整理汇总了Java中org.eclipse.jface.bindings.TriggerSequence.getTriggers方法的典型用法代码示例。如果您正苦于以下问题:Java TriggerSequence.getTriggers方法的具体用法?Java TriggerSequence.getTriggers怎么用?Java TriggerSequence.getTriggers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.bindings.TriggerSequence
的用法示例。
在下文中一共展示了TriggerSequence.getTriggers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHotKey
import org.eclipse.jface.bindings.TriggerSequence; //导入方法依赖的package包/类
public static KeyStroke getHotKey(String commondID) throws ParseException {
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
if (bindingService != null) {
TriggerSequence trigger = bindingService.getBestActiveBindingFor(commondID);
if (trigger != null) {
Trigger[] tiggers = trigger.getTriggers();
if (tiggers.length > 0) {
Trigger tigger = tiggers[0];
if (tigger instanceof KeyStroke) {
return (KeyStroke) tigger;
}
}
}
}
return KeyStroke.getInstance("Ctrl+Space");
}
示例2: getAccelerator
import org.eclipse.jface.bindings.TriggerSequence; //导入方法依赖的package包/类
/**
* @see org.eclipse.jface.action.ExternalActionManager.ICallback#getAccelerator(String)
*/
public final Integer getAccelerator(final String commandId) {
final TriggerSequence triggerSequence = bindingManager
.getBestActiveBindingFor(commandId);
if (triggerSequence != null) {
final Trigger[] triggers = triggerSequence.getTriggers();
if (triggers.length == 1) {
final Trigger trigger = triggers[0];
if (trigger instanceof KeyStroke) {
final KeyStroke keyStroke = (KeyStroke) trigger;
final int accelerator = SWTKeySupport
.convertKeyStrokeToAccelerator(keyStroke);
return new Integer(accelerator);
}
}
}
return null;
}
示例3: execute
import org.eclipse.jface.bindings.TriggerSequence; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
EmacsPlusConsole console = EmacsPlusConsole.getInstance();
console.clear();
console.activate();
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
String id = (event.getCommand() != null ? event.getCommand().getId() : null);
if (id != null) {
try {
TriggerSequence trigger = bindingService.getBestActiveBindingFor(event.getCommand().getId());
Trigger[] trigs = trigger.getTriggers();
KeyStroke key = (KeyStroke)trigs[0];
Collection<Binding> partials = EmacsPlusUtils.getPartialMatches(bindingService,KeySequence.getInstance(key)).values();
for (Binding bind : partials) {
ParameterizedCommand cmd = bind.getParameterizedCommand();
if (cmd.getId().startsWith(EmacsPlusUtils.MULGASOFT)) {
console.printBold(bind.getTriggerSequence().toString());
console.print(SWT.TAB + cmd.getCommand().getName());
String desc = cmd.getCommand().getDescription();
if (desc != null) {
desc = desc.replaceAll(CR, EMPTY_STR);
console.print(" - " + desc + CR); //$NON-NLS-1$
} else {
console.print(CR);
}
}
}
} catch (Exception e) {}
console.setFocus(true);
}
return null;
}
示例4: getKeyStrokeForCommand
import org.eclipse.jface.bindings.TriggerSequence; //导入方法依赖的package包/类
/**
* Gets the KeyStroke that triggers the command with the
* given id, if any.
* @param id The id of the command.
* @return The KeyStroke that triggers the command with the
* given id.
*/
private static KeyStroke getKeyStrokeForCommand(String id) {
IBindingService bindingService = (IBindingService)PlatformUI.getWorkbench().getAdapter(IBindingService.class);
TriggerSequence seq = bindingService.getBestActiveBindingFor(id);
if (seq.getTriggers().length == 1 && seq.getTriggers()[0] instanceof KeyStroke)
return (KeyStroke)seq.getTriggers()[0];
else
return null;
}