Program: 136973
Project: 136973
Buggy source:
/** 
 * Add qiongli :Extract it and used by subClass(feature 19192).
 * @param chartComp
 * @param explorer
 * @param analysis
 */
protected void addMouseListenerForChart(final ChartComposite chartComp,final IDataExplorer explorer,final Analysis analysis){
  chartComp.addChartMouseListener(new ChartMouseListener(){
    @SuppressWarnings("String_Node_Str") public void chartMouseClicked(    ChartMouseEvent event){
      boolean flag=event.getTrigger().getButton() != MouseEvent.BUTTON3;
      chartComp.setDomainZoomable(flag);
      chartComp.setRangeZoomable(flag);
      final ExecutionLanguage currentEngine=analysis.getParameters().getExecutionLanguage();
      if (flag) {
        return;
      }
      ChartEntity chartEntity=event.getEntity();
      if (chartEntity != null && chartEntity instanceof CategoryItemEntity) {
        CategoryItemEntity cateEntity=(CategoryItemEntity)chartEntity;
        ICustomerDataset dataEntity=(ICustomerDataset)cateEntity.getDataset();
        final ChartDataEntity currentDataEntity=getCurrentChartDateEntity(cateEntity,dataEntity);
        if (currentDataEntity != null) {
          if (!analysis.getParameters().isStoreData()) {
            return;
          }
          if (0 == analysis.getResults().getIndicToRowMap().size()) {
            return;
          }
          Menu menu=new Menu(chartComp.getShell(),SWT.POP_UP);
          chartComp.setMenu(menu);
          final Indicator currentIndicator=currentDataEntity.getIndicator();
          AnalyzedDataSet analyDataSet=analysis.getResults().getIndicToRowMap().get(currentIndicator);
          if (analyDataSet == null || analyDataSet.getData() == null || analyDataSet.getData().size() == 0) {
            return;
          }
          int createPatternFlag=0;
          MenuItemEntity[] itemEntities=ChartTableMenuGenerator.generate(explorer,analysis,currentDataEntity);
          for (          final MenuItemEntity itemEntity : itemEntities) {
            MenuItem item=new MenuItem(menu,SWT.PUSH);
            item.setText(itemEntity.getLabel());
            item.setImage(itemEntity.getIcon());
            item.addSelectionListener(new SelectionAdapter(){
              @Override public void widgetSelected(              SelectionEvent e){
                if (ExecutionLanguage.JAVA == currentEngine) {
                  try {
                    CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new DrillDownEditorInput(analysis,currentDataEntity,itemEntity),"String_Node_Str");
                  }
 catch (                  PartInitException e1) {
                    e1.printStackTrace();
                  }
                }
 else {
                  Display.getDefault().asyncExec(new Runnable(){
                    public void run(){
                      Connection tdDataProvider=SwitchHelpers.CONNECTION_SWITCH.doSwitch(analysis.getContext().getConnection());
                      String query=itemEntity.getQuery();
                      String editorName=currentIndicator.getName();
                      SqlExplorerUtils.getDefault().runInDQViewer(tdDataProvider,query,editorName);
                    }
                  }
);
                }
              }
            }
);
            if ((currentIndicator instanceof PatternFreqIndicator || currentIndicator instanceof PatternLowFreqIndicator) && createPatternFlag == 0) {
              MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
              itemCreatePatt.setText(DefaultMessagesImpl.getString("String_Node_Str"));
              final PatternTransformer pattTransformer=new PatternTransformer(DbmsLanguageFactory.createDbmsLanguage(analysis));
              itemCreatePatt.addSelectionListener(new SelectionAdapter(){
                @Override public void widgetSelected(                SelectionEvent e){
                  Display.getDefault().asyncExec(new Runnable(){
                    public void run(){
                      ChartTableFactory.createPattern(analysis,itemEntity,pattTransformer);
                    }
                  }
);
                }
              }
);
            }
            createPatternFlag++;
          }
          ChartTableFactory.addJobGenerationMenu(menu,analysis,currentIndicator);
          menu.setVisible(true);
        }
      }
    }
    /** 
 * DOC xqliu Comment method "getCurrentChartDateEntity". bug 15745.
 * @param cateEntity
 * @param dataEntity
 * @return
 */
    @SuppressWarnings("String_Node_Str") private ChartDataEntity getCurrentChartDateEntity(    CategoryItemEntity cateEntity,    ICustomerDataset dataEntity){
      ChartDataEntity currentDataEntity=null;
      ChartDataEntity[] dataEntities=dataEntity.getDataEntities();
      if (dataEntities.length == 1) {
        currentDataEntity=dataEntities[0];
      }
 else {
        for (        ChartDataEntity entity : dataEntities) {
          if (cateEntity.getColumnKey().compareTo(entity.getLabel()) == 0) {
            currentDataEntity=entity;
          }
 else {
            if (cateEntity.getRowKey().compareTo(entity.getLabel()) == 0) {
              currentDataEntity=entity;
            }
          }
        }
      }
      return currentDataEntity;
    }
    public void chartMouseMoved(    ChartMouseEvent event){
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Add qiongli :Extract it and used by subClass(feature 19192).
 * @param chartComp
 * @param explorer
 * @param analysis
 */
protected void addMouseListenerForChart(final ChartComposite chartComp,final IDataExplorer explorer,final Analysis analysis){
  chartComp.addChartMouseListener(new ChartMouseListener(){
    @SuppressWarnings("String_Node_Str") public void chartMouseClicked(    ChartMouseEvent event){
      boolean flag=event.getTrigger().getButton() != MouseEvent.BUTTON3;
      chartComp.setDomainZoomable(flag);
      chartComp.setRangeZoomable(flag);
      final ExecutionLanguage currentEngine=analysis.getParameters().getExecutionLanguage();
      if (flag) {
        return;
      }
      ChartEntity chartEntity=event.getEntity();
      if (chartEntity != null && chartEntity instanceof CategoryItemEntity) {
        CategoryItemEntity cateEntity=(CategoryItemEntity)chartEntity;
        ICustomerDataset dataEntity=(ICustomerDataset)cateEntity.getDataset();
        final ChartDataEntity currentDataEntity=getCurrentChartDateEntity(cateEntity,dataEntity);
        if (currentDataEntity != null) {
          if (!analysis.getParameters().isStoreData()) {
            return;
          }
          if (0 == analysis.getResults().getIndicToRowMap().size()) {
            return;
          }
          Menu menu=new Menu(chartComp.getShell(),SWT.POP_UP);
          chartComp.setMenu(menu);
          final Indicator currentIndicator=currentDataEntity.getIndicator();
          AnalyzedDataSet analyDataSet=analysis.getResults().getIndicToRowMap().get(currentIndicator);
          if (analyDataSet == null || analyDataSet.getData() == null || analyDataSet.getData().size() == 0) {
            return;
          }
          int createPatternFlag=0;
          MenuItemEntity[] itemEntities=ChartTableMenuGenerator.generate(explorer,analysis,currentDataEntity);
          for (          final MenuItemEntity itemEntity : itemEntities) {
            MenuItem item=new MenuItem(menu,SWT.PUSH);
            item.setText(itemEntity.getLabel());
            item.setImage(itemEntity.getIcon());
            try {
              int mapSize=DrillDownUtils.getMapDB(currentDataEntity,analysis,itemEntity).size();
              item.setEnabled(mapSize > 0);
            }
 catch (            IOError e) {
              item.setEnabled(false);
            }
            item.addSelectionListener(new SelectionAdapter(){
              @Override public void widgetSelected(              SelectionEvent e){
                if (ExecutionLanguage.JAVA == currentEngine) {
                  try {
                    CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new DrillDownEditorInput(analysis,currentDataEntity,itemEntity),"String_Node_Str");
                  }
 catch (                  PartInitException e1) {
                    e1.printStackTrace();
                  }
                }
 else {
                  Display.getDefault().asyncExec(new Runnable(){
                    public void run(){
                      Connection tdDataProvider=SwitchHelpers.CONNECTION_SWITCH.doSwitch(analysis.getContext().getConnection());
                      String query=itemEntity.getQuery();
                      String editorName=currentIndicator.getName();
                      SqlExplorerUtils.getDefault().runInDQViewer(tdDataProvider,query,editorName);
                    }
                  }
);
                }
              }
            }
);
            if ((currentIndicator instanceof PatternFreqIndicator || currentIndicator instanceof PatternLowFreqIndicator) && createPatternFlag == 0) {
              MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
              itemCreatePatt.setText(DefaultMessagesImpl.getString("String_Node_Str"));
              final PatternTransformer pattTransformer=new PatternTransformer(DbmsLanguageFactory.createDbmsLanguage(analysis));
              itemCreatePatt.addSelectionListener(new SelectionAdapter(){
                @Override public void widgetSelected(                SelectionEvent e){
                  Display.getDefault().asyncExec(new Runnable(){
                    public void run(){
                      ChartTableFactory.createPattern(analysis,itemEntity,pattTransformer);
                    }
                  }
);
                }
              }
);
            }
            createPatternFlag++;
          }
          ChartTableFactory.addJobGenerationMenu(menu,analysis,currentIndicator);
          menu.setVisible(true);
        }
      }
    }
    /** 
 * DOC xqliu Comment method "getCurrentChartDateEntity". bug 15745.
 * @param cateEntity
 * @param dataEntity
 * @return
 */
    @SuppressWarnings("String_Node_Str") private ChartDataEntity getCurrentChartDateEntity(    CategoryItemEntity cateEntity,    ICustomerDataset dataEntity){
      ChartDataEntity currentDataEntity=null;
      ChartDataEntity[] dataEntities=dataEntity.getDataEntities();
      if (dataEntities.length == 1) {
        currentDataEntity=dataEntities[0];
      }
 else {
        for (        ChartDataEntity entity : dataEntities) {
          if (cateEntity.getColumnKey().compareTo(entity.getLabel()) == 0) {
            currentDataEntity=entity;
          }
 else {
            if (cateEntity.getRowKey().compareTo(entity.getLabel()) == 0) {
              currentDataEntity=entity;
            }
          }
        }
      }
      return currentDataEntity;
    }
    public void chartMouseMoved(    ChartMouseEvent event){
    }
  }
);
}