Program: 51830
Project: 51830
Buggy source:
private void setupTable(){
  List<XulComponent> colCollection=getColumns().getChildNodes();
  String cols[]=new String[colCollection.size()];
  SelectionGrid.SelectionPolicy selectionPolicy=null;
  if ("String_Node_Str".equals(getSeltype())) {
    selectionPolicy=SelectionGrid.SelectionPolicy.ONE_ROW;
  }
 else   if ("String_Node_Str".equals(getSeltype())) {
    selectionPolicy=SelectionGrid.SelectionPolicy.MULTI_ROW;
  }
  int[] widths=new int[cols.length];
  int totalFlex=0;
  for (int i=0; i < cols.length; i++) {
    totalFlex+=colCollection.get(i).getFlex();
  }
  boolean allFlexing=true;
  int totalWidth=0;
  for (int i=0; i < cols.length; i++) {
    cols[i]=((XulTreeCol)colCollection.get(i)).getLabel();
    if (totalFlex > 0 && getWidth() > 0) {
      widths[i]=(int)(getWidth() * ((double)colCollection.get(i).getFlex() / totalFlex));
      totalWidth+=widths[i];
    }
 else     if (getColumns().getColumn(i).getWidth() > 0) {
      allFlexing=false;
      widths[i]=getColumns().getColumn(i).getWidth();
      totalWidth+=widths[i];
    }
  }
  table=new BaseTable(cols,widths,new BaseColumnComparator[cols.length],selectionPolicy,this);
  if (getHeight() != 0) {
    table.setHeight(getHeight() + "String_Node_Str");
  }
 else {
    table.setHeight("String_Node_Str");
  }
  if (getWidth() != 0) {
    table.setWidth(getWidth() + "String_Node_Str");
  }
 else {
    table.setWidth("String_Node_Str");
  }
  if (allFlexing) {
    table.fillWidth();
  }
  RowSelectionHandler handler=new RowSelectionHandler(){
    @Override public void onRowSelection(    RowSelectionEvent event){
      try {
        if (getOnselect() != null && getOnselect().trim().length() > 0) {
          getXulDomContainer().invoke(getOnselect(),new Object[]{});
        }
        Integer[] selectedRows=table.getSelectedRows().toArray(new Integer[table.getSelectedRows().size()]);
        int[] rows=new int[selectedRows.length];
        for (int i=0; i < selectedRows.length; i++) {
          rows[i]=selectedRows[i];
        }
        GwtTree.this.setSelectedRows(rows);
        GwtTree.this.colCollection=getColumns().getChildNodes();
        if (GwtTree.this.isShowalleditcontrols() == false) {
          if (curSelectedRow > -1) {
            Object[] curSelectedRowOriginal=new Object[getColumns().getColumnCount()];
            for (int j=0; j < getColumns().getColumnCount(); j++) {
              curSelectedRowOriginal[j]=getColumnEditor(j,curSelectedRow);
            }
            table.replaceRow(curSelectedRow,curSelectedRowOriginal);
          }
          curSelectedRow=rows[0];
          Object[] newRow=new Object[getColumns().getColumnCount()];
          for (int j=0; j < getColumns().getColumnCount(); j++) {
            newRow[j]=getColumnEditor(j,rows[0]);
          }
          table.replaceRow(rows[0],newRow);
        }
      }
 catch (      XulException e) {
        e.printStackTrace();
      }
    }
  }
;
  table.addRowSelectionHandler(handler);
  setWidgetInPanel(table);
  updateUI();
}

Fixed version (ground truth):
private void setupTable(){
  List<XulComponent> colCollection=getColumns().getChildNodes();
  String cols[]=new String[colCollection.size()];
  SelectionGrid.SelectionPolicy selectionPolicy=null;
  if ("String_Node_Str".equals(getSeltype())) {
    selectionPolicy=SelectionGrid.SelectionPolicy.ONE_ROW;
  }
 else   if ("String_Node_Str".equals(getSeltype())) {
    selectionPolicy=SelectionGrid.SelectionPolicy.MULTI_ROW;
  }
  int[] widths=new int[cols.length];
  int totalFlex=0;
  for (int i=0; i < cols.length; i++) {
    totalFlex+=colCollection.get(i).getFlex();
  }
  boolean allFlexing=true;
  int totalWidth=0;
  for (int i=0; i < cols.length; i++) {
    cols[i]=((XulTreeCol)colCollection.get(i)).getLabel();
    if (totalFlex > 0 && getWidth() > 0) {
      widths[i]=(int)(getWidth() * ((double)colCollection.get(i).getFlex() / totalFlex));
      totalWidth+=widths[i];
    }
 else     if (getColumns().getColumn(i).getWidth() > 0) {
      allFlexing=false;
      widths[i]=getColumns().getColumn(i).getWidth();
      totalWidth+=widths[i];
    }
  }
  table=new BaseTable(cols,widths,new BaseColumnComparator[cols.length],selectionPolicy,this);
  if (getHeight() != 0) {
    table.setHeight(getHeight() + "String_Node_Str");
  }
 else {
    table.setHeight("String_Node_Str");
  }
  if (getWidth() != 0) {
    table.setWidth(getWidth() + "String_Node_Str");
  }
 else {
    table.setWidth("String_Node_Str");
  }
  if (allFlexing) {
    table.fillWidth();
  }
  RowSelectionHandler handler=new RowSelectionHandler(){
    @Override public void onRowSelection(    RowSelectionEvent event){
      try {
        Integer[] selectedRows=table.getSelectedRows().toArray(new Integer[table.getSelectedRows().size()]);
        if (getOnselect() != null && getOnselect().trim().length() > 0) {
          getXulDomContainer().invoke(getOnselect(),new Object[]{selectedRows.length > 0 ? selectedRows[0] : null});
        }
        int[] rows=new int[selectedRows.length];
        for (int i=0; i < selectedRows.length; i++) {
          rows[i]=selectedRows[i];
        }
        GwtTree.this.setSelectedRows(rows);
        GwtTree.this.colCollection=getColumns().getChildNodes();
        if (GwtTree.this.isShowalleditcontrols() == false) {
          if (curSelectedRow > -1) {
            Object[] curSelectedRowOriginal=new Object[getColumns().getColumnCount()];
            for (int j=0; j < getColumns().getColumnCount(); j++) {
              curSelectedRowOriginal[j]=getColumnEditor(j,curSelectedRow);
            }
            table.replaceRow(curSelectedRow,curSelectedRowOriginal);
          }
          curSelectedRow=rows[0];
          Object[] newRow=new Object[getColumns().getColumnCount()];
          for (int j=0; j < getColumns().getColumnCount(); j++) {
            newRow[j]=getColumnEditor(j,rows[0]);
          }
          table.replaceRow(rows[0],newRow);
        }
      }
 catch (      XulException e) {
        e.printStackTrace();
      }
    }
  }
;
  table.addRowSelectionHandler(handler);
  setWidgetInPanel(table);
  updateUI();
}