[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.platform] Re: Tying MenuItems to IContributionItem
|
- From: Scott Morrison <captainqwark@xxxxxxxxx>
- Date: Fri, 17 Mar 2006 10:22:08 -0500
- Newsgroups: eclipse.platform
- Organization: EclipseCorner
- User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)
I can get the object stored in menuItem.getData() and often times it's
the contribution item but there's no consistency in what's put in there.
For some menu items there's internal classes like
ActionSetContributionItem which probably shouldn't be used in a plugin.
There's also the problem where the Edit menu has ContributionItem
objects stored in .getData() but getting those objects and doing
.setVisible(false) fails to render them invisible however if I do the
following:
Menu menuBar = window.getShell().getMenuBar();
Menu targetMenu = menuItems[i].getMenu();
Object o = menuItems[i].getData();
MenuManager targetManager = (MenuManager)o;
MenuItem[] targetMenuItems = targetMenu.getItems();
IContributionItem[] targetContributionItems = targetManager.getItems();
I can loop through all the IContributionItem arrays for each menu and
set every MenuItem in every menu invisible but what I need to know is
how to identify the IContrubtionItem array elements with their
corresponding MenuItems.
I tried looping through the MenuItems and doing
MenuManager.fill(targetMenu, i) but it still isn't consistent in what
objects it puts in .data();
Thanks for your help :)
Scott
Paul News wrote:
Check out ActionContributionItem#fill() methods ... it attaches the
contribution item to the menu item ... you should be able to go
menuItem.getData() to get back the contribution item.
Later,
PW