Eclipse Editor插件键绑定未显示在菜单中用于命令 [英] Eclipse Editor plug-in key binding not shown in menu for command

查看:309
本文介绍了Eclipse Editor插件键绑定未显示在菜单中用于命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个键绑定,在我的自定义Eclipse编辑器插件中触发一个命令:

 < key 
commandId =my.plugin.ui.MyCommand
contextId =my.plugin.ui.mycontext
schemeId =org.eclipse.ui.defaultAcceleratorConfiguration
sequence = M1 + M2 + O>
< / key>

我正在使用一个新定义的上下文 mycontext 以便能够覆盖已经存在的用于组织导入的密钥绑定。 mycontext org.eclipse.ui.contexts.window 的子上下文



为此命令创建菜单条目时,键盘快捷方式不会显示在标签旁边,因为绑定的上下文不是 org.eclipse.ui.contexts.window 但它的孩子。



当右键单击 .java

时,所需的演示文稿将类似于默认绑定。 code>文件:



整理导入 __ _ __ _ __ _ ___ Ctrl + Shift + O



<有没有办法显示自定义上下文的绑定?

解决方案

您是否尝试激活视图的创建零件控件中的上下文方法。

  PlatformUI.getWorkbench()。getDisplay()。asyncExec(new Runnable(){
@Override
public void run(){
PlatformUI.getWorkbench()。getServic E(IContextService.class).activateContext( custom.context.id);
}
});


I have a key binding that triggers a command in my custom Eclipse editor plug-in:

  <key
        commandId="my.plugin.ui.MyCommand"
        contextId="my.plugin.ui.mycontext"
        schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
        sequence="M1+M2+O">
  </key>

I am using a newly defined context mycontext to be able to overwrite the already existing key binding for organizing imports. mycontext is a child context of org.eclipse.ui.contexts.window.

When creating a menu entry for this command, the keyboard shortcut is not shown next to the label because the context for the binding is not org.eclipse.ui.contexts.window but its child.

The desired presentation would look like that of the default binding when right-clicking .java files:

Organize Imports ____________ Ctrl+Shift+O

Is there a way to show the bindings for custom contexts?

解决方案

Did you try to activate the context in the view's create part control method.

PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
        @Override
        public void run() {
             PlatformUI.getWorkbench().getService(IContextService.class).activateContext("custom.context.id");
        }
    });

这篇关于Eclipse Editor插件键绑定未显示在菜单中用于命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆