Program: 70422
Project: 70422
Buggy source:
public void handleEvent(Event event){
  if (event.data instanceof ISelectDataComponent) {
    if (event.type == IChartDataSheet.EVENT_QUERY && event.detail == IChartDataSheet.DETAIL_UPDATE_COLOR) {
      refreshTableColor();
    }
    return;
  }
  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;
        boolean isSharingChart=dataProvider.checkState(IDataServiceProvider.SHARE_CHART_QUERY);
        if (header.getMenu() == null && !isSharingChart) {
          header.setMenu(createMenuManager(event.data).createContextMenu(tablePreview));
        }
        if (event.doit && !isSharingChart) {
          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);
        cmbInherit.setEnabled(getDataServiceProvider().getReportDataSet() != null);
        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);
        cmbInherit.setEnabled(false);
        setEnabledForButtons();
        updateDragDataSource();
        updatePredefinedQueries();
      }
 else       if (event.widget == cmbInherit) {
        getContext().setInheritColumnsOnly(cmbInherit.getSelectionIndex() == 1);
        fireEvent(btnBinding,EVENT_QUERY);
        refreshTablePreview();
      }
 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());
ChartReportItemUtil.reviseChartModel(ChartReportItemUtil.REVISE_REFERENCE_REPORT_ITEM,this.getContext().getModel(),itemHandle);
ChartAdapter.beginIgnoreNotifications();
if (dataProvider.checkState(IDataServiceProvider.SHARE_CHART_QUERY)) {
copyChartSeriesDefinition(ChartReportItemUtil.getChartFromHandle((ExtendedItemHandle)itemHandle.getDataBindingReference()),getChartModel());
}
ChartAdapter.endIgnoreNotifications();
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();
}
 else if (event.widget == btnShowDataPreviewA || event.widget == btnShowDataPreviewB) {
Button w=(Button)event.widget;
getContext().setShowingDataPreview(w.getSelection());
updateDragDataSource();
}
}
 catch (ChartException e1) {
WizardBase.showException(e1.getLocalizedMessage());
}
}
}

Fixed version (ground truth):
public void handleEvent(Event event){
  if (event.data instanceof ISelectDataComponent) {
    if (event.type == IChartDataSheet.EVENT_QUERY && event.detail == IChartDataSheet.DETAIL_UPDATE_COLOR) {
      refreshTableColor();
    }
    return;
  }
  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;
        boolean isSharingChart=dataProvider.checkState(IDataServiceProvider.SHARE_CHART_QUERY);
        if (header.getMenu() == null && !isSharingChart) {
          header.setMenu(createMenuManager(event.data).createContextMenu(tablePreview));
        }
        if (event.doit && !isSharingChart) {
          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) {
        refreshDataPreviewPane();
        fireEvent(btnFilters,EVENT_PREVIEW);
      }
    }
 else     if (event.widget == btnParameters) {
      if (invokeEditParameter() == Window.OK) {
        refreshDataPreviewPane();
        fireEvent(btnParameters,EVENT_PREVIEW);
      }
    }
 else     if (event.widget == btnBinding) {
      if (invokeDataBinding() == Window.OK) {
        refreshDataPreviewPane();
        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);
        cmbInherit.setEnabled(getDataServiceProvider().getReportDataSet() != null);
        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);
        cmbInherit.setEnabled(false);
        setEnabledForButtons();
        updateDragDataSource();
        updatePredefinedQueries();
      }
 else       if (event.widget == cmbInherit) {
        getContext().setInheritColumnsOnly(cmbInherit.getSelectionIndex() == 1);
        fireEvent(btnBinding,EVENT_QUERY);
        refreshDataPreviewPane();
      }
 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());
ChartReportItemUtil.reviseChartModel(ChartReportItemUtil.REVISE_REFERENCE_REPORT_ITEM,this.getContext().getModel(),itemHandle);
ChartAdapter.beginIgnoreNotifications();
if (dataProvider.checkState(IDataServiceProvider.SHARE_CHART_QUERY)) {
copyChartSeriesDefinition(ChartReportItemUtil.getChartFromHandle((ExtendedItemHandle)itemHandle.getDataBindingReference()),getChartModel());
}
ChartAdapter.endIgnoreNotifications();
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();
}
 else if (event.widget == btnShowDataPreviewA || event.widget == btnShowDataPreviewB) {
Button w=(Button)event.widget;
getContext().setShowingDataPreview(w.getSelection());
updateDragDataSource();
}
}
 catch (ChartException e1) {
WizardBase.showException(e1.getLocalizedMessage());
}
}
}