Program: 71810
Project: 71810
Buggy source:
protected Control createDialogArea(Composite parent){
  UIUtil.bindHelp(parent,IHelpContextIds.COLUMNBINDING_DIALOG_ID);
  Composite parentComposite=(Composite)super.createDialogArea(parent);
  if (this.canSelect) {
    composite=new Composite(parentComposite,SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    composite.setLayout(UIUtil.createGridLayoutWithoutMargin(2,false));
    warnLabel=new CLabel(composite,SWT.NONE);
    warnLabel.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
    warnLabel.setText(WARN_COLUMN_BINDINGS);
    GridData gd=new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan=2;
    warnLabel.setLayoutData(gd);
    datasetRadio=new Button(composite,SWT.RADIO);
    datasetRadio.setText(LABEL_COLUMN_BINDINGS);
    datasetRadio.setLayoutData(new GridData(GridData.BEGINNING));
    datasetRadio.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent e){
        refreshBinding();
        if (datasetRadio.getSelection() && inputElement.getDataBindingType() == ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF && (DEUtil.getBindingHolder(inputElement,true) == null || DEUtil.getBindingHolder(inputElement,true).getDataBindingType() != ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF))         saveBinding();
      }
    }
);
    datasetCombo=new Combo(composite,SWT.READ_ONLY | SWT.BORDER);
    datasetCombo.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    String[] dataSets=ChoiceSetFactory.getDataSets();
    String[] newList=new String[dataSets.length + 1];
    newList[0]=NullDatasetChoice;
    System.arraycopy(dataSets,0,newList,1,dataSets.length);
    datasetCombo.setItems(newList);
    String dataSetName=getDataSetName();
    datasetCombo.deselectAll();
    if (dataSetName != null) {
      datasetCombo.setText(dataSetName);
    }
 else {
      datasetCombo.select(0);
    }
    gd=new GridData();
    gd.widthHint=250;
    datasetCombo.setLayoutData(gd);
    datasetCombo.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent event){
        saveBinding();
      }
    }
);
    reportItemRadio=new Button(composite,SWT.RADIO);
    reportItemRadio.setText(Messages.getString("String_Node_Str"));
    reportItemRadio.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent e){
        refreshBinding();
        if (reportItemRadio.getSelection() && inputElement.getDataBindingType() == ReportItemHandle.DATABINDING_TYPE_DATA && (DEUtil.getBindingHolder(inputElement,true) == null || DEUtil.getBindingHolder(inputElement,true).getDataBindingType() == ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF))         saveBinding();
      }
    }
);
    reportItemCombo=new Combo(composite,SWT.READ_ONLY | SWT.BORDER);
    reportItemCombo.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    gd=new GridData();
    gd.widthHint=250;
    reportItemCombo.setLayoutData(gd);
    reportItemCombo.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent e){
        saveBinding();
      }
    }
);
  }
  Composite contentComposite=new Composite(parentComposite,SWT.NONE);
  contentComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
  contentComposite.setLayout(UIUtil.createGridLayoutWithoutMargin(2,false));
  final Table table=new Table(contentComposite,SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER| (canSelect ? SWT.CHECK : 0));
  GridData gd=new GridData(GridData.FILL_BOTH);
  gd.heightHint=200;
  gd.verticalSpan=5;
  table.setLayoutData(gd);
  table.setLinesVisible(true);
  table.setHeaderVisible(true);
  table.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      if (e.keyCode == SWT.DEL && (DEUtil.getBindingHolder(inputElement).getDataBindingType() == ReportItemHandle.DATABINDING_TYPE_DATA || (DEUtil.getBindingHolder(inputElement).getDataBindingType() == ReportItemHandle.DATABINDING_TYPE_NONE && (DEUtil.getBindingHolder(inputElement,true) == null || DEUtil.getBindingHolder(inputElement,true).getDataBindingType() != ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF)))) {
        int itemCount=table.getItemCount();
        if (selectIndex == itemCount) {
          return;
        }
        if (selectIndex == itemCount - 1) {
          selectIndex--;
        }
        try {
          handleDelEvent();
        }
 catch (        Exception e1) {
          WidgetUtil.processError(getShell(),e1);
        }
        refreshBindingTable();
      }
    }
  }
);
  table.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      selectIndex=table.getSelectionIndex();
      updateButtons();
    }
  }
);
  table.addMouseListener(new MouseAdapter(){
    /** 
 * @param e
 */
    public void mouseDoubleClick(    MouseEvent e){
      editSelectedBinding(table.getSelectionIndex());
    }
  }
);
  String[] columns=null;
  int[] columnWidth=null;
  groups=new String[groupList.size() + 1];
  groups[0]=ALL;
  for (int i=0; i < groupList.size(); i++) {
    groups[i + 1]=((GroupHandle)groupList.get(i)).getName();
  }
  if (canAggregate) {
    columns=new String[]{null,COLUMN_NAME,COLUMN_DISPLAYNAME,COLUMN_DATATYPE,COLUMN_EXPRESSION,COLUMN_FUNCTION,COLUMN_FILTER,COLUMN_AGGREGATEON};
    columnWidth=new int[]{canSelect ? 25 : 20,100,100,70,100,100,100,100};
  }
 else {
    columns=new String[]{null,COLUMN_NAME,COLUMN_DISPLAYNAME,COLUMN_DATATYPE,COLUMN_EXPRESSION};
    columnWidth=new int[]{canSelect ? 25 : 20,150,150,70,150};
  }
  for (int i=0; i < columns.length; i++) {
    TableColumn column=new TableColumn(table,SWT.LEFT);
    column.setResizable(columns[i] != null);
    if (columns[i] != null) {
      column.setText(columns[i]);
    }
    column.setWidth(columnWidth[i]);
  }
  if (canSelect) {
    bindingTable=new CheckboxTableViewer(table);
    ((CheckboxTableViewer)bindingTable).addCheckStateListener(new ICheckStateListener(){
      public void checkStateChanged(      CheckStateChangedEvent event){
        if (event.getElement() instanceof ComputedColumnHandle) {
          ComputedColumnHandle handle=(ComputedColumnHandle)event.getElement();
          if (handle.getName().equals(selectedColumnName)) {
            selectedColumnName=null;
          }
 else {
            selectedColumnName=handle.getName();
          }
          updateSelection();
          updateButtons();
        }
 else {
          ((CheckboxTableViewer)bindingTable).setChecked(dummyChoice,false);
        }
      }
    }
);
  }
 else {
    bindingTable=new TableViewer(table);
  }
  bindingTable.setColumnProperties(columns);
  bindingTable.setContentProvider(contentProvider);
  bindingTable.setLabelProvider(labelProvider);
  bindingTable.setInput(inputElement);
  bindingTable.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      updateButtons();
    }
  }
);
  btnAdd=new Button(contentComposite,SWT.PUSH);
  btnAdd.setText(MSG_ADD);
  GridData data=new GridData();
  data.widthHint=Math.max(60,btnAdd.computeSize(SWT.DEFAULT,SWT.DEFAULT,true).x);
  btnAdd.setLayoutData(data);
  btnAdd.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      handleAddEvent();
      refreshBindingTable();
      if (table.getItemCount() > 0)       selectIndex=(table.getItemCount() - 1);
      updateButtons();
    }
  }
);
  if (canAggregate) {
    btnAddAggr=new Button(contentComposite,SWT.PUSH);
    btnAddAggr.setText(MSG_ADDAGGREGATEON);
    data=new GridData();
    data.widthHint=Math.max(60,btnAddAggr.computeSize(SWT.DEFAULT,SWT.DEFAULT,true).x);
    btnAddAggr.setLayoutData(data);
    btnAddAggr.addListener(SWT.Selection,new Listener(){
      public void handleEvent(      Event event){
        DataColumnBindingDialog dialog=new DataColumnBindingDialog(true);
        dialog.setInput(inputElement);
        dialog.setExpressionProvider(expressionProvider);
        dialog.setAggreate(true);
        if (dialog.open() == Dialog.OK) {
          if (bindingTable != null) {
            refreshBindingTable();
            bindingTable.getTable().setSelection(bindingTable.getTable().getItemCount() - 1);
          }
        }
        refreshBindingTable();
        if (table.getItemCount() > 0)         setSelectionInTable(table.getItemCount() - 1);
        updateButtons();
      }
    }
);
  }
  btnEdit=new Button(contentComposite,SWT.PUSH);
  btnEdit.setText(MSG_EDIT);
  data=new GridData();
  data.widthHint=Math.max(60,btnEdit.computeSize(SWT.DEFAULT,SWT.DEFAULT,true).x);
  btnEdit.setLayoutData(data);
  btnEdit.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      handleEditEvent();
      refreshBindingTable();
    }
  }
);
  btnDel=new Button(contentComposite,SWT.PUSH);
  btnDel.setText(MSG_DELETE);
  data=new GridData();
  data.widthHint=Math.max(60,btnDel.computeSize(SWT.DEFAULT,SWT.DEFAULT,true).x);
  btnDel.setLayoutData(data);
  btnDel.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      if (bindingTable.isCellEditorActive()) {
        bindingTable.cancelEditing();
      }
      int pos=bindingTable.getTable().getSelectionIndex();
      if (pos == -1) {
        bindingTable.getTable().setFocus();
        return;
      }
      selectIndex=pos;
      int itemCount=bindingTable.getTable().getItemCount();
      if (selectIndex == itemCount - 1) {
        selectIndex--;
      }
      try {
        handleDelEvent();
      }
 catch (      Exception e1) {
        WidgetUtil.processError(getShell(),e1);
      }
      refreshBindingTable();
    }
  }
);
  int buttonsNumber=addButtons(contentComposite,table);
  if (buttonsNumber > 0) {
    if (table.getLayoutData() instanceof GridData) {
      ((GridData)table.getLayoutData()).verticalSpan+=buttonsNumber;
    }
  }
  if (!isDataSetVisible) {
    if (composite != null)     ((GridData)composite.getLayoutData()).exclude=true;
  }
  return parentComposite;
}

Fixed version (ground truth):
protected Control createDialogArea(Composite parent){
  UIUtil.bindHelp(parent,IHelpContextIds.COLUMNBINDING_DIALOG_ID);
  Composite parentComposite=(Composite)super.createDialogArea(parent);
  if (this.canSelect) {
    composite=new Composite(parentComposite,SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    composite.setLayout(UIUtil.createGridLayoutWithoutMargin(2,false));
    warnLabel=new CLabel(composite,SWT.NONE);
    warnLabel.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
    warnLabel.setText(WARN_COLUMN_BINDINGS);
    GridData gd=new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan=2;
    warnLabel.setLayoutData(gd);
    datasetRadio=new Button(composite,SWT.RADIO);
    datasetRadio.setText(LABEL_COLUMN_BINDINGS);
    datasetRadio.setLayoutData(new GridData(GridData.BEGINNING));
    datasetRadio.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent e){
        refreshBinding();
        if (datasetRadio.getSelection() && inputElement.getDataBindingType() == ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF && (DEUtil.getBindingHolder(inputElement,true) == null || DEUtil.getBindingHolder(inputElement,true).getDataBindingType() != ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF))         saveBinding();
      }
    }
);
    datasetCombo=new Combo(composite,SWT.READ_ONLY | SWT.BORDER);
    datasetCombo.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    String[] dataSets=ChoiceSetFactory.getDataSets();
    String[] newList=new String[dataSets.length + 1];
    newList[0]=NullDatasetChoice;
    System.arraycopy(dataSets,0,newList,1,dataSets.length);
    datasetCombo.setItems(newList);
    String dataSetName=getDataSetName();
    datasetCombo.deselectAll();
    if (dataSetName != null) {
      datasetCombo.setText(dataSetName);
    }
 else {
      datasetCombo.select(0);
    }
    gd=new GridData();
    gd.widthHint=250;
    datasetCombo.setLayoutData(gd);
    datasetCombo.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent event){
        saveBinding();
      }
    }
);
    reportItemRadio=new Button(composite,SWT.RADIO);
    reportItemRadio.setText(Messages.getString("String_Node_Str"));
    reportItemRadio.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent e){
        refreshBinding();
        if (reportItemRadio.getSelection() && inputElement.getDataBindingType() == ReportItemHandle.DATABINDING_TYPE_DATA && (DEUtil.getBindingHolder(inputElement,true) == null || DEUtil.getBindingHolder(inputElement,true).getDataBindingType() == ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF))         saveBinding();
      }
    }
);
    reportItemCombo=new Combo(composite,SWT.READ_ONLY | SWT.BORDER);
    reportItemCombo.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    gd=new GridData();
    gd.widthHint=250;
    reportItemCombo.setLayoutData(gd);
    reportItemCombo.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(      SelectionEvent e){
        saveBinding();
      }
    }
);
  }
  Composite contentComposite=new Composite(parentComposite,SWT.NONE);
  contentComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
  contentComposite.setLayout(UIUtil.createGridLayoutWithoutMargin(2,false));
  final Table table=new Table(contentComposite,SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER| (canSelect ? SWT.CHECK : 0));
  GridData gd=new GridData(GridData.FILL_BOTH);
  gd.heightHint=200;
  gd.verticalSpan=5;
  table.setLayoutData(gd);
  table.setLinesVisible(true);
  table.setHeaderVisible(true);
  table.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      if (e.keyCode == SWT.DEL && (DEUtil.getBindingHolder(inputElement).getDataBindingType() == ReportItemHandle.DATABINDING_TYPE_DATA || (DEUtil.getBindingHolder(inputElement).getDataBindingType() == ReportItemHandle.DATABINDING_TYPE_NONE && (DEUtil.getBindingHolder(inputElement,true) == null || DEUtil.getBindingHolder(inputElement,true).getDataBindingType() != ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF)))) {
        int itemCount=table.getItemCount();
        if (selectIndex == itemCount) {
          return;
        }
        if (selectIndex == itemCount - 1) {
          selectIndex--;
        }
        try {
          handleDelEvent();
        }
 catch (        Exception e1) {
          WidgetUtil.processError(getShell(),e1);
        }
        refreshBindingTable();
      }
    }
  }
);
  table.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      selectIndex=table.getSelectionIndex();
      updateButtons();
    }
  }
);
  table.addMouseListener(new MouseAdapter(){
    /** 
 * @param e
 */
    public void mouseDoubleClick(    MouseEvent e){
      editSelectedBinding(table.getSelectionIndex());
      refreshBindingTable();
    }
  }
);
  String[] columns=null;
  int[] columnWidth=null;
  groups=new String[groupList.size() + 1];
  groups[0]=ALL;
  for (int i=0; i < groupList.size(); i++) {
    groups[i + 1]=((GroupHandle)groupList.get(i)).getName();
  }
  if (canAggregate) {
    columns=new String[]{null,COLUMN_NAME,COLUMN_DISPLAYNAME,COLUMN_DATATYPE,COLUMN_EXPRESSION,COLUMN_FUNCTION,COLUMN_FILTER,COLUMN_AGGREGATEON};
    columnWidth=new int[]{canSelect ? 25 : 20,100,100,70,100,100,100,100};
  }
 else {
    columns=new String[]{null,COLUMN_NAME,COLUMN_DISPLAYNAME,COLUMN_DATATYPE,COLUMN_EXPRESSION};
    columnWidth=new int[]{canSelect ? 25 : 20,150,150,70,150};
  }
  for (int i=0; i < columns.length; i++) {
    TableColumn column=new TableColumn(table,SWT.LEFT);
    column.setResizable(columns[i] != null);
    if (columns[i] != null) {
      column.setText(columns[i]);
    }
    column.setWidth(columnWidth[i]);
  }
  if (canSelect) {
    bindingTable=new CheckboxTableViewer(table);
    ((CheckboxTableViewer)bindingTable).addCheckStateListener(new ICheckStateListener(){
      public void checkStateChanged(      CheckStateChangedEvent event){
        if (event.getElement() instanceof ComputedColumnHandle) {
          ComputedColumnHandle handle=(ComputedColumnHandle)event.getElement();
          if (handle.getName().equals(selectedColumnName)) {
            selectedColumnName=null;
          }
 else {
            selectedColumnName=handle.getName();
          }
          updateSelection();
          updateButtons();
        }
 else {
          ((CheckboxTableViewer)bindingTable).setChecked(dummyChoice,false);
        }
      }
    }
);
  }
 else {
    bindingTable=new TableViewer(table);
  }
  bindingTable.setColumnProperties(columns);
  bindingTable.setContentProvider(contentProvider);
  bindingTable.setLabelProvider(labelProvider);
  bindingTable.setInput(inputElement);
  bindingTable.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      updateButtons();
    }
  }
);
  btnAdd=new Button(contentComposite,SWT.PUSH);
  btnAdd.setText(MSG_ADD);
  GridData data=new GridData();
  data.widthHint=Math.max(60,btnAdd.computeSize(SWT.DEFAULT,SWT.DEFAULT,true).x);
  btnAdd.setLayoutData(data);
  btnAdd.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      handleAddEvent();
      refreshBindingTable();
      if (table.getItemCount() > 0)       selectIndex=(table.getItemCount() - 1);
      updateButtons();
    }
  }
);
  if (canAggregate) {
    btnAddAggr=new Button(contentComposite,SWT.PUSH);
    btnAddAggr.setText(MSG_ADDAGGREGATEON);
    data=new GridData();
    data.widthHint=Math.max(60,btnAddAggr.computeSize(SWT.DEFAULT,SWT.DEFAULT,true).x);
    btnAddAggr.setLayoutData(data);
    btnAddAggr.addListener(SWT.Selection,new Listener(){
      public void handleEvent(      Event event){
        DataColumnBindingDialog dialog=new DataColumnBindingDialog(true);
        dialog.setInput(inputElement);
        dialog.setExpressionProvider(expressionProvider);
        dialog.setAggreate(true);
        if (dialog.open() == Dialog.OK) {
          if (bindingTable != null) {
            refreshBindingTable();
            bindingTable.getTable().setSelection(bindingTable.getTable().getItemCount() - 1);
          }
        }
        refreshBindingTable();
        if (table.getItemCount() > 0)         setSelectionInTable(table.getItemCount() - 1);
        updateButtons();
      }
    }
);
  }
  btnEdit=new Button(contentComposite,SWT.PUSH);
  btnEdit.setText(MSG_EDIT);
  data=new GridData();
  data.widthHint=Math.max(60,btnEdit.computeSize(SWT.DEFAULT,SWT.DEFAULT,true).x);
  btnEdit.setLayoutData(data);
  btnEdit.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      handleEditEvent();
      refreshBindingTable();
    }
  }
);
  btnDel=new Button(contentComposite,SWT.PUSH);
  btnDel.setText(MSG_DELETE);
  data=new GridData();
  data.widthHint=Math.max(60,btnDel.computeSize(SWT.DEFAULT,SWT.DEFAULT,true).x);
  btnDel.setLayoutData(data);
  btnDel.addSelectionListener(new SelectionAdapter(){
    public void widgetSelected(    SelectionEvent e){
      if (bindingTable.isCellEditorActive()) {
        bindingTable.cancelEditing();
      }
      int pos=bindingTable.getTable().getSelectionIndex();
      if (pos == -1) {
        bindingTable.getTable().setFocus();
        return;
      }
      selectIndex=pos;
      int itemCount=bindingTable.getTable().getItemCount();
      if (selectIndex == itemCount - 1) {
        selectIndex--;
      }
      try {
        handleDelEvent();
      }
 catch (      Exception e1) {
        WidgetUtil.processError(getShell(),e1);
      }
      refreshBindingTable();
    }
  }
);
  int buttonsNumber=addButtons(contentComposite,table);
  if (buttonsNumber > 0) {
    if (table.getLayoutData() instanceof GridData) {
      ((GridData)table.getLayoutData()).verticalSpan+=buttonsNumber;
    }
  }
  if (!isDataSetVisible) {
    if (composite != null)     ((GridData)composite.getLayoutData()).exclude=true;
  }
  return parentComposite;
}