Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 26593

Summary: [Contributions] (dynamic) Support for showing and hiding dynamic menus
Product: [Eclipse Project] Platform Reporter: Dan Rubel <danrubel>
Component: UIAssignee: Paul Webster <pwebster>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: clayberg, pickens, tim_koss
Version: 2.1Keywords: api
Target Milestone: 3.3   
Hardware: Other   
OS: Windows XP   
Whiteboard:
Bug Depends on: 29709    
Bug Blocks: 97356    

Description Dan Rubel CLA 2002-11-18 11:07:44 EST
Our product provides a scheduling service for the user. One of the options 
allows the user to make one or more of the scheduled tasks available as part of 
a top level menu so that those scheduled actions selected by the user are easily 
accessible.  To make this happen, we need access to the workbench window's 
menubar manager to dynamically add or remove the task menu and its contents as 
directed by the user.  The WorkbenchWindow class already provides the 
getMenuBarManager() method, so the simple solution is to promote this method 
into the IWorkbenchWindow public API.
Comment 1 Nick Edgar CLA 2003-09-29 22:47:13 EDT
I have changed the title to more accurately describe the needed enhancement.

I have the following concern with the proposed patch.  On the surface, this 
seems like an innocent request.  However, giving arbitrary plug-ins access to 
the real menubar is not a good idea.  Currently editors and views are given a 
virtual menubar, which allows the workbench to manage placement and visibility 
of menu items appropriately based on part activation.  Likewise for action 
sets and how they are managed (globally on, or associated with perspective or 
part).  Giving arbitrary access to the real menubar would preempt the ability 
of the workbench to manage actions consistently, and could lead to an 
unpredictable UI.  For example, regular plug-ins would not only be able to add 
menus and menu items independently of a particular perspective or part, but 
would also be able to remove and modify actions from other plug-ins.

Have you tried using the existing API for dynamic menus and/or drop-down 
toolbar items (a la Run and Debug actions)?  See 
IWorkbenchWindowPulldownDelegate and the pulldown=true attribute on action 
elements in the actionSets extension point.  The current mechanism has the 
limitation of only being able to add dynamic submenus or dynamic tool items, 
not dynamic top-level menus, and there is currently no way of programmatically 
showing and hiding action sets (see bug 39455 for my concerns with adding the 
latter).  However, we may be able to extend the existing mechanism to meet 
your needs.

From your description above, it sounds like you need:
1. The ability to define a new top-level menu.  
2. The ability to dynamically add or remove items from the menu.
3. The ability to programmatically hide or show the top-level menu in response 
to a user request.

Questions:
- Does the menu appear globally, or is at associated with particular 
perspectives?
- If the user turns it off, is it removed from all windows and all 
perspectives, or just the current window and perspective?
- What is the UI for turning the menu on and off?  Is it a user preference or 
some other mechanism?
Comment 2 David Pickens CLA 2004-10-18 12:11:02 EDT
I also need to be able to generate a menu on the main menubar whose contents 
isn't known until runtime. I know that this is possible for submenus via the 
IWorkbenchWindowPulldownDelegate2 interface, but couldn't you extend this 
mechanism for top-level menus?

Comment 3 Nick Edgar CLA 2006-03-15 13:34:21 EST
Reassigning bugs in component areas that are changing ownership.
Comment 4 Michael Van Meekeren CLA 2006-04-21 13:56:11 EDT
Moving Dougs bugs
Comment 5 Paul Webster CLA 2007-04-05 19:01:54 EDT
Assigning to component owner
PW
Comment 6 Paul Webster CLA 2007-06-20 12:35:55 EDT
This has been fixed and/or superceded by the menu contribution work - bug 154130
PW