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

Bug 33184

Summary: [Contributions] updating: Separator should return isEnabled() == false
Product: [Eclipse Project] Platform Reporter: pasdemoi
Component: UIAssignee: Robert Roth <robert.roth.off>
Status: RESOLVED FIXED QA Contact:
Severity: trivial    
Priority: P5 CC: daniel_megert, Lars.Vogel, mistria, remy.suen, robert.roth.off
Version: 2.1Keywords: helpwanted
Target Milestone: 4.7 M1   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/47013
https://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=fadddbdc53bffee0c072dc97c7a7ac2519ffac6b
Whiteboard:

Description pasdemoi CLA 2003-02-25 20:53:45 EST
The jface.action.Separator class inherits the default AbstractGroupMarker 
class's isEnabled() method, which is hardwired to return true.

This makes it impossible to use separators in submenus (or top-level menus in 
menubars) where you want disabled behavior, i.e., the submenu should be grayed 
out and not pop open when pressed.  The problem is, MenuManager.updateMenuItem 
looks to see if there are any enabled items within the menu, and if so, forces 
the menu to be enabled.  The presence of a Separator within that menu means 
there will *always* be an enabled item.

The simplest fix is to just override isEnabled() to return false instead of 
true.  An easier fix might be to just change the superclass method 
AbstractGroupMarker.isEnabled.  Clearly I can override it myself, which is why 
this bug is rated as "trivial".

There is no visible difference to the separator due to this change.

Special note:  this problem is exacerbated by peculiar SWT behavior (which 
might itself be a bug):  if you double-click on a disabled menu item in a menu 
bar, that menu item will receive an SWT.Shown event (even though the menu has 
not been shown).  This causes MenuManager.updateMenuItem to be called, which 
leads to the behavior listed in the paragraph at the top of this report.  Thus, 
you can disable a menu, but double-clicking on it causes updateMenuItem to be 
called, and then the Separator causes it to become enabled, and the status of 
your menu has changed, and it's now visible, with all other entries still 
disabled!  Wierd!

I hope this write-up is clear.
Comment 1 Nick Edgar CLA 2003-02-28 16:31:03 EST
There are no plans for the UI team to work on this defect until higher 
priority items are addressed. 
Comment 2 Michael Van Meekeren CLA 2006-04-21 13:56:42 EDT
Moving Dougs bugs
Comment 3 Paul Webster CLA 2007-04-05 19:02:05 EDT
Assigning to component owner
PW
Comment 4 Remy Suen CLA 2007-09-15 19:20:00 EDT
The AllTests test suite in org.eclipse.jface.tests.action all pass both when AbstractGroupMarker overrides isEnabled() to return false and when Separator does likewise.
Comment 5 Eclipse Genie CLA 2015-05-04 04:34:25 EDT
New Gerrit change created: https://git.eclipse.org/r/47013
Comment 6 Robert Roth CLA 2015-05-04 04:36:21 EDT
Proposed a patch as discussed and requested, with AbstractGroupMarker.isEnabled returning false.
Comment 7 Mickael Istria CLA 2016-07-04 05:55:16 EDT
Thanks Robert for this patch, and sorry it took so long for such a simple change.