问题
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