Program: 137520
Project: 137520
Buggy source:
/** 
 * DOC xqliu Comment method "addColumnUdi". ADD xqliu 2010-02-23 feature 11617
 * @param treeItem
 * @param meIndicator
 * @param columnIndex
 * @return
 */
private TreeEditor addColumnUdi(final TreeItem treeItem,final ModelElementIndicator meIndicator,int columnIndex){
  TreeEditor addUdiEditor=new TreeEditor(tree);
  Label addUdiLabl=new Label(tree,SWT.NONE);
  addUdiLabl.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
  addUdiLabl.setImage(ImageLib.getImage(ImageLib.ADD_IND_DEFINITION));
  addUdiLabl.setToolTipText(DefaultMessagesImpl.getString("String_Node_Str"));
  addUdiLabl.pack();
  addUdiLabl.addMouseListener(new MouseAdapter(){
    @Override public void mouseDown(    MouseEvent e){
      DataManager dm=getAnalysis().getContext().getConnection();
      if (dm == null) {
        masterPage.doSave(null);
      }
      if (dm != null && dm instanceof Connection) {
        Connection dp=(Connection)dm;
        if (ConnectionUtils.isMdmConnection(dp)) {
          MessageUI.openWarning(DefaultMessagesImpl.getString("String_Node_Str"));
          return;
        }
      }
      IFolder udiProject=ResourceManager.getUDIFolder();
      CheckedTreeSelectionDialog dialog=UDIUtils.createUdiCheckedTreeSelectionDialog(udiProject,meIndicator);
      if (dialog.open() == Window.OK) {
        List<IFile> allSelectedFiles=new ArrayList<IFile>();
        Set<String> allSelectedIndNames=new HashSet<String>();
        for (        Object obj : dialog.getResult()) {
          if (obj instanceof IFile) {
            allSelectedFiles.add((IFile)obj);
            IndicatorDefinition udid=IndicatorResourceFileHelper.getInstance().findIndDefinition((IFile)obj);
            if (udid != null) {
              allSelectedIndNames.add(udid.getName());
            }
          }
        }
        Set<String> oldSelectedIndNames=new HashSet<String>();
        for (        IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
          Indicator indicator=indicatorUnit.getIndicator();
          if (indicator instanceof UserDefIndicator) {
            if (allSelectedIndNames.contains(indicator.getName())) {
              oldSelectedIndNames.add(indicator.getName());
            }
 else {
              meIndicator.removeIndicatorUnit(indicatorUnit);
              if (!isDirty()) {
                setDirty(true);
              }
            }
          }
        }
        treeItem.removeAll();
        for (        IFile file : allSelectedFiles) {
          IndicatorDefinition udid=IndicatorResourceFileHelper.getInstance().findIndDefinition(file);
          if (udid != null && oldSelectedIndNames.contains(udid.getName())) {
            continue;
          }
          IndicatorUnit[] addIndicatorUnits=null;
          try {
            addIndicatorUnits=UDIUtils.createIndicatorUnit(file,meIndicator,getAnalysis());
          }
 catch (          Throwable e1) {
            log.warn(e1,e1);
          }
          if (addIndicatorUnits != null && addIndicatorUnits.length > 0) {
            for (            IndicatorUnit unit : addIndicatorUnits) {
              createOneUnit(treeItem,unit);
            }
            if (!isDirty()) {
              setDirty(true);
            }
          }
        }
        treeItem.setExpanded(true);
        masterPage.refreshTheTree(masterPage.getCurrentModelElementIndicators());
      }
    }
  }
);
  addUdiEditor.minimumWidth=addUdiLabl.getImage().getBounds().width;
  addUdiEditor.setEditor(addUdiLabl,treeItem,columnIndex);
  return addUdiEditor;
}

Fixed version (ground truth):
/** 
 * DOC xqliu Comment method "addColumnUdi". ADD xqliu 2010-02-23 feature 11617
 * @param treeItem
 * @param meIndicator
 * @param columnIndex
 * @return
 */
private TreeEditor addColumnUdi(final TreeItem treeItem,final ModelElementIndicator meIndicator,int columnIndex){
  TreeEditor addUdiEditor=new TreeEditor(tree);
  Label addUdiLabl=new Label(tree,SWT.NONE);
  addUdiLabl.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
  addUdiLabl.setImage(ImageLib.getImage(ImageLib.ADD_IND_DEFINITION));
  addUdiLabl.setToolTipText(DefaultMessagesImpl.getString("String_Node_Str"));
  addUdiLabl.pack();
  addUdiLabl.addMouseListener(new MouseAdapter(){
    @Override public void mouseDown(    MouseEvent e){
      DataManager dm=getAnalysis().getContext().getConnection();
      if (dm == null) {
        masterPage.doSave(null);
      }
      if (dm != null && dm instanceof Connection) {
        Connection dp=(Connection)dm;
        if (ConnectionUtils.isMdmConnection(dp)) {
          MessageUI.openWarning(DefaultMessagesImpl.getString("String_Node_Str"));
          return;
        }
      }
      IFolder udiProject=ResourceManager.getUDIFolder();
      CheckedTreeSelectionDialog dialog=UDIUtils.createUdiCheckedTreeSelectionDialog(udiProject,meIndicator);
      if (dialog.open() == Window.OK) {
        List<IFile> allSelectedFiles=new ArrayList<IFile>();
        Set<String> allSelectedIndNames=new HashSet<String>();
        for (        Object obj : dialog.getResult()) {
          if (obj instanceof IFile) {
            allSelectedFiles.add((IFile)obj);
            IndicatorDefinition udid=IndicatorResourceFileHelper.getInstance().findIndDefinition((IFile)obj);
            if (udid != null) {
              allSelectedIndNames.add(udid.getName());
            }
          }
        }
        Set<String> oldSelectedIndNames=new HashSet<String>();
        for (        IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
          Indicator indicator=indicatorUnit.getIndicator();
          if (indicator instanceof UserDefIndicator) {
            if (allSelectedIndNames.contains(indicator.getName())) {
              oldSelectedIndNames.add(indicator.getName());
            }
 else {
              deleteIndicatorItems(meIndicator,indicatorUnit);
              if (!isDirty()) {
                setDirty(true);
              }
            }
          }
        }
        treeItem.removeAll();
        for (        IFile file : allSelectedFiles) {
          IndicatorDefinition udid=IndicatorResourceFileHelper.getInstance().findIndDefinition(file);
          if (udid != null && oldSelectedIndNames.contains(udid.getName())) {
            continue;
          }
          IndicatorUnit[] addIndicatorUnits=null;
          try {
            addIndicatorUnits=UDIUtils.createIndicatorUnit(file,meIndicator,getAnalysis());
          }
 catch (          Throwable e1) {
            log.warn(e1,e1);
          }
          if (addIndicatorUnits != null && addIndicatorUnits.length > 0) {
            for (            IndicatorUnit unit : addIndicatorUnits) {
              createOneUnit(treeItem,unit);
            }
            if (!isDirty()) {
              setDirty(true);
            }
          }
        }
        treeItem.setExpanded(true);
        masterPage.refreshTheTree(masterPage.getCurrentModelElementIndicators());
      }
    }
  }
);
  addUdiEditor.minimumWidth=addUdiLabl.getImage().getBounds().width;
  addUdiEditor.setEditor(addUdiLabl,treeItem,columnIndex);
  return addUdiEditor;
}