Dr. Stefan Winkler
freier Softwareentwickler und IT-Berater

Following a reader's comment on my earlier post, I found the new API (Extension point description of org.eclipse.ui.menus) which unifies all command contributions to Eclipse menus, views, objects, toolbars etc.

With this example it requires a lot less code to add an action (well, the new API uses commands) which is visible or enabled dynamically based on an object property. However, at the same time, we have to do quite a bit more extension configurations: Instead of a single declaration of an org.eclipse.ui.popupMenus extension, we need all this:

One of the first Hello World examples when dealing with contributions to Eclipse extension points is adding an objectContribution or a viewerContribution to a popup menu. However, if one wants to add a more flexible contribution which is hided or disabled in certain circumstances, documentation gets rare. This article describes how to implement these advanced featues by example. Let's assume we have an EMF model of objects MyObject which implement a property called type. EMF can generate item and label providers for tree editors. Let's assume we have implemented such an editor and we want to contribute an action which is only visible for a particular type value.

Say, you want to implement a quick and flexible automation enhancement to one of your eclipse RCP plugins - for example, because you are writing some sort of business application in which you always have to create a few standard structures manually in order to play with it and test it. Here's how you can do it the groovy way: