Community
Participate
Working Groups
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; } }
Moving Dougs bugs
Any status on this defect?
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.
Assigning to component owner PW
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.
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.
Please write up the appropriate explanation and I'll make sure it gets in 3.7M7 PW
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> */
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.