0
votes

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
The key binding will only be shown (and will only be used) when your context is actually active.greg-449
Yes, this was the case. Thank you for the suggestion!Zemunk

1 Answers

0
votes

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