@Override
 public void dispose() {
   endCharCaret.dispose();
   cutItem.dispose();
   copyItem.dispose();
   pasteItem.dispose();
   selectAllItem.dispose();
   contextMenu.dispose();
 }
  /** Populate the dynamic menu */
  protected void fillMenu(Menu parent, List<Concern> concerns) {
    assert parent != null;
    assert !parent.isDisposed();

    //	if (!selectedJavaElements.isEmpty())
    // {
    parent.setEnabled(true);

    fillMenuRecursive(parent, concerns, selectedJavaElements, concernModelProvider.getLinkType());

    String linkAllLabel = getNewConcernMenuItemText();

    for (MenuItem menuItem : parent.getItems()) {
      String text = menuItem.getText();

      if (text.isEmpty()) {
        menuItem.dispose();
      } else if (text.equals(linkAllLabel)) {
        menuItem.dispose();
        break;
      }
    }

    // If there were concerns in the model, add a separator before
    // the New Concern item

    boolean hasItemsToLink = parent.getItemCount() > 0;

    /*if (hasItemsToLink)
    {
    	new MenuItem(parent, SWT.SEPARATOR);
    }*/

    // Add the "New concern..." item
    /*MenuItem lNewConcernItem = new MenuItem(parent, SWT.PUSH);
    lNewConcernItem.addSelectionListener(clickListener);
    lNewConcernItem.setText(linkAllLabel);*/
    /*	}
    else
    {
    	parent.setEnabled(false);
    }*/
  }
 protected void disposeMenuItems() {
   if (fMenu == null || fMenu.isDisposed()) {
     return;
   }
   MenuItem[] items = fMenu.getItems();
   for (int i = 0; i < items.length; i++) {
     MenuItem menuItem = items[i];
     if (!menuItem.isDisposed()) {
       menuItem.dispose();
     }
   }
 }
Example #4
0
 public void clearMenu() {
   for (org.eclipse.swt.widgets.MenuItem item : menu.getItems()) {
     if (!item.isDisposed()) {
       item.dispose();
     }
   }
   if (isIconReloadEnqueued) {
     IconFactory.getInstance().cleanup();
     IconFactory.getInstance().loadResources();
     isIconReloadEnqueued = false;
   }
 }
  /**
   * 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();
  }
 /**
  * The default implementation of this <code>IContributionItem</code> method does nothing.
  * Subclasses may override.
  */
 @Override
 public void dispose() {
   if (subMenuItem != null && !subMenuItem.isDisposed()) {
     subMenuItem.dispose();
   }
 }
  /**
   * Fills the menu with build configurations which are common for all selected projects
   *
   * @param menu The menu to fill
   */
  protected void fillMenu(Menu menu) {
    // This should not happen
    if (menu == null) return;

    MenuItem[] items = menu.getItems();
    for (MenuItem item2 : items) item2.dispose();

    SortedSet<String> configNames = new TreeSet<String>();
    String sCurrentConfig = null;
    boolean bCurrentConfig = true;
    for (IProject prj : fProjects) {
      ICConfigurationDescription[] cfgDescs = getCfgs(prj);

      String sActiveConfig = null;
      // Store names and detect active configuration
      for (ICConfigurationDescription cfgDesc : cfgDescs) {
        String s = cfgDesc.getName();
        if (!configNames.contains(s)) configNames.add(s);
        if (cfgDesc.isActive()) sActiveConfig = s;
      }

      // Check whether all projects have the same active configuration
      if (bCurrentConfig) {
        if (sCurrentConfig == null) sCurrentConfig = sActiveConfig;
        else {
          if (!sCurrentConfig.equals(sActiveConfig)) bCurrentConfig = false;
        }
      }
    }

    int accel = 0;
    for (String sName : configNames) {
      String sDesc = null;
      boolean commonName = true;
      boolean commonDesc = true;
      boolean firstProj = true;
      for (IProject prj : fProjects) {
        ICConfigurationDescription[] cfgDescs = getCfgs(prj);
        int i = 0;
        for (; i < cfgDescs.length; i++) {
          if (cfgDescs[i].getName().equals(sName)) {
            String sNewDesc = cfgDescs[i].getDescription();
            if (sNewDesc != null && sNewDesc.length() == 0) {
              sNewDesc = null;
            }
            if (commonDesc) {
              if (firstProj) {
                sDesc = sNewDesc;
                firstProj = false;
              } else if (sNewDesc == null && sDesc != null
                  || sNewDesc != null && !sNewDesc.equals(sDesc)) {
                commonDesc = false;
              }
            }
            break;
          }
        }
        if (i == cfgDescs.length) {
          commonName = false;
          break;
        }
      }
      if (commonName) {
        StringBuffer builder = new StringBuffer(sName);
        if (commonDesc) {
          if (sDesc != null) {
            builder.append(" ("); // $NON-NLS-1$
            builder.append(sDesc);
            builder.append(")"); // $NON-NLS-1$
          }
        } else {
          builder.append(" (...)"); // $NON-NLS-1$
        }

        IAction action = makeAction(sName, builder, accel);
        if (bCurrentConfig && sCurrentConfig != null && sCurrentConfig.equals(sName)) {
          action.setChecked(true);
        }
        ActionContributionItem item = new ActionContributionItem(action);
        item.fill(menu, -1);
        accel++;
      }
    }
  }