Eclipse Editor plug-in key binding not shown in menu for command

假装没事ソ 提交于 2019-12-11 08:20:08

问题


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?


回答1:


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");
        }
    });


来源:https://stackoverflow.com/questions/22220782/eclipse-editor-plug-in-key-binding-not-shown-in-menu-for-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!