/** @param element */
 protected void cleanUp(MToolBar toolbarModel) {
   Collection<ToolBarContributionRecord> vals = modelContributionToRecord.values();
   for (ToolBarContributionRecord record :
       vals.toArray(new ToolBarContributionRecord[vals.size()])) {
     if (record.toolbarModel == toolbarModel) {
       record.dispose();
       for (MToolBarElement copy : record.generatedElements) {
         cleanUpCopy(record, copy);
       }
       for (MToolBarElement copy : record.sharedElements) {
         cleanUpCopy(record, copy);
       }
       record.generatedElements.clear();
       record.sharedElements.clear();
     }
   }
 }
 public void cleanUpCopy(ToolBarContributionRecord record, MToolBarElement copy) {
   modelContributionToRecord.remove(copy);
   IContributionItem ici = getContribution(copy);
   clearModelToContribution(copy, ici);
   if (ici != null) {
     record.getManagerForModel().remove(ici);
   }
 }
  /**
   * @param toolbarModel
   * @param manager
   * @param contribution
   * @param existingSeparatorNames
   * @return <code>true</code> if the contribution was successfuly processed
   */
  private boolean processAddition(
      final MToolBar toolbarModel,
      final ToolBarManager manager,
      MToolBarContribution contribution) {
    final ToolBarContributionRecord record =
        new ToolBarContributionRecord(toolbarModel, contribution, this);
    if (!record.mergeIntoModel()) {
      return false;
    }
    if (record.anyVisibleWhen()) {
      final IEclipseContext parentContext = getContext(toolbarModel);
      parentContext.runAndTrack(
          new RunAndTrack() {
            @Override
            public boolean changed(IEclipseContext context) {
              if (getManager(toolbarModel) == null) {
                // tool bar no longer being managed, ignore it
                return false;
              }

              record.updateVisibility(parentContext.getActiveLeaf());
              runExternalCode(
                  new Runnable() {

                    public void run() {
                      manager.update(false);
                    }
                  });
              // disposeToolbarIfNecessary(toolbarModel);
              return true;
            }
          });
    }

    return true;
  }