Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Drop down menu below main menu programmatically
Drop down menu below main menu programmatically [message #673636] Tue, 24 May 2011 09:49 Go to next message
Dirk Hoffmann is currently offline Dirk HoffmannFriend
Messages: 163
Registered: July 2009
Senior Member
Hi,

I'd like to add my own drop down menu to the main menu bar in a
programmatic way. I know this is possible like so:
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=tools">
<menu
label="My Drop Down">
<dynamic
class="MyContributionItem"
id="MyContributionItem.id">
</dynamic>
</menu>
</menuContribution>
</extension>

MyContributionItem.fill(Menu,int) would then add MenuItems to the passed
in Menu.

Unfortunately this doesn't go far enough. I also want the label of the
menu to be specified programmatically. I also want the drop down menu
and its content to be changed upon some other events, e.g. stopping or
starting the plug-in, changing preferences.

When searching the net I always only found tips on how to
programmatically add commands to the main menu, not how to add a menu.

Thanks,
Dirk
Re: Drop down menu below main menu programmatically [message #673702 is a reply to message #673636] Tue, 24 May 2011 13:58 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Dirk Hoffmann wrote on Tue, 24 May 2011 05:49
Hi,

MyContributionItem.fill(Menu,int) would then add MenuItems to the passed
in Menu.



The system is just not that dynamic, especially the main menu bar. There are hacks in 3.x that would probably allow it to work ... until 4.x, where they would fail.

Quote:


Unfortunately this doesn't go far enough. I also want the label of the
menu to be specified programmatically. I also want the drop down menu
and its content to be changed upon some other events, e.g. stopping or
starting the plug-in, changing preferences.


If you are literally creating SWT MenuItems yourself, you are responsible for the entire subsystem that manages events and keeps them up to date. The reason you wouldn't be able to find a howto is because it's hard and no one wants to do it Smile

If you use a CompoundContributionItem, you get a chance to fill in the menu on every show ... your user can't update preferences while your other menu is open, and so updating the menu item's label and state on the next show would be adequate, no?

Also, you can fill in your menu with CommandContributionItems. If your handler updates its enabled state correctly, the menu items would go enabled/disabled while the menu was open. Also, handlers that are IElementUpdaters can update text of the menu items based on some external event through the ICommandService API.

Later,
PW


Previous Topic:Using SelectionService in Commands
Next Topic:Webstart RCP (based on eclipse 3.6.2)
Goto Forum:
  


Current Time: Thu Mar 28 14:11:01 GMT 2024

Powered by FUDForum. Page generated in 0.02335 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top