Bug 54779 [RCP] Problem updating menus, menu not appearing
I'm using 3.0 M7. I have an application, implementing workbench advisor, that creates a placeholder Help menu in the top level menu. Since the Help menu has no items other than separators and group items a swt menu is not created. Later on an item, Help Contents, is contributed to the Help menu. When getMenuBarManager().updateAll(false); is called from updateActionBars() in WorkbenchWindow the help menu will not be updated for two reasons: 1) The top level menu is not dirty, so it can't fill the help menu can create the swt menu. 2) The swt menu for the Help menu does not exist, so the swt menu can not be created. I have an sample application to demonstrate the problem as well as a fix to MenuManager.java in jface to solve the problem. The fix is to override markDirty()in MenuManager.java with the following code. /* (non-Javadoc) * @see org.eclipse.jface.action.IContributionManager#markDirty() */ public void markDirty() { super.markDirty(); // if we do not have a menu yet, then we need to mark our parent as dirty so our parent will // have the chance to create our menu when it gets updated. if (!menuExist()) { IContributionManager parent = getParent(); if (parent != null && !parent.isDirty()) { parent.markDirty(); } } }
bundles/org.eclipse.jface/src/org/eclipse/jface/action/MenuManager.java
}
        return null;
    }
    /**
     * Notifies any menu listeners that a menu is about to show.
     * Only listeners registered at the time this method is called are notified.
     *
     * @param manager the menu manager
     *
     * @see IMenuListener#menuAboutToShow
     */
    private void fireAboutToShow(IMenuManager manager) {
        Object[] listeners = this.listeners.getListeners();
        for (int i = 0; i < listeners.length; ++i) {
            ((IMenuListener) listeners[i]).menuAboutToShow(manager);
        }
    }
    /**
     * Returns the menu id.
     * The menu id is used when creating a contribution item 
     * for adding this menu as a sub menu of another.
     *
     * @return the menu id
     */
    public String getId() {
        return id;
    }
    /**
     * Returns the SWT menu control for this menu manager.
     *