Program: 71845
Project: 71845
Buggy source:
public void handleEvent(Event event){
  if (event.type == CustomPreviewTable.MOUSE_RIGHT_CLICK_TYPE) {
    if (getDataServiceProvider().getBoundDataSet() != null || getDataServiceProvider().getReportDataSet() != null) {
      if (event.widget instanceof Button) {
        Button header=(Button)event.widget;
        if (header.getMenu() == null) {
          header.setMenu(createMenuManager(event.data).createContextMenu(tablePreview));
        }
        header.getMenu().setVisible(true);
      }
    }
  }
 else   if (event.type == SWT.Selection) {
    if (event.widget instanceof MenuItem) {
      MenuItem item=(MenuItem)event.widget;
      IAction action=(IAction)item.getData();
      action.setChecked(!action.isChecked());
      action.run();
    }
 else     if (event.widget == btnFilters) {
      if (invokeEditFilter() == Window.OK) {
        refreshTablePreview();
        fireEvent(btnFilters,EVENT_PREVIEW);
      }
    }
 else     if (event.widget == btnParameters) {
      if (invokeEditParameter() == Window.OK) {
        refreshTablePreview();
        fireEvent(btnParameters,EVENT_PREVIEW);
      }
    }
 else     if (event.widget == btnBinding) {
      if (invokeDataBinding() == Window.OK) {
        refreshTablePreview();
        fireEvent(btnBinding,EVENT_PREVIEW);
      }
    }
    try {
      if (event.widget == btnInherit) {
        ColorPalette.getInstance().restore();
        if (!btnInherit.getSelection()) {
          return;
        }
        if (bIsInheritSelected) {
          return;
        }
        bIsInheritSelected=true;
        getDataServiceProvider().setReportItemReference(null);
        getDataServiceProvider().setDataSet(null);
        switchDataSet(null);
        cmbDataItems.select(0);
        currentData=null;
        cmbDataItems.setEnabled(false);
        setEnabledForButtons();
        updateDragDataSource();
        updatePredefinedQueries();
      }
 else       if (event.widget == btnUseData) {
        if (!btnUseData.getSelection()) {
          return;
        }
        if (!bIsInheritSelected) {
          return;
        }
        bIsInheritSelected=false;
        getDataServiceProvider().setReportItemReference(null);
        selectDataSet();
        cmbDataItems.setEnabled(true);
        setEnabledForButtons();
        updateDragDataSource();
        updatePredefinedQueries();
      }
 else       if (event.widget == cmbDataItems) {
        ColorPalette.getInstance().restore();
        int selectedIndex=cmbDataItems.getSelectionIndex();
        Integer selectState=selectDataTypes.get(selectedIndex);
switch (selectState.intValue()) {
case SELECT_NONE:
          btnInherit.setSelection(true);
        btnUseData.setSelection(false);
      btnInherit.notifyListeners(SWT.Selection,new Event());
    break;
case SELECT_NEXT:
  selectedIndex++;
selectState=selectDataTypes.get(selectedIndex);
cmbDataItems.select(selectedIndex);
break;
}
switch (selectState.intValue()) {
case SELECT_DATA_SET:
if (getDataServiceProvider().getReportItemReference() == null && getDataServiceProvider().getBoundDataSet() != null && getDataServiceProvider().getBoundDataSet().equals(cmbDataItems.getText())) {
return;
}
getDataServiceProvider().setDataSet(cmbDataItems.getText());
currentData=cmbDataItems.getText();
switchDataSet(cmbDataItems.getText());
setEnabledForButtons();
updateDragDataSource();
break;
case SELECT_DATA_CUBE:
getDataServiceProvider().setDataCube(cmbDataItems.getText());
currentData=cmbDataItems.getText();
updateDragDataSource();
setEnabledForButtons();
DataDefinitionTextManager.getInstance().refreshAll();
fireEvent(tablePreview,EVENT_PREVIEW);
break;
case SELECT_REPORT_ITEM:
if (cmbDataItems.getText().equals(getDataServiceProvider().getReportItemReference())) {
return;
}
getDataServiceProvider().setReportItemReference(cmbDataItems.getText());
currentData=cmbDataItems.getText();
DataDefinitionTextManager.getInstance().refreshAll();
fireEvent(tablePreview,EVENT_PREVIEW);
setEnabledForButtons();
updateDragDataSource();
break;
case SELECT_NEW_DATASET:
int result=invokeNewDataSet();
if (result == Window.CANCEL) {
return;
}
cmbDataItems.removeAll();
cmbDataItems.setItems(createDataComboItems());
cmbDataItems.setVisibleItemCount(cmbDataItems.getItemCount());
if (currentData == null) {
cmbDataItems.select(0);
}
 else {
cmbDataItems.setText(currentData);
}
break;
case SELECT_NEW_DATACUBE:
if (getDataServiceProvider().getAllDataSets().length == 0) {
invokeNewDataSet();
}
if (getDataServiceProvider().getAllDataSets().length != 0) {
new NewCubeAction().run();
}
cmbDataItems.removeAll();
cmbDataItems.setItems(createDataComboItems());
cmbDataItems.setVisibleItemCount(cmbDataItems.getItemCount());
if (currentData == null) {
cmbDataItems.select(0);
}
 else {
cmbDataItems.setText(currentData);
}
break;
}
updatePredefinedQueries();
}
}
 catch (ChartException e1) {
WizardBase.showException(e1.getLocalizedMessage());
}
}
}

Fixed version (ground truth):
public void handleEvent(Event event){
  if (event.type == CustomPreviewTable.MOUSE_RIGHT_CLICK_TYPE) {
    if (getDataServiceProvider().getBoundDataSet() != null || getDataServiceProvider().getReportDataSet() != null) {
      if (event.widget instanceof Button) {
        Button header=(Button)event.widget;
        if (header.getMenu() == null) {
          header.setMenu(createMenuManager(event.data).createContextMenu(tablePreview));
        }
        header.getMenu().setVisible(true);
      }
    }
  }
 else   if (event.type == SWT.Selection) {
    if (event.widget instanceof MenuItem) {
      MenuItem item=(MenuItem)event.widget;
      IAction action=(IAction)item.getData();
      action.setChecked(!action.isChecked());
      action.run();
    }
 else     if (event.widget == btnFilters) {
      if (invokeEditFilter() == Window.OK) {
        refreshTablePreview();
        fireEvent(btnFilters,EVENT_PREVIEW);
      }
    }
 else     if (event.widget == btnParameters) {
      if (invokeEditParameter() == Window.OK) {
        refreshTablePreview();
        fireEvent(btnParameters,EVENT_PREVIEW);
      }
    }
 else     if (event.widget == btnBinding) {
      if (invokeDataBinding() == Window.OK) {
        refreshTablePreview();
        fireEvent(btnBinding,EVENT_PREVIEW);
      }
    }
    try {
      if (event.widget == btnInherit) {
        ColorPalette.getInstance().restore();
        if (!btnInherit.getSelection()) {
          return;
        }
        if (bIsInheritSelected) {
          return;
        }
        bIsInheritSelected=true;
        getDataServiceProvider().setReportItemReference(null);
        getDataServiceProvider().setDataSet(null);
        switchDataSet(null);
        cmbDataItems.select(0);
        currentData=null;
        cmbDataItems.setEnabled(false);
        setEnabledForButtons();
        updateDragDataSource();
        updatePredefinedQueries();
      }
 else       if (event.widget == btnUseData) {
        if (!btnUseData.getSelection()) {
          return;
        }
        if (!bIsInheritSelected) {
          return;
        }
        bIsInheritSelected=false;
        getDataServiceProvider().setReportItemReference(null);
        getDataServiceProvider().setDataSet(null);
        selectDataSet();
        cmbDataItems.setEnabled(true);
        setEnabledForButtons();
        updateDragDataSource();
        updatePredefinedQueries();
      }
 else       if (event.widget == cmbDataItems) {
        ColorPalette.getInstance().restore();
        int selectedIndex=cmbDataItems.getSelectionIndex();
        Integer selectState=selectDataTypes.get(selectedIndex);
switch (selectState.intValue()) {
case SELECT_NONE:
          btnInherit.setSelection(true);
        btnUseData.setSelection(false);
      btnInherit.notifyListeners(SWT.Selection,new Event());
    break;
case SELECT_NEXT:
  selectedIndex++;
selectState=selectDataTypes.get(selectedIndex);
cmbDataItems.select(selectedIndex);
break;
}
switch (selectState.intValue()) {
case SELECT_DATA_SET:
if (getDataServiceProvider().getReportItemReference() == null && getDataServiceProvider().getBoundDataSet() != null && getDataServiceProvider().getBoundDataSet().equals(cmbDataItems.getText())) {
return;
}
getDataServiceProvider().setDataSet(cmbDataItems.getText());
currentData=cmbDataItems.getText();
switchDataSet(cmbDataItems.getText());
setEnabledForButtons();
updateDragDataSource();
break;
case SELECT_DATA_CUBE:
getDataServiceProvider().setDataCube(cmbDataItems.getText());
currentData=cmbDataItems.getText();
updateDragDataSource();
setEnabledForButtons();
DataDefinitionTextManager.getInstance().refreshAll();
fireEvent(tablePreview,EVENT_PREVIEW);
break;
case SELECT_REPORT_ITEM:
if (cmbDataItems.getText().equals(getDataServiceProvider().getReportItemReference())) {
return;
}
getDataServiceProvider().setReportItemReference(cmbDataItems.getText());
currentData=cmbDataItems.getText();
DataDefinitionTextManager.getInstance().refreshAll();
fireEvent(tablePreview,EVENT_PREVIEW);
setEnabledForButtons();
updateDragDataSource();
break;
case SELECT_NEW_DATASET:
int result=invokeNewDataSet();
if (result == Window.CANCEL) {
return;
}
cmbDataItems.removeAll();
cmbDataItems.setItems(createDataComboItems());
cmbDataItems.setVisibleItemCount(cmbDataItems.getItemCount());
if (currentData == null) {
cmbDataItems.select(0);
}
 else {
cmbDataItems.setText(currentData);
}
break;
case SELECT_NEW_DATACUBE:
if (getDataServiceProvider().getAllDataSets().length == 0) {
invokeNewDataSet();
}
if (getDataServiceProvider().getAllDataSets().length != 0) {
new NewCubeAction().run();
}
cmbDataItems.removeAll();
cmbDataItems.setItems(createDataComboItems());
cmbDataItems.setVisibleItemCount(cmbDataItems.getItemCount());
if (currentData == null) {
cmbDataItems.select(0);
}
 else {
cmbDataItems.setText(currentData);
}
break;
}
updatePredefinedQueries();
}
}
 catch (ChartException e1) {
WizardBase.showException(e1.getLocalizedMessage());
}
}
}