Program: 68683
Project: 68683
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().getDataSet() != null || getDataServiceProvider().getInheritedDataSet() != 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().getInheritedDataSet() != null && ChartReportItemUtil.isContainerInheritable(itemHandle));
        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);
        setEnabledForButtons();
        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().getDataSet() != null && getDataServiceProvider().getDataSet().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);
if (this.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_CHART_QUERY)) {
ChartAdapter.beginIgnoreNotifications();
this.getDataServiceProvider().update(ChartUIConstants.COPY_SERIES_DEFINITION,null);
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();
autoSelect(true);
}
 else if (event.widget == btnShowDataPreviewA || event.widget == btnShowDataPreviewB) {
Button w=(Button)event.widget;
getContext().setShowingDataPreview(Boolean.valueOf(w.getSelection()));
updateDragDataSource();
}
if (event.widget == btnInherit || event.widget == cmbDataItems) {
List<SeriesDefinition> sds=ChartUIUtil.getBaseSeriesDefinitions(getChartModel());
if (sds != null && sds.size() > 0) {
SeriesDefinition base=sds.get(0);
if (selectDataTypes.get(cmbDataItems.getSelectionIndex()).intValue() == SELECT_DATA_SET && !ChartUIConstants.TYPE_GANTT.equals(getChartModel().getType())) {
if (base.getGrouping() == null) {
base.setGrouping(SeriesGroupingImpl.create());
}
base.getGrouping().setEnabled(true);
}
 else if (ChartUIConstants.TYPE_GANTT.equals(getChartModel().getType())) {
if (base.getGrouping() != null) {
base.getGrouping().setEnabled(false);
}
}
}
}
checkColBindingForCube();
ChartWizard.removeException(ChartWizard.StaChartDSh_switch_ID);
}
 catch (ChartException e1) {
ChartWizard.showException(ChartWizard.StaChartDSh_switch_ID,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().getDataSet() != null || getDataServiceProvider().getInheritedDataSet() != 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().getInheritedDataSet() != null && ChartReportItemUtil.isContainerInheritable(itemHandle));
        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);
        setEnabledForButtons();
        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().getDataSet() != null && getDataServiceProvider().getDataSet().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);
if (this.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_CHART_QUERY)) {
ChartAdapter.beginIgnoreNotifications();
this.getDataServiceProvider().update(ChartUIConstants.COPY_SERIES_DEFINITION,null);
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());
String[] datasets=getDataServiceProvider().getAllDataSets();
currentData=datasets[datasets.length - 1];
getDataServiceProvider().setDataSet(currentData);
cmbDataItems.setText(currentData);
setEnabledForButtons();
updateDragDataSource();
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());
String[] datacubes=getDataServiceProvider().getAllDataCubes();
currentData=datacubes[datacubes.length - 1];
getDataServiceProvider().setDataCube(currentData);
cmbDataItems.setText(currentData);
updateDragDataSource();
setEnabledForButtons();
DataDefinitionTextManager.getInstance().refreshAll();
fireEvent(tablePreview,EVENT_PREVIEW);
break;
}
updatePredefinedQueries();
autoSelect(true);
}
 else if (event.widget == btnShowDataPreviewA || event.widget == btnShowDataPreviewB) {
Button w=(Button)event.widget;
getContext().setShowingDataPreview(Boolean.valueOf(w.getSelection()));
updateDragDataSource();
}
if (event.widget == btnInherit || event.widget == cmbDataItems) {
List<SeriesDefinition> sds=ChartUIUtil.getBaseSeriesDefinitions(getChartModel());
if (sds != null && sds.size() > 0) {
SeriesDefinition base=sds.get(0);
if (selectDataTypes.get(cmbDataItems.getSelectionIndex()).intValue() == SELECT_DATA_SET && !ChartUIConstants.TYPE_GANTT.equals(getChartModel().getType())) {
if (base.getGrouping() == null) {
base.setGrouping(SeriesGroupingImpl.create());
}
base.getGrouping().setEnabled(true);
}
 else if (ChartUIConstants.TYPE_GANTT.equals(getChartModel().getType())) {
if (base.getGrouping() != null) {
base.getGrouping().setEnabled(false);
}
}
}
}
checkColBindingForCube();
ChartWizard.removeException(ChartWizard.StaChartDSh_switch_ID);
}
 catch (ChartException e1) {
ChartWizard.showException(ChartWizard.StaChartDSh_switch_ID,e1.getLocalizedMessage());
}
}
}