Bug 34969

Summary: [Contributions] Menu manager is enabled even when empty.
Product: [Eclipse Project] Platform Reporter: Dave Steinberg <davidms>
Component: UIAssignee: Simon Arsenault <simon_arsenault>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: csalter, turnham
Version: 2.1   
Target Milestone: 2.1.1   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Bug Depends on: 30833    
Bug Blocks:    
Attachments:
Description Flags
Empty menu behaviour in 2.0
none
Empty menu behaviour in 2.1 none

Description Dave Steinberg CLA 2003-03-13 16:28:03 EST
I use an org.eclipse.jface.action.MenuManager for a sub-menu in the
context-sensitive menu.  Items are added to that sub-menu according to the
current selection, and in some cases, there may be no items added.

In the 2.0 series, the sub-menu item would be disabled if it contained no items.
 On 2.1 RC1 and RC2, it draws the sub-menu item as if it's enabled but, of
course, pops up no sub-menu when selected.

The new behaviour is very confusing.

Note: this is not a repeat of bug 30423, which deals with sub-menus that contain
only disabled items; this refers to sub-menus with no items at all.
Comment 1 Dave Steinberg CLA 2003-03-13 16:37:27 EST
Created attachment 4123 [details]
Empty menu behaviour in 2.0

Under Eclipse 2.0, "New Sibling", which contains no items, is disabled.
Comment 2 Dave Steinberg CLA 2003-03-13 16:39:08 EST
Created attachment 4124 [details]
Empty menu behaviour in 2.1

Under Eclipse 2.1, "New Sibling" is enabled.  Because it has no items in it, no
sub-menu pops up.
Comment 3 Nick Edgar CLA 2003-03-15 15:48:41 EST
Simon, please check that this is in fact a regression.
Comment 4 Simon Arsenault CLA 2003-03-17 11:11:52 EST
It's not an "unknown" regression... The code to disable the menu item of a sub-
menu has been removed for 2.1 because it caused more problems than it solved. 
For example, when the sub-menu needs to be populated on menuAboutToShow event, 
if the menu item is disabled, the sub-menu will never be given the chance to 
populate again.

See bug 30833 for a list of bugs related to this problem. See also bug 27019 
which is a very much the same as this one.
Comment 5 Dave Steinberg CLA 2003-03-17 13:19:27 EST
Is there any work-around you could suggest, other than ensuring that all
sub-menus always contain at least one item?

For example, is there any way that I could explicitly disable the menu myself?

As it stands, all EMF.Edit-generated editors are "broken" in this respect.
Comment 6 Simon Arsenault CLA 2003-03-17 14:31:39 EST
I can't think of any workaround at the moment. Unfortunately, with 2.1 release 
date just days away, I do not have sufficient time to look more into this.
Comment 7 Craig Salter CLA 2003-04-21 16:10:10 EDT
Can someone clarify?  Is this a problem that will be fixed in eclipse, or is 
this an intentional behaviour change that we need to react to?
Comment 8 Simon Arsenault CLA 2003-04-22 09:22:23 EDT
It is a known problem.
Comment 9 Jeff Turnham CLA 2003-04-23 15:15:14 EDT
I think Craig's question is if this well be fixed in 2.1.1.  We are working on 
a product that will be based on 2.1.1 and nearing our code shutdown, so we need 
to know if Craig should workaround this problem or expect a fix.
Comment 10 Simon Arsenault CLA 2003-04-24 07:26:02 EDT
No plans to fix this for 2.1.1  If that changes, you will see the target 
milestone field change to reflect this.
Comment 11 Nick Edgar CLA 2003-04-29 10:38:49 EDT
Please investigate a fix or workaround for 2.1.1.

If the context menu is repopulated entirely each time it is popped up, then the 
problem mentioned in comment #4 does not matter.  It would be a problem if 
there was a dynamically populated submenu in a non-dynamic context menu.
For context menus, I'm comfortable with imposing a limitation whereby if there 
is a dynamically populated submenu, then the context menu must be dynamic as 
well.  However, this also has to work with main menus.
Comment 12 Simon Arsenault CLA 2003-05-07 16:27:41 EDT
A potential fix for this problem has been released in the 2.1.1 stream and will 
be part of the next 2.1.1 build (next week I'm told). I've also updated the 
HEAD stream with the same changes.