Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Dynamically create eclipse main menu item or global toolbar item(Dynamically create eclipse main menu item or global toolbar item)
Dynamically create eclipse main menu item or global toolbar item [message #771659] Tue, 27 December 2011 21:21 Go to next message
Hao Missing name is currently offline Hao Missing name
Messages: 115
Registered: July 2009
Senior Member
Appreciate if I can get some helps on the following issue:

I need to create menu items on eclipse main menu bar and toolbar items on eclipse global toolbar when a viewPart instance is created and to remove those menu items when the viewPart instance is disposed.

I tried the following eclipse APIs but could not make them to work:
org.eclipse.ui.menus.IMenuService
org.eclipse.ui.menus.AbstractContributionFactory
org.eclipse.jface.action.ToolBarContributionItem
org.eclipse.jface.action.MenuManager
org.eclipse.jface.action.ToolBarManager

The first issue I am facing is how to define the location where my menu item or toolbar item will be contributed.
Re: Dynamically create eclipse main menu item or global toolbar item [message #774723 is a reply to message #771659] Wed, 04 January 2012 13:31 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Use the org.eclipse.ui.menus extension point to add your commands to the main toolbar or main menu. Use a visibleWhen clause to make them visible when your view is active, or a visibleWhen + a property tester to have them visible when your view is open.

See:

http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/workbench.htm

PW


Previous Topic:Enable handler based on active page in multi-page editor
Next Topic:Enable "Always run in background" for Jobs as Default
Goto Forum:
  


Current Time: Fri Sep 19 23:56:00 GMT 2014

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

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