Friday, February 24, 2006

What is my selection ?

Do you know that problem? There is a view in Eclipse displaying some artficats and you want to contribute a new popup menu entry for them. So you go ahead and create a new objectContribution for the org.eclipse.ui.popupMenus extension point. The only question is, what object type do I want to contribute the entry for? How do I find out what kind of objects are displayed?

One way is to go and have a look at the source code of any view that displays this object and dig a bit in their label or content provider. Doing so you need to find out where the view is implemented and so on ...

I have written a tiny tool that should make things easier here and shows the type of the object selected. You simply right click an object in a view and select "Show selection".

A small message box will pop-up presenting some information about the object you selected.

Typically in your extension you would want to specify one of the interfaces for the object type to contribute a menu entry for.

To many people have asked me to tell them what type of object they are seeing because they want to contribute an action or menu. I was just sick of searching everytime :) You can download the plugin including sources here.


Blogger Alejandro L√≥pez Ruiz said...


3:24 PM

Blogger Sam Mesh said...

What about multiple selection?

7:27 PM

Blogger Eugene Kuleshov said...

Really handy. Couple suggestions though: put menu under pde tools and deploy an update site somewhere...

8:11 PM

Blogger Philipp said...

This comment has been removed by a blog administrator.

8:30 PM

Blogger Philipp said...

@sam I am not sure if this really makes sense here as you want to know the type of one particulary object you selected.

If there is a multiple selection I take care only for the first element of the selection.

Had you anything in mind particular?

@eugene Great ideas, will do this next. I was just trying to find out before if people think its helpfull.

8:32 PM

Blogger Sam Mesh said...

I wanted to have a clear picture about all possible selections in Eclipse. Probably, ISelection javadoc provides this clear picture. Or you foresee something to investigate?

11:22 PM

Blogger AlBlue said...

Very cool indeed. An update site would be excellent. I don't think it should live under PDE Tools; if I'm testing a run-time RCP app I may not have that menu in my RCP but it would be cool to bring this plugin in to tell me what it is.

9:21 AM

Blogger Eugene Kuleshov said...

Alex, if there are no PDE menu this plugin would create it. It is just hard to find a good place for menu because it already has a lot of stuff...

3:13 AM


Post a Comment

Links to this post:

Create a Link

<< Home