Eclipse 3.5 – Plug-in Spy and menus
All plug-in developpers know about the beloved plug-in spy (Alt+Shift+F1). This great feature allows to inspect various part of the workbench (Editors, Views, Wizards, Dialogs,…) but menus were not include in this list… Until Galileo!!
First we will see how it works and how it looks, then I will briefly make a demo of how it is useful for a cool use case 🙂
I finally make some comment on this feature.
The Plug-in Spy for menu
Press Alt+Shift+F2, then click on the menu item that you want to inspect.
It will display this kind of pop-up :

We can see such information as:
- The active contribution item identifier : We know the id of the item, can call it now 🙂
- The active contribution location URI : With this path you can easily provide your own menu item in the same group.
- The active action definition identifier : Useful to reuse this action.
- The active contribution item class : The responsible class of this Action. A good start point to see what this menu item triggers.
- The contributing plug-in : To see which plug-in provides this menu item
A quick demo
A demo use case : “I want to add a great menu item which will trigger the display of great information about me!!”
So, I see that a menu item exists to do such kind of thing : “About Eclipse SDK”

And as you guess I will use the Plug-in Spy to grab needed information!

Now I create a new plug-in project and create an extension to the point : org.eclipse.ui.menus and fill the locationURI with the one given by the plug-in spy. To get the locationURI, select the text and right-click on it 😉

Now create a command and attach it to the menu contribution :

Set a handler to this command and do what you want in execute method of the class implementing the handler (Open a MessageDialog and display a great text for instance):

Test your plugin :


All works fine and very quickly!!
Comments
You have to adopt a different point of view with this new feature of the plug-in spy :
- Make active what you want to inspect then press Alt+SHift+F1 to trigger the plug-in spy
- Make active the plug-in spy Alt+Shift+F2, then navigate through menu and click on the menu item to inspect
Why? think of mnemonics 😉
sources :
eclipse new and noteworthy (seems to work only in google cache)
and 2 Chris blogpost : here and here
Leave a Reply Cancel reply
About Me
Welcome on my blog.
As I'm an Eclipse addict, I will mainly post about Eclipse. Don't hesitate to let a comment about what you think of my blogposts.

Categories
- e4 (1)
- Eclipse (5)
- GMF (1)
- Mountain (1)
- Uncategorized (1)
Recent Comments
| Jeroen on Eclipse 3.5 – Plug-in Sp… | |
| Innovate Day 5… on Eclipse 3.5 – Plug-in Sp… | |
| hiergiltdiestfu on Eclipse 3.5 – Plug-in Sp… | |
| vincent on Eclipse 3.5 – Plug-in Sp… | |
| Sang on Eclipse 3.5 – Plug-in Sp… |
Great post 🙂
Nice article indeed!
This was really helpful
When I launch an eclipse application from eclipse, the spy only work on the eclipse DEV window but not on my application which is running. Anyway to make spy to work on my eclipse application instead?
Thanks
Make sure to start org.eclipse.pde.runtime plugin to use it in your application.
Very helpful, thank you!