/**
  * @param menuManager
  * @param element
  * @param evalContext
  */
 public static void updateVisibility(
     MenuManager menuManager, MMenuElement element, ExpressionContext evalContext) {
   if (!(element.getVisibleWhen() instanceof MCoreExpression)) {
     return;
   }
   boolean val =
       ContributionsAnalyzer.isVisible((MCoreExpression) element.getVisibleWhen(), evalContext);
   if (val != element.isVisible()) {
     element.setVisible(val);
     menuManager.markDirty();
   }
 }
  /**
   * Disposes of this menu manager and frees all allocated SWT resources. Notifies all contribution
   * items of the dispose. Note that this method does not clean up references between this menu
   * manager and its associated contribution items. Use <code>removeAll</code> for that purpose.
   */
  public void dispose() {
    if (menuExist()) {
      menu.dispose();
    }
    menu = null;

    if (menuItem != null) {
      menuItem.dispose();
      menuItem = null;
    }

    disposeOldImages();

    IContributionItem[] items = getItems();
    for (int i = 0; i < items.length; i++) {
      items[i].dispose();
    }

    markDirty();
  }