Program: 139265
Project: 139265
Buggy source:
private void addItemElements(final ModelElementIndicator[] elements){
  for (int i=0; i < elements.length; i++) {
    final TreeItem treeItem=new TreeItem(tree,SWT.NONE);
    treeItem.setImage(ImageLib.getImage(ImageLib.TD_COLUMN));
    final ModelElementIndicator meIndicator=(ModelElementIndicator)elements[i];
    treeItem.setText(0,getModelElemetnDisplayName(meIndicator));
    treeItem.setData(MODELELEMENT_INDICATOR_KEY,meIndicator);
    TreeEditor comboEditor=new TreeEditor(tree);
    final CCombo combo=new CCombo(tree,SWT.BORDER);
    for (    DataminingType type : DataminingType.values()) {
      combo.add(type.getLiteral());
    }
    DataminingType dataminingType=MetadataHelper.getDataminingType(meIndicator.getModelElement());
    if (dataminingType == null) {
      combo.select(0);
    }
 else {
      combo.setText(dataminingType.getLiteral());
    }
    combo.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent e){
        MetadataHelper.setDataminingType(DataminingType.get(combo.getText()),meIndicator.getModelElement());
        setDirty(true);
      }
    }
);
    combo.setEditable(false);
    comboEditor.minimumWidth=WIDTH1_CELL;
    comboEditor.setEditor(combo,treeItem,1);
    TreeEditor addPatternEditor=new TreeEditor(tree);
    Label addPatternLabl=new Label(tree,SWT.NONE);
    addPatternLabl.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    addPatternLabl.setImage(ImageLib.getImage(ImageLib.ADD_PATTERN));
    addPatternLabl.setToolTipText(DefaultMessagesImpl.getString("String_Node_Str"));
    addPatternLabl.pack();
    addPatternLabl.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 TdDataProvider) {
          TdDataProvider dp=(TdDataProvider)dm;
          if (ConnectionUtils.isMdmConnection(DataProviderHelper.getTdProviderConnection(dp).getObject())) {
            MessageUI.openWarning(DefaultMessagesImpl.getString("String_Node_Str"));
            return;
          }
        }
        IFolder libProject=ResourceManager.getLibrariesFolder();
        CheckedTreeSelectionDialog dialog=PatternUtilities.createPatternCheckedTreeSelectionDialog(libProject);
        if (dialog.open() == Window.OK) {
          for (          Object obj : dialog.getResult()) {
            if (obj instanceof IFile) {
              IFile file=(IFile)obj;
              IndicatorUnit addIndicatorUnit=PatternUtilities.createIndicatorUnit(file,meIndicator,getAnalysis());
              if (addIndicatorUnit != null) {
                createOneUnit(treeItem,addIndicatorUnit);
                setDirty(true);
              }
 else {
                Pattern pattern=PatternResourceFileHelper.getInstance().findPattern(file);
                MessageUI.openError(DefaultMessagesImpl.getString("String_Node_Str") + pattern.getName());
              }
            }
          }
        }
      }
    }
);
    addPatternEditor.minimumWidth=addPatternLabl.getImage().getBounds().width;
    addPatternEditor.setEditor(addPatternLabl,treeItem,2);
    addColumnUdi(treeItem,meIndicator,3);
    TreeEditor delLabelEditor=new TreeEditor(tree);
    Label delLabel=new Label(tree,SWT.NONE);
    delLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    delLabel.setImage(ImageLib.getImage(ImageLib.DELETE_ACTION));
    delLabel.setToolTipText(DefaultMessagesImpl.getString("String_Node_Str"));
    delLabel.pack();
    delLabel.addMouseListener(new MouseAdapter(){
      @Override public void mouseDown(      MouseEvent e){
        deleteModelElementItems(meIndicator);
        if (treeItem.getParentItem() != null && treeItem.getParentItem().getData(INDICATOR_UNIT_KEY) != null) {
          setElements(modelElementIndicators);
        }
 else {
          removeItemBranch(treeItem);
        }
      }
    }
);
    delLabelEditor.minimumWidth=delLabel.getImage().getBounds().width;
    delLabelEditor.horizontalAlignment=SWT.CENTER;
    delLabelEditor.setEditor(delLabel,treeItem,4);
    treeItem.setData(ITEM_EDITOR_KEY,new TreeEditor[]{comboEditor,delLabelEditor,addPatternEditor});
    if (meIndicator.hasIndicators()) {
      createIndicatorItems(treeItem,meIndicator.getIndicatorUnits());
    }
    treeItem.setExpanded(true);
  }
  this.setDirty(true);
}

Fixed version (ground truth):
private void addItemElements(final ModelElementIndicator[] elements){
  for (int i=0; i < elements.length; i++) {
    final TreeItem treeItem=new TreeItem(tree,SWT.NONE);
    treeItem.setImage(ImageLib.getImage(ImageLib.TD_COLUMN));
    final ModelElementIndicator meIndicator=(ModelElementIndicator)elements[i];
    treeItem.setText(0,getModelElemetnDisplayName(meIndicator));
    treeItem.setData(MODELELEMENT_INDICATOR_KEY,meIndicator);
    TreeEditor comboEditor=new TreeEditor(tree);
    final CCombo combo=new CCombo(tree,SWT.BORDER);
    for (    DataminingType type : DataminingType.values()) {
      combo.add(type.getLiteral());
    }
    DataminingType dataminingType=MetadataHelper.getDataminingType(meIndicator.getModelElement());
    if (dataminingType == null) {
      combo.select(0);
    }
 else {
      combo.setText(dataminingType.getLiteral());
    }
    combo.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent e){
        MetadataHelper.setDataminingType(DataminingType.get(combo.getText()),meIndicator.getModelElement());
        setDirty(true);
      }
    }
);
    combo.setEditable(false);
    comboEditor.minimumWidth=WIDTH1_CELL;
    comboEditor.setEditor(combo,treeItem,1);
    TreeEditor addPatternEditor=new TreeEditor(tree);
    Label addPatternLabl=new Label(tree,SWT.NONE);
    addPatternLabl.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    addPatternLabl.setImage(ImageLib.getImage(ImageLib.ADD_PATTERN));
    addPatternLabl.setToolTipText(DefaultMessagesImpl.getString("String_Node_Str"));
    addPatternLabl.pack();
    addPatternLabl.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 TdDataProvider) {
          TdDataProvider dp=(TdDataProvider)dm;
          if (ConnectionUtils.isMdmConnection(DataProviderHelper.getTdProviderConnection(dp).getObject())) {
            MessageUI.openWarning(DefaultMessagesImpl.getString("String_Node_Str"));
            return;
          }
        }
        IFolder libProject=ResourceManager.getLibrariesFolder();
        CheckedTreeSelectionDialog dialog=PatternUtilities.createPatternCheckedTreeSelectionDialog(libProject);
        if (dialog.open() == Window.OK) {
          for (          Object obj : dialog.getResult()) {
            if (obj instanceof IFile) {
              IFile file=(IFile)obj;
              IndicatorUnit addIndicatorUnit=PatternUtilities.createIndicatorUnit(file,meIndicator,getAnalysis());
              if (addIndicatorUnit != null) {
                createOneUnit(treeItem,addIndicatorUnit);
                setDirty(true);
              }
 else {
                Pattern pattern=PatternResourceFileHelper.getInstance().findPattern(file);
                MessageUI.openError(DefaultMessagesImpl.getString("String_Node_Str") + pattern.getName());
              }
            }
          }
        }
      }
    }
);
    addPatternEditor.minimumWidth=addPatternLabl.getImage().getBounds().width;
    addPatternEditor.setEditor(addPatternLabl,treeItem,2);
    TreeEditor addUdiEditor=addColumnUdi(treeItem,meIndicator,3);
    TreeEditor delLabelEditor=new TreeEditor(tree);
    Label delLabel=new Label(tree,SWT.NONE);
    delLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    delLabel.setImage(ImageLib.getImage(ImageLib.DELETE_ACTION));
    delLabel.setToolTipText(DefaultMessagesImpl.getString("String_Node_Str"));
    delLabel.pack();
    delLabel.addMouseListener(new MouseAdapter(){
      @Override public void mouseDown(      MouseEvent e){
        deleteModelElementItems(meIndicator);
        if (treeItem.getParentItem() != null && treeItem.getParentItem().getData(INDICATOR_UNIT_KEY) != null) {
          setElements(modelElementIndicators);
        }
 else {
          removeItemBranch(treeItem);
        }
      }
    }
);
    delLabelEditor.minimumWidth=delLabel.getImage().getBounds().width;
    delLabelEditor.horizontalAlignment=SWT.CENTER;
    delLabelEditor.setEditor(delLabel,treeItem,4);
    treeItem.setData(ITEM_EDITOR_KEY,new TreeEditor[]{comboEditor,delLabelEditor,addPatternEditor,addUdiEditor});
    if (meIndicator.hasIndicators()) {
      createIndicatorItems(treeItem,meIndicator.getIndicatorUnits());
    }
    treeItem.setExpanded(true);
  }
  this.setDirty(true);
}