[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform] Re: IContributionItems Access details
|
- From: Paul Webster <pwebster@xxxxxxxxxx>
- Date: Tue, 22 Jul 2008 11:12:52 -0400
- Newsgroups: eclipse.platform
- Organization: EclipseCorner
- User-agent: Thunderbird 2.0.0.14 (X11/20080515)
Hmmm. If you can get the MenuManager or ToolBarManager for the view,
you can get a list of IContributionItems. Depending on the view, some
of them are ActionContributionItems, and aci.getAction().run() will run
them (most of the time). CommandContributionItem doesn't have getters
for most of its information, there isn't a general purpose need for them
(although I can see why swtbot could use them). As a matter of fact,
CommandContributionItem has no useful API above IContributionItem. The
only way to access information for CommandContributionItem would be to
use reflection to yank it out of the private member variables (messy at
the best of times).
The other option is to walk the SWT Menu/MenuItem hierarchy, but you
have to get it first (and I'm not sure where you are starting from, an
active IWorkbenchPart?). Once you have the menu item, executing is
straight forward (for non-dynamic menu cases):
item.notifyListeners(SWT.Selection, null);
But that won't handle the general case, only the 80% case. Is there a
specific direction you are trying to take?
Later,
PW
--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/workbench.htm