2
votes

In Eclipse (3.x for that matter) you can use the Plug-in Spy and Menu Selection Spy to find out information about UI elements which are accessible via the mouse.

I am now facing the problem that I want to find out about the command (I need the command id) which is triggered by a certain key binding, because I want to create a menu item for this command in my custom UI (view/editor)).

In my concrete case I am looking for the Expand All children command which is triggered by Numpad+Plus in a common navigator. However, I am interested in a general way to find out about key bindings.

I know that I can access the key bindings via the preferences dialog or the key binding QuickView (CTRL+SHIFT+L in Windows); but there, I can only find out about the command name, not the ID or the contributing plug-in of the command.

2

2 Answers

4
votes

You can use the Eclipse Search / Plug-in Search to search for an extension point. In this case search for org.eclipse.ui.bindings to see the key bindings: Search dialog

The search will give to a list of plug-ins, open a list item to see the plugin.xml for the plug-in with the extension point highlighted. You will have to search through the plug-ins and entries to find what you want.

The Expand All key binding is defined in the org.eclipse.ui plug-in and has command id org.eclipse.ui.navigate.expandAll

You may need to check the Include all plug-ins from target in Java search in Preferences > Plug-in Development to get the search to look in the target platform (which needs to be Eclipse).

6
votes

I have found an alternative which suits my requirements a bit more.

This article describes how to turn on tracing of the keybinding mechanism. This will report each keypress and triggered shortcut/keybinding to the console.

In the launch configuration dialog, go to the Tracing tab and enable general tracing. Then select the plug-in org.eclipse.ui and activate the options:

org.eclipse.ui/debug
org.eclipse.ui/trace/keyBindings
org.eclipse.ui/trace/keyBindings.verbose

It's not super-convenient, but it serves my purpose and does not require me to take a guess on the contributing plug-ins. (At least if the contributing plug-in is not obvious).