Program: 102073
Project: 102073
Buggy source:
private Composite createResultSetPanel(Composite parent){
  Composite thePanel=WidgetFactory.createPanel(parent,SWT.NONE,1,2);
  GridLayoutFactory.fillDefaults().margins(10,10).applyTo(thePanel);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(thePanel);
  this.includeResultSetCB=new Button(thePanel,SWT.CHECK | SWT.RIGHT);
  GridDataFactory.fillDefaults().align(SWT.LEFT,SWT.CENTER).applyTo(this.includeResultSetCB);
  this.includeResultSetCB.setText(Messages.includeLabel);
  this.includeResultSetCB.setToolTipText(Messages.includeResultSetTooltip);
  this.includeResultSetCB.addSelectionListener(new SelectionAdapter(){
    /** 
 * {@inheritDoc}
 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
 */
    @Override public void widgetSelected(    SelectionEvent e){
      if (includeResultSetCB.getSelection()) {
        if (getRelationalReference().getResultSet() == null) {
          RelationalProcedureResultSet resultSet=new RelationalProcedureResultSet();
          if (resultSetNameText.getText() != null) {
            resultSet.setName(resultSetNameText.getText());
          }
          getRelationalReference().setResultSet(resultSet);
        }
      }
 else {
        getRelationalReference().setResultSet(null);
      }
      handleInfoChanged();
    }
  }
);
  Composite namePanel=WidgetFactory.createPanel(thePanel,SWT.NONE,2,2);
  GridLayoutFactory.fillDefaults().numColumns(2).applyTo(namePanel);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(namePanel);
  Label label=new Label(namePanel,SWT.NONE | SWT.RIGHT);
  label.setText(Messages.nameLabel);
  GridDataFactory.fillDefaults().applyTo(label);
  this.resultSetNameText=new Text(namePanel,SWT.BORDER | SWT.SINGLE);
  this.resultSetNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
  GridDataFactory.fillDefaults().grab(true,false).minSize(50,SWT.DEFAULT).applyTo(this.resultSetNameText);
  this.resultSetNameText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    final ModifyEvent event){
      String value=resultSetNameText.getText();
      if (value == null) {
        value=EMPTY_STRING;
      }
      if (getRelationalReference().getResultSet() != null) {
        RelationalProcedureResultSet resultSet=getRelationalReference().getResultSet();
        resultSet.setName(value);
      }
      handleInfoChanged();
    }
  }
);
  Composite buttonPanel=WidgetFactory.createPanel(thePanel,SWT.NONE,1,4);
  GridLayoutFactory.fillDefaults().numColumns(4).applyTo(buttonPanel);
  GridDataFactory.fillDefaults().span(2,1).applyTo(buttonPanel);
  addColumnButton=new Button(buttonPanel,SWT.PUSH);
  addColumnButton.setText(Messages.addLabel);
  GridDataFactory.fillDefaults().applyTo(addColumnButton);
  addColumnButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      getRelationalReference().getResultSet().createColumn();
      handleInfoChanged();
    }
  }
);
  this.addColumnButton.setEnabled(false);
  deleteColumnButton=new Button(buttonPanel,SWT.PUSH);
  deleteColumnButton.setText(Messages.deleteLabel);
  GridDataFactory.fillDefaults().applyTo(deleteColumnButton);
  deleteColumnButton.setEnabled(false);
  deleteColumnButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      RelationalColumn column=null;
      IStructuredSelection selection=(IStructuredSelection)columnsViewer.getSelection();
      for (      Object obj : selection.toArray()) {
        if (obj instanceof RelationalColumn) {
          column=(RelationalColumn)obj;
          break;
        }
      }
      if (column != null) {
        getRelationalReference().getResultSet().removeColumn(column);
        deleteColumnButton.setEnabled(false);
        handleInfoChanged();
      }
    }
  }
);
  upColumnButton=new Button(buttonPanel,SWT.PUSH);
  upColumnButton.setText(Messages.moveUpLabel);
  GridDataFactory.fillDefaults().applyTo(upColumnButton);
  upColumnButton.setEnabled(false);
  upColumnButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      RelationalColumn info=null;
      IStructuredSelection selection=(IStructuredSelection)columnsViewer.getSelection();
      for (      Object obj : selection.toArray()) {
        if (obj instanceof RelationalColumn) {
          info=(RelationalColumn)obj;
          break;
        }
      }
      if (info != null) {
        int selectedIndex=columnsViewer.getTable().getSelectionIndex();
        getRelationalReference().getResultSet().moveColumnUp(info);
        handleInfoChanged();
        columnsViewer.getTable().select(selectedIndex - 1);
        downColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnDown(info));
        upColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnUp(info));
      }
    }
  }
);
  downColumnButton=new Button(buttonPanel,SWT.PUSH);
  downColumnButton.setText(Messages.moveDownLabel);
  GridDataFactory.fillDefaults().applyTo(downColumnButton);
  downColumnButton.setEnabled(false);
  downColumnButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      RelationalColumn info=null;
      IStructuredSelection selection=(IStructuredSelection)columnsViewer.getSelection();
      for (      Object obj : selection.toArray()) {
        if (obj instanceof RelationalColumn) {
          info=(RelationalColumn)obj;
          break;
        }
      }
      if (info != null) {
        int selectedIndex=columnsViewer.getTable().getSelectionIndex();
        getRelationalReference().getResultSet().moveColumnDown(info);
        handleInfoChanged();
        columnsViewer.getTable().select(selectedIndex + 1);
        downColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnDown(info));
        upColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnUp(info));
      }
    }
  }
);
  Table columnTable=new Table(thePanel,SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL| SWT.BORDER);
  columnTable.setHeaderVisible(true);
  columnTable.setLinesVisible(true);
  columnTable.setLayout(new TableLayout());
  this.columnsViewer=new TableViewer(columnTable);
  GridDataFactory.fillDefaults().grab(true,false).hint(SWT.DEFAULT,100).applyTo(this.columnsViewer.getControl());
  TableViewerColumn column=new TableViewerColumn(this.columnsViewer,SWT.LEFT);
  column.getColumn().setText(Messages.columnNameLabel + "String_Node_Str");
  column.setEditingSupport(new ColumnNameEditingSupport(this.columnsViewer));
  column.setLabelProvider(new ColumnDataLabelProvider(0));
  column.getColumn().pack();
  column=new TableViewerColumn(this.columnsViewer,SWT.LEFT);
  column.getColumn().setText(Messages.dataTypeLabel + "String_Node_Str");
  column.setLabelProvider(new ColumnDataLabelProvider(1));
  column.setEditingSupport(new DatatypeEditingSupport(this.columnsViewer));
  column.getColumn().pack();
  column=new TableViewerColumn(this.columnsViewer,SWT.LEFT);
  column.getColumn().setText(Messages.lengthLabel);
  column.setLabelProvider(new ColumnDataLabelProvider(2));
  column.setEditingSupport(new ColumnWidthEditingSupport(this.columnsViewer));
  column.getColumn().pack();
  if (this.getRelationalReference().getResultSet() != null) {
    for (    RelationalColumn row : this.getRelationalReference().getResultSet().getColumns()) {
      this.columnsViewer.add(row);
    }
  }
  this.columnsViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    @Override public void selectionChanged(    SelectionChangedEvent event){
      IStructuredSelection sel=(IStructuredSelection)event.getSelection();
      if (sel.isEmpty()) {
        deleteColumnButton.setEnabled(false);
        upColumnButton.setEnabled(false);
        downColumnButton.setEnabled(false);
      }
 else {
        boolean enable=true;
        Object[] objs=sel.toArray();
        RelationalColumn columnInfo=null;
        for (        Object obj : objs) {
          if (!(obj instanceof RelationalColumn)) {
            enable=false;
            break;
          }
 else {
            columnInfo=(RelationalColumn)obj;
          }
        }
        if (objs.length == 0) {
          enable=false;
        }
        deleteColumnButton.setEnabled(enable);
        if (enable) {
          upColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnUp(columnInfo));
          downColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnDown(columnInfo));
        }
      }
    }
  }
);
  return thePanel;
}

Fixed version (ground truth):
private Composite createResultSetPanel(Composite parent){
  Composite thePanel=WidgetFactory.createPanel(parent,SWT.NONE,1,2);
  GridLayoutFactory.fillDefaults().margins(10,10).applyTo(thePanel);
  GridDataFactory.fillDefaults().grab(true,true).applyTo(thePanel);
  this.includeResultSetCB=new Button(thePanel,SWT.CHECK | SWT.RIGHT);
  GridDataFactory.fillDefaults().align(SWT.LEFT,SWT.CENTER).applyTo(this.includeResultSetCB);
  this.includeResultSetCB.setText(Messages.includeLabel);
  this.includeResultSetCB.setToolTipText(Messages.includeResultSetTooltip);
  this.includeResultSetCB.addSelectionListener(new SelectionAdapter(){
    /** 
 * {@inheritDoc}
 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
 */
    @Override public void widgetSelected(    SelectionEvent e){
      if (includeResultSetCB.getSelection()) {
        if (getRelationalReference().getResultSet() == null) {
          RelationalProcedureResultSet resultSet=new RelationalProcedureResultSet();
          if (resultSetNameText.getText() != null) {
            resultSet.setName(resultSetNameText.getText());
          }
          getRelationalReference().setResultSet(resultSet);
        }
      }
 else {
        getRelationalReference().setResultSet(null);
      }
      handleInfoChanged();
    }
  }
);
  Composite namePanel=WidgetFactory.createPanel(thePanel,SWT.NONE,2,2);
  GridLayoutFactory.fillDefaults().numColumns(2).applyTo(namePanel);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(namePanel);
  Label label=new Label(namePanel,SWT.NONE | SWT.RIGHT);
  label.setText(Messages.nameLabel);
  GridDataFactory.fillDefaults().applyTo(label);
  this.resultSetNameText=new Text(namePanel,SWT.BORDER | SWT.SINGLE);
  this.resultSetNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
  GridDataFactory.fillDefaults().grab(true,false).minSize(50,SWT.DEFAULT).applyTo(this.resultSetNameText);
  this.resultSetNameText.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    final ModifyEvent event){
      String value=resultSetNameText.getText();
      if (value == null) {
        value=EMPTY_STRING;
      }
      if (getRelationalReference().getResultSet() != null) {
        RelationalProcedureResultSet resultSet=getRelationalReference().getResultSet();
        resultSet.setName(value);
      }
      handleInfoChanged();
    }
  }
);
  Composite buttonPanel=WidgetFactory.createPanel(thePanel,SWT.NONE,1,4);
  GridLayoutFactory.fillDefaults().numColumns(4).applyTo(buttonPanel);
  GridDataFactory.fillDefaults().span(2,1).applyTo(buttonPanel);
  addColumnButton=new Button(buttonPanel,SWT.PUSH);
  addColumnButton.setText(Messages.addLabel);
  GridDataFactory.fillDefaults().applyTo(addColumnButton);
  addColumnButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      getRelationalReference().getResultSet().createColumn();
      handleInfoChanged();
    }
  }
);
  this.addColumnButton.setEnabled(false);
  deleteColumnButton=new Button(buttonPanel,SWT.PUSH);
  deleteColumnButton.setText(Messages.deleteLabel);
  GridDataFactory.fillDefaults().applyTo(deleteColumnButton);
  deleteColumnButton.setEnabled(false);
  deleteColumnButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      RelationalColumn column=null;
      IStructuredSelection selection=(IStructuredSelection)columnsViewer.getSelection();
      for (      Object obj : selection.toArray()) {
        if (obj instanceof RelationalColumn) {
          column=(RelationalColumn)obj;
          break;
        }
      }
      if (column != null) {
        getRelationalReference().getResultSet().removeColumn(column);
        deleteColumnButton.setEnabled(false);
        handleInfoChanged();
      }
    }
  }
);
  upColumnButton=new Button(buttonPanel,SWT.PUSH);
  upColumnButton.setText(Messages.moveUpLabel);
  GridDataFactory.fillDefaults().applyTo(upColumnButton);
  upColumnButton.setEnabled(false);
  upColumnButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      RelationalColumn info=null;
      IStructuredSelection selection=(IStructuredSelection)columnsViewer.getSelection();
      for (      Object obj : selection.toArray()) {
        if (obj instanceof RelationalColumn) {
          info=(RelationalColumn)obj;
          break;
        }
      }
      if (info != null) {
        int selectedIndex=columnsViewer.getTable().getSelectionIndex();
        getRelationalReference().getResultSet().moveColumnUp(info);
        handleInfoChanged();
        columnsViewer.getTable().select(selectedIndex - 1);
        downColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnDown(info));
        upColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnUp(info));
      }
    }
  }
);
  downColumnButton=new Button(buttonPanel,SWT.PUSH);
  downColumnButton.setText(Messages.moveDownLabel);
  GridDataFactory.fillDefaults().applyTo(downColumnButton);
  downColumnButton.setEnabled(false);
  downColumnButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      RelationalColumn info=null;
      IStructuredSelection selection=(IStructuredSelection)columnsViewer.getSelection();
      for (      Object obj : selection.toArray()) {
        if (obj instanceof RelationalColumn) {
          info=(RelationalColumn)obj;
          break;
        }
      }
      if (info != null) {
        int selectedIndex=columnsViewer.getTable().getSelectionIndex();
        getRelationalReference().getResultSet().moveColumnDown(info);
        handleInfoChanged();
        columnsViewer.getTable().select(selectedIndex + 1);
        downColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnDown(info));
        upColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnUp(info));
      }
    }
  }
);
  this.columnsViewer=new TableViewer(thePanel,SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL| SWT.V_SCROLL| SWT.BORDER);
  Table columnTable=this.columnsViewer.getTable();
  columnTable.setHeaderVisible(true);
  columnTable.setLinesVisible(true);
  columnTable.setLayout(new TableLayout());
  GridDataFactory.fillDefaults().grab(true,false).hint(SWT.DEFAULT,100).applyTo(this.columnsViewer.getControl());
  TableViewerColumn column=new TableViewerColumn(this.columnsViewer,SWT.LEFT);
  column.getColumn().setText(Messages.columnNameLabel + "String_Node_Str");
  column.setEditingSupport(new ColumnNameEditingSupport(this.columnsViewer));
  column.setLabelProvider(new ColumnDataLabelProvider(0));
  column.getColumn().pack();
  column=new TableViewerColumn(this.columnsViewer,SWT.LEFT);
  column.getColumn().setText(Messages.dataTypeLabel + "String_Node_Str");
  column.setLabelProvider(new ColumnDataLabelProvider(1));
  column.setEditingSupport(new DatatypeEditingSupport(this.columnsViewer));
  column.getColumn().pack();
  column=new TableViewerColumn(this.columnsViewer,SWT.LEFT);
  column.getColumn().setText(Messages.lengthLabel);
  column.setLabelProvider(new ColumnDataLabelProvider(2));
  column.setEditingSupport(new ColumnWidthEditingSupport(this.columnsViewer));
  column.getColumn().pack();
  if (this.getRelationalReference().getResultSet() != null) {
    for (    RelationalColumn row : this.getRelationalReference().getResultSet().getColumns()) {
      this.columnsViewer.add(row);
    }
  }
  this.columnsViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    @Override public void selectionChanged(    SelectionChangedEvent event){
      IStructuredSelection sel=(IStructuredSelection)event.getSelection();
      if (sel.isEmpty()) {
        deleteColumnButton.setEnabled(false);
        upColumnButton.setEnabled(false);
        downColumnButton.setEnabled(false);
      }
 else {
        boolean enable=true;
        Object[] objs=sel.toArray();
        RelationalColumn columnInfo=null;
        for (        Object obj : objs) {
          if (!(obj instanceof RelationalColumn)) {
            enable=false;
            break;
          }
 else {
            columnInfo=(RelationalColumn)obj;
          }
        }
        if (objs.length == 0) {
          enable=false;
        }
        deleteColumnButton.setEnabled(enable);
        if (enable) {
          upColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnUp(columnInfo));
          downColumnButton.setEnabled(getRelationalReference().getResultSet().canMoveColumnDown(columnInfo));
        }
      }
    }
  }
);
  return thePanel;
}