Program: 137526
Project: 137526
Buggy source:
@Override public void mouseDown(MouseEvent e){
  DataManager dm=analysis.getContext().getConnection();
  if (dm == null) {
    masterPage.doSave(null);
  }
  IRepositoryNode patternFolderNode=null;
  AnalysisType analysisType=analysis.getParameters().getAnalysisType();
  ExecutionLanguage executionLanguage=analysis.getParameters().getExecutionLanguage();
  if (AnalysisType.COLUMN_SET.equals(analysisType)) {
    if (ExecutionLanguage.SQL.equals(executionLanguage)) {
      MessageUI.openWarning(DefaultMessagesImpl.getString("String_Node_Str"));
      return;
    }
 else     if (ExecutionLanguage.JAVA.equals(executionLanguage)) {
      patternFolderNode=RepositoryNodeHelper.getLibrariesFolderNode(EResourceConstant.PATTERN_REGEX);
    }
  }
 else   if (AnalysisType.MULTIPLE_COLUMN.equals(analysisType)) {
    if (ExecutionLanguage.JAVA.equals(executionLanguage)) {
      patternFolderNode=RepositoryNodeHelper.getLibrariesFolderNode(EResourceConstant.PATTERN_REGEX);
    }
  }
  if (null == patternFolderNode) {
    patternFolderNode=RepositoryNodeHelper.getLibrariesFolderNode(EResourceConstant.PATTERNS);
  }
  CheckedTreeSelectionDialog dialog=PatternUtilities.createPatternCheckedTreeSelectionDialog(patternFolderNode);
  if (null != filters) {
    for (    ViewerFilter filter : filters) {
      dialog.addFilter(filter);
    }
  }
  Object[] selectedRepNodes=PatternUtilities.getPatternRepNodesByIndicator(meIndicator);
  dialog.setInitialSelections(selectedRepNodes);
  dialog.create();
  if (dialog.open() == Window.OK) {
    List<PatternRepNode> allSelectedPatternNodes=new ArrayList<PatternRepNode>();
    Set<String> allSelectedNodeNames=new HashSet<String>();
    for (    Object obj : dialog.getResult()) {
      if (obj instanceof PatternRepNode) {
        PatternRepNode patternNode=(PatternRepNode)obj;
        allSelectedPatternNodes.add(patternNode);
        allSelectedNodeNames.add(patternNode.getLabel());
      }
    }
    Set<String> oldSelectedNodeNames=new HashSet<String>();
    Map<String,IndicatorUnit> oldSelectedUnits=new HashMap<String,IndicatorUnit>();
    for (    IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
      Indicator indicator=indicatorUnit.getIndicator();
      if (indicator instanceof PatternMatchingIndicator) {
        if (!allSelectedNodeNames.contains(indicator.getName())) {
          meIndicator.removeIndicatorUnit(indicatorUnit);
          if (!columnDropTree.isDirty()) {
            columnDropTree.setDirty(true);
          }
        }
 else {
          oldSelectedNodeNames.add(indicator.getName());
          oldSelectedUnits.put(indicator.getName(),indicatorUnit);
        }
      }
    }
    boolean addOldSelected=false;
    if (masterPage instanceof ColumnSetMasterPage) {
      addOldSelected=true;
    }
    if (addOldSelected) {
      for (      TreeItem child : treeItem.getItems()) {
        masterPage.getTreeViewer().removeItemBranch(child);
      }
    }
    treeItem.removeAll();
    for (    PatternRepNode patternNode : allSelectedPatternNodes) {
      if (oldSelectedNodeNames.contains(patternNode.getLabel()) && !addOldSelected) {
        continue;
      }
      TypedReturnCode<IndicatorUnit> trc=PatternUtilities.createIndicatorUnit(patternNode.getPattern(),meIndicator,analysis);
      if (trc.isOk()) {
        createOneUnit(trc.getObject());
      }
    }
    treeItem.setExpanded(true);
    if (masterPage instanceof ColumnMasterDetailsPage) {
      ColumnMasterDetailsPage page=(ColumnMasterDetailsPage)masterPage;
      page.refreshTheTree(page.getCurrentModelElementIndicators());
    }
  }
}

Fixed version (ground truth):
@Override public void mouseDown(MouseEvent e){
  DataManager dm=analysis.getContext().getConnection();
  if (dm == null) {
    masterPage.doSave(null);
  }
  IRepositoryNode patternFolderNode=null;
  AnalysisType analysisType=analysis.getParameters().getAnalysisType();
  ExecutionLanguage executionLanguage=analysis.getParameters().getExecutionLanguage();
  if (AnalysisType.COLUMN_SET.equals(analysisType)) {
    if (ExecutionLanguage.SQL.equals(executionLanguage)) {
      MessageUI.openWarning(DefaultMessagesImpl.getString("String_Node_Str"));
      return;
    }
 else     if (ExecutionLanguage.JAVA.equals(executionLanguage)) {
      patternFolderNode=RepositoryNodeHelper.getLibrariesFolderNode(EResourceConstant.PATTERN_REGEX);
    }
  }
 else   if (AnalysisType.MULTIPLE_COLUMN.equals(analysisType)) {
    if (ExecutionLanguage.JAVA.equals(executionLanguage)) {
      patternFolderNode=RepositoryNodeHelper.getLibrariesFolderNode(EResourceConstant.PATTERN_REGEX);
    }
  }
  if (null == patternFolderNode) {
    patternFolderNode=RepositoryNodeHelper.getLibrariesFolderNode(EResourceConstant.PATTERNS);
  }
  CheckedTreeSelectionDialog dialog=PatternUtilities.createPatternCheckedTreeSelectionDialog(patternFolderNode);
  if (null != filters) {
    for (    ViewerFilter filter : filters) {
      dialog.addFilter(filter);
    }
  }
  Object[] selectedRepNodes=PatternUtilities.getPatternRepNodesByIndicator(meIndicator);
  dialog.setInitialSelections(selectedRepNodes);
  dialog.create();
  if (dialog.open() == Window.OK) {
    List<PatternRepNode> allSelectedPatternNodes=new ArrayList<PatternRepNode>();
    Set<String> allSelectedNodeNames=new HashSet<String>();
    for (    Object obj : dialog.getResult()) {
      if (obj instanceof PatternRepNode) {
        PatternRepNode patternNode=(PatternRepNode)obj;
        allSelectedPatternNodes.add(patternNode);
        allSelectedNodeNames.add(patternNode.getLabel());
      }
    }
    Set<String> oldSelectedNodeNames=new HashSet<String>();
    Map<String,IndicatorUnit> oldSelectedUnits=new HashMap<String,IndicatorUnit>();
    for (    IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
      Indicator indicator=indicatorUnit.getIndicator();
      if (indicator instanceof PatternMatchingIndicator) {
        if (!allSelectedNodeNames.contains(indicator.getName())) {
          columnDropTree.deleteIndicatorItems(meIndicator,indicatorUnit);
          if (!columnDropTree.isDirty()) {
            columnDropTree.setDirty(true);
          }
        }
 else {
          oldSelectedNodeNames.add(indicator.getName());
          oldSelectedUnits.put(indicator.getName(),indicatorUnit);
        }
      }
    }
    boolean addOldSelected=false;
    if (masterPage instanceof ColumnSetMasterPage) {
      addOldSelected=true;
    }
    if (addOldSelected) {
      for (      TreeItem child : treeItem.getItems()) {
        masterPage.getTreeViewer().removeItemBranch(child);
      }
    }
    treeItem.removeAll();
    for (    PatternRepNode patternNode : allSelectedPatternNodes) {
      if (oldSelectedNodeNames.contains(patternNode.getLabel()) && !addOldSelected) {
        continue;
      }
      TypedReturnCode<IndicatorUnit> trc=PatternUtilities.createIndicatorUnit(patternNode.getPattern(),meIndicator,analysis);
      if (trc.isOk()) {
        createOneUnit(trc.getObject());
      }
    }
    treeItem.setExpanded(true);
    if (masterPage instanceof ColumnMasterDetailsPage) {
      ColumnMasterDetailsPage page=(ColumnMasterDetailsPage)masterPage;
      page.refreshTheTree(page.getCurrentModelElementIndicators());
    }
  }
}