Bug 149890 [Contributions] MenuManager does not properly handle dynamic submenus
3.2 RC5 I tried adding a dynamic MenuManager as a submenu of the parent MenuManager. By dynamic, I mean that I used subMenu.setRemoveAllWhenShown(true), and a menu listener on the submenu to populate it when shown. When the context menu was shown, it had no entry for the submenu. This is because MenuManager.isVisible() returns false if the menu has generated no concrete menu items (after update). If isVisible is fixed to return true if removeAllWhenShown is true, then a secondary problem occurs: the label for the submenu appears disabled, until clicked on to show the submenu. Suggested fix: In MenuManager.isVisible(), add the following before checking the items: if (removeAllWhenShown) return true; In MenuManager.updateMenuItem(), change: boolean enabled = menu.getItemCount() > 0; to: boolean enabled = removeAllWhenShown || menu.getItemCount() > 0;
bundles/org.eclipse.jface/src/org/eclipse/jface/action/MenuManager.java
}
    }
	/**
	 * Dispose any images allocated for this menu
	 */
	private void disposeOldImages() {
		if (imageManager != null) {
			imageManager.dispose();
			imageManager = null;
		}
	}
    /* (non-Javadoc)
     * @see org.eclipse.jface.action.IMenuManager#updateAll(boolean)
     */
    public void updateAll(boolean force) {
        update(force, true);
    }
    /**
     * Updates the menu item for this sub menu.
     * The menu item is disabled if this sub menu is empty.
     * Does nothing if this menu is not a submenu.
     */
    private void updateMenuItem() {
        /*
         * Commented out until proper solution to enablement of
         * menu item for a sub-menu is found. See bug 30833 for
         * more details.
         *  
         if (menuItem != null && !menuItem.isDisposed() && menuExist()) {
         IContributionItem items[] = getItems();