I started this post to help me and hopefully you understand what is involved in using
org.eclipse.ui.menus. I'm assuming you have a good understanding of Eclipse RCP and you would use this as a reference guide. It stems from my fustration in using the Eclipse wiki and finding help with the new features of Eclipse Europa.
The Eclipse Europa (3.3) release has changed the
org.eclipse.ui.menus extension to improve menu, toolbar, and popup placement and visibility. The idea is to move away from the old extensions.
Where to start
I've listed the extensions with links to appropriate Eclipse help page and wiki page.
Scared yet? It is well worth the effort to learn and thus avoid, as much as possible, the legacy action extensions listed above.
What do you get? A very flexible and powerful way of creating menus, toolbars, and popup menus. I found the legacy action extensions to be difficult to implement complex menu and toolbar interactions and I ended up writing less java code.
- A logical representation of a task. A handler does the work. See wiki and help guide.
- A handler does what the command represents. See wiki and help guide.
- Bind a command to a key. See wiki and help guide.
- Bindings can be organized into a context. See wiki.
- Give a command an image.
- See RCP Text Editor Example.
- See Creating an Eclipse View.
- Add custom additions to the main menu, main toolbars, and view/editor context menus, toolbars, popup menu, and trim. See wiki and help guide.
Important to understand
Command Core Expressions needs to be understood to make your commands visible and handlers enabled.
Read up on Basic workbench extension points using commands.
How the old maps to the new.
Example code can be found in org.eclipse.ui.examples.contributions.
Keep notes of the commands you are creating and how they can be reused.
- Create or reuse a
- Create a command category.
- Create a command.
- Create a command image (optional).
- Create a binding schema.
- Create a binding for a command.
- Create a handler.
- Create a menu contribution.
Debugging and tracing
Check out this wiki page for details on a few debugging strategies.
- Commands added to a view toolbar must have either a label or icon defined in the menuContribution or icons defined in the org.eclipse.ui.commandImages.
- Forget to look at org.eclipse.ui.menus.MenuUtil for correct spelling of menu constants.