Bug 209872 - [spy] toolbar and menu action contributions
Summary: [spy] toolbar and menu action contributions
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows Vista
: P3 enhancement (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Chris Aniszczyk CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2007-11-14 17:07 EST by Willian Mitsuda CLA
Modified: 2009-03-26 15:08 EDT (History)
6 users (show)

See Also:


Attachments
org.eclipse.pde.runtime.patch (20.72 KB, patch)
2009-03-15 16:29 EDT, Chris Aniszczyk CLA
no flags Details | Diff
Some poking at menu IDs (2.84 KB, patch)
2009-03-26 15:08 EDT, Paul Webster CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Willian Mitsuda CLA 2007-11-14 17:07:21 EST
Chris, first I have to say I'm loving all these spy stuff ;)

When developing plugins, most times you want to see how some action was implemented, and the first problem is to discover in which plugin it is hosted. I remember taking so much time just to locate the implementing plugin.

I think this is something PDE spy could help and could be enhanced for.

Not sure if this is possible (at least in the way I imagine), but it could work this way:

- You hover mouse pointer over some action in workbench or view toolbar, press the spy shortcut, and it gets the control under mouse cursor, from which it reveals the implementing class, bundle, the toolbar contribution path, etc...
- You hover mouse pointer over some a menu option, press the spy shortcut (in this case it will have to be changed, because Alt closes the menu in Windows), and it captures the menu action under the mouse pointer, and so on...
Comment 1 Chris Aniszczyk CLA 2007-11-14 17:12:50 EST
Yes, I had code that does exactly this in the incubator in the old spy. I haven't had time to graduate and migrate some of the code because it was messy and not 100% working.

http://dev.eclipse.org/viewcvs/index.cgi/pde-incubator/spy/plugins/org.eclipse.pde.ui.spy/

Check that project out, and use that spy. When you launch the spy, you'll notice an icon in the spy's toolbar manager that looks like a menu icon. Click that, and it will do a Display.addFilter() and hook into your next selection. Once you select something like a toolbar contribution, it should come back with information about it.

Give it a whirl and any comments you have are valuable. I'm trying to find time to graduate the code in M4 or M5 but product work is hurting at the moment. Any help is appreciated.

Comment 2 Benjamin Cabé CLA 2008-02-11 16:10:04 EST
(In reply to comment #1)
> Any help is appreciated.

Hey, I volunteer ! ;)

Comment 3 Chris Aniszczyk CLA 2008-02-11 16:12:46 EST
I'm tinkering with some code that does a lot of this, I plan on dropping code in M6 if it's stable enough. There's other bugs open Ben :)
Comment 4 Benjamin Cabé CLA 2008-02-11 16:18:28 EST
Oh ok ;)
I checked out code from the incubator ; did you make some enhancements since december ?
Comment 5 Chris Aniszczyk CLA 2008-02-11 16:20:18 EST
ya, one of my workspaces has the code cleaned up to work with the code outside the incubator and did a ton of cleanup. The incubator code was ugly :)
Comment 6 Benjamin Cabé CLA 2008-02-11 16:23:42 EST
(In reply to comment #5)
> The incubator code was ugly :)

Yap, definitely! ;)))
...Well, let's find another bug ... :)

Comment 7 Chris Aniszczyk CLA 2008-03-30 18:38:30 EDT
not for 3.4, work will probably be done in PDE incubator for 3.5
Comment 8 Chris Aniszczyk CLA 2009-03-15 16:29:45 EDT
Created attachment 128852 [details]
org.eclipse.pde.runtime.patch

This is what happens when I get bored on the plane... extremely hackish first cut of how I envision things working...
Comment 9 Chris Aniszczyk CLA 2009-03-15 16:30:49 EDT
Hey Paul, let's chat about this one this week sometime. Or we can do it at EclipseCon :)
Comment 10 Chris Aniszczyk CLA 2009-03-16 15:35:42 EDT
I released a first cut of this functionality for the next i-build. This way people can start to toy with it and we can evolve it before M7 ships. There are still cases where we don't get enough information back (ie., given a command, how do I get the associated handler and all that good stuff), we can open separate bugs for this.

> 20090316
Comment 11 Chris Aniszczyk CLA 2009-03-16 15:38:58 EDT
At EclipseCon, I'll spend some quality time with Paul to polish this up a bit as he understands the action/command hierarchy hell better than I do :)
Comment 12 Paul Webster CLA 2009-03-16 15:41:13 EDT
Looking forward to it!  :-)

PW
Comment 13 Chris Aniszczyk CLA 2009-03-16 15:44:42 EDT
Oh, to toy with the functionality, alt+shift+f2... you should see a "spy cursor" come up. The next action you do should be intercepted via a clever display filter... the spy should popup with relevant information.

Paul, a question for you. Given a command, how do I get the handler? I have some code like this...

else if (item instanceof CommandContributionItem) { // TODO... this is hard...
CommandContributionItem contributionItem = (CommandContributionItem) item;
ICommandService service = (ICommandService) 
     PlatformUI.getWorkbench().getService(ICommandService.class);
Command command = service.getCommand(contributionItem.getCommand().getId());

If I attempt to get a handler, it's going to be a proxy of course. The command is also not the command that someone wrote, looks to be a proxy object itself. Any options besides reflection or hitting the registry?
Comment 14 Paul Webster CLA 2009-03-24 11:27:19 EDT
From CommandContributionItem you should be able to go:


Command cmd = cci.getCommand().getCommand();
IHandler h = cmd.getHandler();

You'll either have a programmatic handler (usually coming from a view's createPartControl(*)) or the HandlerProxy.

The HandlerProxy is an internal class, but I can provide a getConfigurationElement() on it that should return the IConfigurationElement.

As for the command itself, we throw away those IConfigurationElements in CommandPersistence, so finding a plugin that contributed a command involves searching the registry (and command can be defined programmaticly, although the platform doesn't do it)

PW
Comment 15 Paul Webster CLA 2009-03-26 15:08:00 EDT
Created attachment 130006 [details]
Some poking at menu IDs