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
this(null, null, null);
    }
    /**
     * Creates a menu manager with the given text. The id of the menu
     * is <code>null</code>.
     * Typically used for creating a sub-menu, where it doesn't need to be referred to by id.
     *
     * @param text the text for the menu, or <code>null</code> if none
     */
    public MenuManager(String text) {
        this(text, null, null);
    }
    /**
     * Creates a menu manager with the given text and id.
     * Typically used for creating a sub-menu, where it needs to be referred to by id.
     *
     * @param text the text for the menu, or <code>null</code> if none
     * @param id the menu id, or <code>null</code> if it is to have no id
     */
    public MenuManager(String text, String id) {
        this(text, null, id);
    }
    /**
     * Creates a menu manager with the given text, image, and id.
     * Typically used for creating a sub-menu, where it needs to be referred to by id.
     * 
     * @param text the text for the menu, or <code>null</code> if none
     * @param image the image for the menu, or <code>null</code> if none
     * @param id the menu id, or <code>null</code> if it is to have no id
     * @since 3.4