Bug 37232 - [Contributions] updating: Can't disable menu using MenuManager
Summary: [Contributions] updating: Can't disable menu using MenuManager
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P5 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks: 152326
  Show dependency tree
 
Reported: 2003-05-05 13:04 EDT by Tim deBoer CLA
Modified: 2019-11-08 04:40 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim deBoer CLA 2003-05-05 13:04:37 EDT
Subclasses of MenuManager will never be disabled, and will show up in the UI as 
enabled even if they have no children and are permanently disabled. The 
following testcase shows this behaviour:

public class DisabledMenuManager extends MenuManager {
  public DisabledMenuManager(String label) {
    super(label);
  }
  public boolean isEnabled() {
    return false;
  }
}
Comment 1 Michael Van Meekeren CLA 2006-04-21 13:56:40 EDT
Moving Dougs bugs
Comment 2 Angel Vera CLA 2006-08-22 14:08:04 EDT
Any status on this defect? 
Comment 3 Andriy Rysin CLA 2006-11-01 16:44:41 EST
In jface code this could be fixed as easy as changing the line
            boolean enabled = menu.getItemCount() > 0;
to 
            boolean enabled = menu.getItemCount() > 0 && isEnabled();

in MenuManager.updateMenuItem()

but there's no way to do anything about it from the client code except to rewrite the whole MenuManger class because menuItem member is not exposed.

Having this fixed, it would be nice to have another method setEnabled() to be able to change state of MenuManager without subclassing it.
Comment 4 Paul Webster CLA 2007-04-05 19:02:28 EDT
Assigning to component owner
PW
Comment 5 Remy Suen CLA 2007-09-15 18:43:27 EDT
I don't think isEnabled() can be changed as it's spec'ed by the API to return true. I do agree that this is annoying though because if your workspace is configured to build automatically and you access the 'Build Working Set' menu item in the 'Project' menu, you will see that there are only disabled choices. It would certainly be nice to be able to turn off these submenus.
Comment 6 Henno Vermeulen CLA 2011-03-21 05:22:38 EDT
Could you at least PLEASE adjust the javadoc of MenuManager.isEnabled to explain this issue? From the Javadoc I concluded that I could make a DisableableMenuManager and overwrite isEnabled().
I subsequently spent about three hours of trying everything to disable the item that is shown for a submenu menumanager. I also did some google searches to no avail before being so "clever" to search bugzilla and then fortunately immediately found this issue :S.
Comment 7 Paul Webster CLA 2011-03-21 08:48:41 EDT
Please write up the appropriate explanation and I'll make sure it gets in 3.7M7

PW
Comment 8 Henno Vermeulen CLA 2011-03-22 06:39:59 EDT
The version I have (build id 20090920-1017) is this:
    /**
     * Returns whether this menu should be enabled or not.
     * Used to enable the menu item containing this menu when it is realized as a sub-menu.
     * <p>
     * The default implementation of this framework method
     * returns <code>true</code>. Subclasses may reimplement.
     * </p>
     *
     * @return <code>true</code> if enabled, and
     *   <code>false</code> if disabled
     */

I came here as a black-box user of MenuManager and the Javadoc clearly states that I can enable/disable the submenu item by overriding the isEnabled() method (which is why at first I searched for the bug was elsewhere).

I am not an Eclipse developer so I'm not sure why "it's spec'ed by the API" that it should always return true and forgive if my attempt at the Javadoc is not really correct, but what about this:

/**
 * Returns whether this menu should be enabled or not. When this menu is
 * realized as a sub-menu this method is used to enable adding the menu
 * item containing this menu to it's parent menu.
 * <p>
 * This is the <code>MenuManager</code> implementation of the framework
 * method defined in {@link IContributionItem} and always returns
 * <code>true</code>. It is not intended to be overridden by subclasses.
 * </p>
 * <p>
 * Unlike the name suggests, this method will not be used for
 * enabling/disabling the menu item itself (as in
 * {@link MenuItem#setEnabled(boolean)}). This behavior is not
 * implemented by <code>MenuManager</code>.
 * </p>
 * 
 * @return always <code>true</code>
 */
Comment 9 Lars Vogel CLA 2019-11-08 04:40:45 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant please remove the stalebug whiteboard tag.