本文整理汇总了Java中org.eclipse.ui.keys.IBindingService.getBestActiveBindingFor方法的典型用法代码示例。如果您正苦于以下问题:Java IBindingService.getBestActiveBindingFor方法的具体用法?Java IBindingService.getBestActiveBindingFor怎么用?Java IBindingService.getBestActiveBindingFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.keys.IBindingService
的用法示例。
在下文中一共展示了IBindingService.getBestActiveBindingFor方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHotKey
import org.eclipse.ui.keys.IBindingService; //导入方法依赖的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: QuickOutline
import org.eclipse.ui.keys.IBindingService; //导入方法依赖的package包/类
public QuickOutline(Shell parent, JsonEditor editor, String fileContentType) {
super(parent, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, true, true, true, true, true, null, null);
this.fileContentType = fileContentType;
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
this.bindingKey = bindingService.getBestActiveBindingFormattedFor(COMMAND_ID);
this.triggerSequence = bindingService.getBestActiveBindingFor(COMMAND_ID);
this.editor = editor;
setInfoText(statusMessage());
create();
}
示例3: getIterationBinding
import org.eclipse.ui.keys.IBindingService; //导入方法依赖的package包/类
private KeySequence getIterationBinding() {
final IBindingService bindingSvc= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
TriggerSequence binding= bindingSvc.getBestActiveBindingFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
if (binding instanceof KeySequence)
return (KeySequence) binding;
return null;
}
示例4: saveMacro
import org.eclipse.ui.keys.IBindingService; //导入方法依赖的package包/类
private void saveMacro(ITextEditor editor,String name, File file) {
IBindingService service = (IBindingService) editor.getSite().getService(IBindingService.class);
KbdMacro kbdMacro = KbdMacroSupport.getInstance().getKbdMacro(name);
TriggerSequence sequence = service.getBestActiveBindingFor(EmacsPlusUtils.kbdMacroId(name));
if (sequence != null && sequence instanceof KeySequence) {
kbdMacro.setBindingKeys(((KeySequence)sequence).toString());
}
writeMacro(editor,file,kbdMacro);
kbdMacro.setBindingKeys(null);
}
示例5: execute
import org.eclipse.ui.keys.IBindingService; //导入方法依赖的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;
}
示例6: getBestBinding
import org.eclipse.ui.keys.IBindingService; //导入方法依赖的package包/类
/**
* Get the best binding (as determined by Eclipse) for the Command
*
* @param cmd
* @return the binding or null
*/
public static String getBestBinding(Command cmd) {
String result = null;
IBindingService binder = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
TriggerSequence bindingFor = binder.getBestActiveBindingFor(cmd.getId());
if (bindingFor != null) {
result = bindingFor.format();
}
return result;
}
示例7: getCommandKeyBinding
import org.eclipse.ui.keys.IBindingService; //导入方法依赖的package包/类
/**
* @param commandId the command we want to know about
* @return the 'best' key sequence that will activate the given command
*/
public static KeySequence getCommandKeyBinding(String commandId) {
Assert.isNotNull(commandId);
IBindingService bindingSvc;
try {
bindingSvc = PlatformUI.getWorkbench()
.getAdapter(IBindingService.class);
} catch (IllegalStateException e) {
return null;
}
TriggerSequence keyBinding = bindingSvc.getBestActiveBindingFor(commandId);
if (keyBinding instanceof KeySequence) {
return (KeySequence) keyBinding;
}
List<Tuple<Binding, ParameterizedCommand>> matches = new ArrayList<Tuple<Binding, ParameterizedCommand>>();
//Ok, it may be that the binding we're looking for is not active, so, let's give a spin on all
//the bindings
Binding[] bindings = bindingSvc.getBindings();
for (Binding binding : bindings) {
ParameterizedCommand command = binding.getParameterizedCommand();
if (command != null) {
if (commandId.equals(command.getId())) {
matches.add(new Tuple<Binding, ParameterizedCommand>(binding, command));
}
}
}
for (Tuple<Binding, ParameterizedCommand> tuple : matches) {
if (tuple.o1.getTriggerSequence() instanceof KeySequence) {
KeySequence keySequence = (KeySequence) tuple.o1.getTriggerSequence();
return keySequence;
}
}
return null;
}
示例8: getGroupingIterationBinding
import org.eclipse.ui.keys.IBindingService; //导入方法依赖的package包/类
protected KeySequence getGroupingIterationBinding() {
IBindingService bindingSvc = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
TriggerSequence binding = bindingSvc.getBestActiveBindingFor(
ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
if(binding instanceof KeySequence)
return (KeySequence) binding;
return null;
}
示例9: getKeyStrokeForCommand
import org.eclipse.ui.keys.IBindingService; //导入方法依赖的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;
}