Program: 51866
Project: 51866
Buggy source:
public <T>void setElements(Collection<T> elements){
  int scrollPos=-1;
  if (this.isHierarchical) {
    if (isPreserveexpandedstate()) {
      cacheExpandedState();
    }
    scrollPos=tree.getTree().getVerticalBar().getSelection();
  }
  destroyPreviousBindings();
  this.elements=elements;
  this.getRootChildren().removeAll();
  if (elements == null) {
    update();
    changeSupport.firePropertyChange("String_Node_Str",null,getSelectedRows());
    changeSupport.firePropertyChange("String_Node_Str",null,getAbsoluteSelectedRows());
    return;
  }
  try {
    if (this.isHierarchical == false) {
      for (      T o : elements) {
        XulTreeRow row=this.getRootChildren().addNewRow();
        ((XulTreeItem)row.getParent()).setBoundObject(o);
        for (int x=0; x < this.getColumns().getChildNodes().size(); x++) {
          XulComponent col=this.getColumns().getColumn(x);
          final XulTreeCell cell=(XulTreeCell)getDocument().createElement("String_Node_Str");
          XulTreeCol column=(XulTreeCol)col;
          for (          InlineBindingExpression exp : ((XulTreeCol)col).getBindingExpressions()) {
            logger.debug("String_Node_Str" + exp + "String_Node_Str"+ cell+ "String_Node_Str"+ o+ "String_Node_Str");
            String colType=column.getType();
            if (StringUtils.isEmpty(colType) == false && colType.equals("String_Node_Str")) {
              colType=extractDynamicColType(o,x);
            }
            if ((colType.equalsIgnoreCase("String_Node_Str") || colType.equalsIgnoreCase("String_Node_Str")) && column.getCombobinding() != null) {
              DefaultBinding binding=new DefaultBinding(o,column.getCombobinding(),cell,"String_Node_Str");
              elementBindings.add(binding);
              binding.setBindingType(Binding.Type.ONE_WAY);
              domContainer.addBinding(binding);
              binding.fireSourceChanged();
              binding=new DefaultBinding(o,((XulTreeCol)col).getBinding(),cell,"String_Node_Str");
              elementBindings.add(binding);
              binding.setConversion(new BindingConvertor<Object,Integer>(){
                @Override public Integer sourceToTarget(                Object value){
                  int index=((Vector)cell.getValue()).indexOf(value);
                  return index > -1 ? index : 0;
                }
                @Override public Object targetToSource(                Integer value){
                  return ((Vector)cell.getValue()).get(value);
                }
              }
);
              domContainer.addBinding(binding);
              binding.fireSourceChanged();
              if (colType.equalsIgnoreCase("String_Node_Str")) {
                binding=new DefaultBinding(o,exp.getModelAttr(),cell,exp.getXulCompAttr());
                elementBindings.add(binding);
                if (!this.editable) {
                  binding.setBindingType(Binding.Type.ONE_WAY);
                }
 else {
                  binding.setBindingType(Binding.Type.BI_DIRECTIONAL);
                }
                domContainer.addBinding(binding);
              }
            }
 else             if (colType.equalsIgnoreCase("String_Node_Str")) {
              if (StringUtils.isNotEmpty(exp.getModelAttr())) {
                DefaultBinding binding=new DefaultBinding(o,exp.getModelAttr(),cell,"String_Node_Str");
                elementBindings.add(binding);
                if (!column.isEditable()) {
                  binding.setBindingType(Binding.Type.ONE_WAY);
                }
                domContainer.addBinding(binding);
                binding.fireSourceChanged();
              }
            }
 else {
              if (StringUtils.isNotEmpty(exp.getModelAttr())) {
                DefaultBinding binding=new DefaultBinding(o,exp.getModelAttr(),cell,exp.getXulCompAttr());
                elementBindings.add(binding);
                if (!column.isEditable()) {
                  binding.setBindingType(Binding.Type.ONE_WAY);
                }
                domContainer.addBinding(binding);
                binding.fireSourceChanged();
              }
 else {
                cell.setLabel(o.toString());
              }
            }
          }
          if (column.getDisabledbinding() != null) {
            String prop=column.getDisabledbinding();
            DefaultBinding bind=new DefaultBinding(o,column.getDisabledbinding(),cell,"String_Node_Str");
            elementBindings.add(bind);
            bind.setBindingType(Binding.Type.ONE_WAY);
            domContainer.addBinding(bind);
            bind.fireSourceChanged();
          }
          Method imageMethod;
          String imageSrc=null;
          String method=toGetter(((XulTreeCol)this.getColumns().getChildNodes().get(x)).getImagebinding());
          if (method != null) {
            imageMethod=o.getClass().getMethod(method);
            imageSrc=(String)imageMethod.invoke(o);
            SwtTreeItem item=(SwtTreeItem)row.getParent();
            item.setXulDomContainer(this.domContainer);
            ((XulTreeItem)row.getParent()).setImage(imageSrc);
          }
          row.addCell(cell);
        }
      }
    }
 else {
      suppressEvents=true;
      if (isHiddenrootnode() == false) {
        SwtTreeItem item=new SwtTreeItem(this.getRootChildren());
        item.setXulDomContainer(this.domContainer);
        item.setBoundObject(elements);
        SwtTreeRow newRow=new SwtTreeRow(item);
        item.setRow(newRow);
        this.getRootChildren().addChild(item);
        addTreeChild(elements,newRow);
      }
 else {
        for (        T o : elements) {
          SwtTreeItem item=new SwtTreeItem(this.getRootChildren());
          item.setXulDomContainer(this.domContainer);
          item.setBoundObject(o);
          SwtTreeRow newRow=new SwtTreeRow(item);
          item.setRow(newRow);
          this.getRootChildren().addChild(item);
          addTreeChild(o,newRow);
        }
      }
      suppressEvents=false;
    }
    update();
    if (this.isHierarchical) {
      if (isPreserveexpandedstate()) {
        restoreExpandedState();
      }
      final int fScrollPos=scrollPos;
      if (scrollPos > -1) {
      }
    }
    if (isPreserveselection() && currentSelectedItems != null && currentSelectedItems.size() > 0) {
      setSelectedItems(currentSelectedItems);
    }
    suppressEvents=false;
    changeSupport.firePropertyChange("String_Node_Str",null,getSelectedRows());
    changeSupport.firePropertyChange("String_Node_Str",null,getAbsoluteSelectedRows());
    changeSupport.firePropertyChange("String_Node_Str",null,Collections.EMPTY_LIST);
    changeSupport.firePropertyChange("String_Node_Str","String_Node_Str",null);
  }
 catch (  XulException e) {
    logger.error("String_Node_Str",e);
  }
catch (  Exception e) {
    logger.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public <T>void setElements(Collection<T> elements){
  int scrollPos=-1;
  if (this.isHierarchical) {
    if (isPreserveexpandedstate()) {
      cacheExpandedState();
    }
    scrollPos=tree.getTree().getVerticalBar().getSelection();
  }
  destroyPreviousBindings();
  this.elements=elements;
  this.getRootChildren().removeAll();
  if (elements == null) {
    update();
    changeSupport.firePropertyChange("String_Node_Str",null,getSelectedRows());
    changeSupport.firePropertyChange("String_Node_Str",null,getAbsoluteSelectedRows());
    return;
  }
  try {
    if (this.isHierarchical == false) {
      for (      T o : elements) {
        XulTreeRow row=this.getRootChildren().addNewRow();
        ((XulTreeItem)row.getParent()).setBoundObject(o);
        for (int x=0; x < this.getColumns().getChildNodes().size(); x++) {
          XulComponent col=this.getColumns().getColumn(x);
          final XulTreeCell cell=(XulTreeCell)getDocument().createElement("String_Node_Str");
          XulTreeCol column=(XulTreeCol)col;
          for (          InlineBindingExpression exp : ((XulTreeCol)col).getBindingExpressions()) {
            logger.debug("String_Node_Str" + exp + "String_Node_Str"+ cell+ "String_Node_Str"+ o+ "String_Node_Str");
            String colType=column.getType();
            if (StringUtils.isEmpty(colType) == false && colType.equals("String_Node_Str")) {
              colType=extractDynamicColType(o,x);
            }
            if ((colType.equalsIgnoreCase("String_Node_Str") || colType.equalsIgnoreCase("String_Node_Str")) && column.getCombobinding() != null) {
              DefaultBinding binding=new DefaultBinding(o,column.getCombobinding(),cell,"String_Node_Str");
              elementBindings.add(binding);
              binding.setBindingType(Binding.Type.ONE_WAY);
              domContainer.addBinding(binding);
              binding.fireSourceChanged();
              binding=new DefaultBinding(o,((XulTreeCol)col).getBinding(),cell,"String_Node_Str");
              elementBindings.add(binding);
              binding.setConversion(new BindingConvertor<Object,Integer>(){
                @Override public Integer sourceToTarget(                Object value){
                  int index=((Vector)cell.getValue()).indexOf(value);
                  return index > -1 ? index : 0;
                }
                @Override public Object targetToSource(                Integer value){
                  return ((Vector)cell.getValue()).get(value);
                }
              }
);
              domContainer.addBinding(binding);
              binding.fireSourceChanged();
              if (colType.equalsIgnoreCase("String_Node_Str")) {
                binding=new DefaultBinding(o,exp.getModelAttr(),cell,exp.getXulCompAttr());
                elementBindings.add(binding);
                if (!this.editable) {
                  binding.setBindingType(Binding.Type.ONE_WAY);
                }
 else {
                  binding.setBindingType(Binding.Type.BI_DIRECTIONAL);
                }
                domContainer.addBinding(binding);
              }
            }
 else             if (colType.equalsIgnoreCase("String_Node_Str")) {
              if (StringUtils.isNotEmpty(exp.getModelAttr())) {
                DefaultBinding binding=new DefaultBinding(o,exp.getModelAttr(),cell,"String_Node_Str");
                elementBindings.add(binding);
                if (!column.isEditable()) {
                  binding.setBindingType(Binding.Type.ONE_WAY);
                }
                domContainer.addBinding(binding);
                binding.fireSourceChanged();
              }
            }
 else {
              if (StringUtils.isNotEmpty(exp.getModelAttr())) {
                DefaultBinding binding=new DefaultBinding(o,exp.getModelAttr(),cell,exp.getXulCompAttr());
                elementBindings.add(binding);
                if (!column.isEditable()) {
                  binding.setBindingType(Binding.Type.ONE_WAY);
                }
                domContainer.addBinding(binding);
                binding.fireSourceChanged();
              }
 else {
                cell.setLabel(o.toString());
              }
            }
          }
          if (column.getDisabledbinding() != null) {
            String prop=column.getDisabledbinding();
            DefaultBinding bind=new DefaultBinding(o,column.getDisabledbinding(),cell,"String_Node_Str");
            elementBindings.add(bind);
            bind.setBindingType(Binding.Type.ONE_WAY);
            domContainer.addBinding(bind);
            bind.fireSourceChanged();
          }
          Method imageMethod;
          String imageSrc=null;
          String method=toGetter(((XulTreeCol)this.getColumns().getChildNodes().get(x)).getImagebinding());
          if (method != null) {
            imageMethod=o.getClass().getMethod(method);
            imageSrc=(String)imageMethod.invoke(o);
            SwtTreeItem item=(SwtTreeItem)row.getParent();
            item.setXulDomContainer(this.domContainer);
            ((XulTreeItem)row.getParent()).setImage(imageSrc);
          }
          row.addCell(cell);
        }
      }
    }
 else {
      suppressEvents=true;
      if (isHiddenrootnode() == false) {
        SwtTreeItem item=new SwtTreeItem(this.getRootChildren());
        item.setXulDomContainer(this.domContainer);
        item.setBoundObject(elements);
        SwtTreeRow newRow=new SwtTreeRow(item);
        item.setRow(newRow);
        this.getRootChildren().addChild(item);
        addTreeChild(elements,newRow);
      }
 else {
        for (        T o : elements) {
          SwtTreeItem item=new SwtTreeItem(this.getRootChildren());
          item.setXulDomContainer(this.domContainer);
          item.setBoundObject(o);
          SwtTreeRow newRow=new SwtTreeRow(item);
          item.setRow(newRow);
          this.getRootChildren().addChild(item);
          addTreeChild(o,newRow);
        }
      }
      suppressEvents=false;
    }
    update();
    if (this.isHierarchical) {
      if (isPreserveexpandedstate()) {
        restoreExpandedState();
      }
      final int fScrollPos=scrollPos;
      if (scrollPos > -1) {
      }
    }
    if (isPreserveselection() && currentSelectedItems != null && currentSelectedItems.size() > 0) {
      setSelectedItems(currentSelectedItems);
      suppressEvents=false;
    }
 else {
      suppressEvents=false;
      changeSupport.firePropertyChange("String_Node_Str",null,getSelectedRows());
      changeSupport.firePropertyChange("String_Node_Str",null,getAbsoluteSelectedRows());
      changeSupport.firePropertyChange("String_Node_Str",null,Collections.EMPTY_LIST);
      changeSupport.firePropertyChange("String_Node_Str","String_Node_Str",null);
    }
  }
 catch (  XulException e) {
    logger.error("String_Node_Str",e);
  }
catch (  Exception e) {
    logger.error("String_Node_Str",e);
  }
}