Program: 136592
Project: 136592
Buggy source:
/** 
 * DOC bZhou Comment method "createChart".
 * @param comp
 * @param chartType
 * @param units
 */
private void createChart(final Composite comp,EIndicatorChartType chartType,List<IndicatorUnit> units){
  DynamicIndicatorModel dyModel=new DynamicIndicatorModel();
  Object chart=null;
  Object dataset=null;
  IEventReceiver event=EventManager.getInstance().findRegisteredEvent(units.get(0).getIndicator(),EventEnum.DQ_DYMANIC_CHART,0);
  if (event != null) {
    dataset=((DynamicChartEventReceiver)event).getDataset();
  }
  List<Indicator> indicators=null;
  dyModel.setChartType(chartType);
  this.dynamicList.add(dyModel);
  if (EIndicatorChartType.SUMMARY_STATISTICS.equals(chartType)) {
    dyModel.setSummaryIndicators(getIndicatorsForTable(units,true));
  }
  ExpandableComposite subComp=uiPagination.getToolkit().createExpandableComposite(comp,ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.EXPANDED);
  subComp.setText(chartType.getLiteral());
  subComp.setLayoutData(new GridData(GridData.FILL_BOTH));
  subComp.setExpanded(EditorPreferencePage.isUnfoldingIndicatorsResultPage());
  final Composite composite=uiPagination.getToolkit().createComposite(subComp,SWT.NULL);
  composite.setLayout(new GridLayout(2,false));
  composite.setLayoutData(new GridData(GridData.FILL_BOTH));
  Analysis analysis=masterPage.getAnalysisHandler().getAnalysis();
  ITableTypeStates tableTypeState=TableTypeStatesFactory.getInstance().getTableState(chartType,units);
  ChartDataEntity[] dataEntities=tableTypeState.getDataEntity();
  TableWithData chartData=new TableWithData(chartType,dataEntities);
  TableViewer tableviewer=tableTypeState.getTableForm(composite);
  tableviewer.setInput(chartData);
  tableviewer.getTable().pack();
  dyModel.setTableViewer(tableviewer);
  DataExplorer dataExplorer=tableTypeState.getDataExplorer();
  ChartTableFactory.addMenuAndTip(tableviewer,dataExplorer,analysis);
  if (EIndicatorChartType.TEXT_STATISTICS.equals(chartType) && dataEntities != null && dataEntities.length > 0) {
    indicators=getIndicators(dataEntities);
  }
 else {
    indicators=getIndicators(units);
  }
  dyModel.setIndicatorList(indicators);
  try {
    if (!EditorPreferencePage.isHideGraphicsForResultPage() && TOPChartUtils.getInstance().isTOPChartInstalled()) {
      IChartTypeStates chartTypeState=ChartTypeStatesFactory.getChartState(chartType,units);
      boolean isPattern=chartTypeState instanceof PatternStatisticsState;
      if (event == null) {
        chart=chartTypeState.getChart();
        if (chart != null && isSQLMode) {
          if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType)) {
            dataset=TOPChartUtils.getInstance().getDatasetFromChart(chart,1);
            dyModel.setSecondDataset(TOPChartUtils.getInstance().getDatasetFromChart(chart,0));
          }
 else {
            dataset=TOPChartUtils.getInstance().getDatasetFromChart(chart,-1);
          }
        }
      }
 else {
        chart=chartTypeState.getChart(dataset);
      }
      dyModel.setDataset(dataset);
      if (chart != null) {
        if (!isPattern) {
          TOPChartUtils.getInstance().decorateChart(chart,false);
        }
 else {
          TOPChartUtils.getInstance().decoratePatternMatching(chart);
        }
        Object chartComposite=TOPChartUtils.getInstance().createTalendChartComposite(composite,SWT.NONE,chart,true);
        if (EIndicatorChartType.SUMMARY_STATISTICS.equals(chartType)) {
          dyModel.setBawParentChartComp(chartComposite);
        }
        Map<String,Object> menuMap=createMenuForAllDataEntity(((Composite)chartComposite).getShell(),dataExplorer,analysis,((ICustomerDataset)chartTypeState.getDataset()).getDataEntities());
        if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType) || EIndicatorChartType.FREQUENCE_STATISTICS.equals(chartType)) {
          TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite,menuMap,false);
        }
 else {
          TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite,menuMap,true);
        }
      }
    }
  }
 catch (  Error e) {
    log.error(DefaultMessagesImpl.getString("String_Node_Str"),e);
  }
catch (  Exception exp) {
    log.error(DefaultMessagesImpl.getString("String_Node_Str"),exp);
  }
  subComp.setClient(composite);
  subComp.addExpansionListener(new ExpansionAdapter(){
    @Override public void expansionStateChanged(    ExpansionEvent e){
      form.reflow(true);
    }
  }
);
  masterPage.registerSection(subComp);
}

Fixed version (ground truth):
/** 
 * DOC bZhou Comment method "createChart".
 * @param comp
 * @param chartType
 * @param units
 */
private void createChart(final Composite comp,EIndicatorChartType chartType,List<IndicatorUnit> units){
  DynamicIndicatorModel dyModel=new DynamicIndicatorModel();
  Object chart=null;
  Object dataset=null;
  IEventReceiver event=EventManager.getInstance().findRegisteredEvent(units.get(0).getIndicator(),EventEnum.DQ_DYMANIC_CHART,0);
  if (event != null) {
    dataset=((DynamicChartEventReceiver)event).getDataset();
  }
  List<Indicator> indicators=null;
  dyModel.setChartType(chartType);
  this.dynamicList.add(dyModel);
  if (EIndicatorChartType.SUMMARY_STATISTICS.equals(chartType)) {
    dyModel.setSummaryIndicators(getIndicatorsForTable(units,true));
  }
  ExpandableComposite subComp=uiPagination.getToolkit().createExpandableComposite(comp,ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.EXPANDED);
  subComp.setText(chartType.getLiteral());
  subComp.setLayoutData(new GridData(GridData.FILL_BOTH));
  subComp.setExpanded(EditorPreferencePage.isUnfoldingIndicatorsResultPage());
  final Composite composite=uiPagination.getToolkit().createComposite(subComp,SWT.NULL);
  composite.setLayout(new GridLayout(2,false));
  composite.setLayoutData(new GridData(GridData.FILL_BOTH));
  Analysis analysis=masterPage.getAnalysisHandler().getAnalysis();
  ITableTypeStates tableTypeState=TableTypeStatesFactory.getInstance().getTableState(chartType,units);
  ChartDataEntity[] dataEntities=tableTypeState.getDataEntity();
  TableWithData chartData=new TableWithData(chartType,dataEntities);
  TableViewer tableviewer=tableTypeState.getTableForm(composite);
  tableviewer.setInput(chartData);
  tableviewer.getTable().pack();
  dyModel.setTableViewer(tableviewer);
  DataExplorer dataExplorer=tableTypeState.getDataExplorer();
  ChartTableFactory.addMenuAndTip(tableviewer,dataExplorer,analysis);
  if (EIndicatorChartType.TEXT_STATISTICS.equals(chartType) && dataEntities != null && dataEntities.length > 0) {
    indicators=getIndicators(dataEntities);
  }
 else {
    indicators=getIndicators(units);
  }
  dyModel.setIndicatorList(indicators);
  try {
    if (!EditorPreferencePage.isHideGraphicsForResultPage() && TOPChartUtils.getInstance().isTOPChartInstalled()) {
      IChartTypeStates chartTypeState=ChartTypeStatesFactory.getChartState(chartType,units);
      boolean isPattern=chartTypeState instanceof PatternStatisticsState;
      if (event == null) {
        chart=chartTypeState.getChart();
        if (chart != null && isSQLMode) {
          if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType)) {
            dataset=TOPChartUtils.getInstance().getDatasetFromChart(chart,2);
            if (dataset == null) {
              dataset=TOPChartUtils.getInstance().getDatasetFromChart(chart,1);
            }
            dyModel.setSecondDataset(TOPChartUtils.getInstance().getDatasetFromChart(chart,0));
          }
 else {
            dataset=TOPChartUtils.getInstance().getDatasetFromChart(chart,1);
            if (dataset == null) {
              dataset=TOPChartUtils.getInstance().getDatasetFromChart(chart,-1);
            }
          }
        }
      }
 else {
        chart=chartTypeState.getChart(dataset);
      }
      dyModel.setDataset(dataset);
      if (chart != null) {
        if (!isPattern) {
          TOPChartUtils.getInstance().decorateChart(chart,false);
        }
 else {
          TOPChartUtils.getInstance().decoratePatternMatching(chart);
        }
        Object chartComposite=TOPChartUtils.getInstance().createTalendChartComposite(composite,SWT.NONE,chart,true);
        dyModel.setBawParentChartComp(chartComposite);
        Map<String,Object> menuMap=createMenuForAllDataEntity(((Composite)chartComposite).getShell(),dataExplorer,analysis,((ICustomerDataset)chartTypeState.getDataset()).getDataEntities());
        if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType) || EIndicatorChartType.FREQUENCE_STATISTICS.equals(chartType)) {
          TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite,menuMap,false);
        }
 else {
          TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite,menuMap,true);
        }
      }
    }
  }
 catch (  Error e) {
    log.error(DefaultMessagesImpl.getString("String_Node_Str"),e);
  }
catch (  Exception exp) {
    log.error(DefaultMessagesImpl.getString("String_Node_Str"),exp);
  }
  subComp.setClient(composite);
  subComp.addExpansionListener(new ExpansionAdapter(){
    @Override public void expansionStateChanged(    ExpansionEvent e){
      form.reflow(true);
    }
  }
);
  masterPage.registerSection(subComp);
}