Program: 139595
Project: 139595
Buggy source:
public static void addMenuAndTip(final TableViewer tbViewer,final IDataExplorer explorer,final Analysis analysis){
  final Table table=tbViewer.getTable();
  table.addMouseListener(new MouseAdapter(){
    @Override public void mouseDown(    MouseEvent e){
      if (table.getMenu() != null) {
        table.getMenu().setVisible(false);
      }
      ExecutionLanguage currentEngine=analysis.getParameters().getExecutionLanguage();
      if (e.button == 3 && ExecutionLanguage.JAVA != currentEngine) {
        StructuredSelection selection=(StructuredSelection)tbViewer.getSelection();
        ChartDataEntity dataEntity=(ChartDataEntity)selection.getFirstElement();
        if (dataEntity == null) {
          return;
        }
        final Indicator indicator=dataEntity.getIndicator();
        if (indicator != null) {
          Menu menu=new Menu(table.getShell(),SWT.POP_UP);
          table.setMenu(menu);
          MenuItemEntity[] itemEntities=ChartTableMenuGenerator.generate(explorer,analysis,dataEntity);
          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){
                DataManager connection=analysis.getContext().getConnection();
                TdDataProvider tdDataProvider=SwitchHelpers.TDDATAPROVIDER_SWITCH.doSwitch(connection);
                String query=itemEntity.getQuery();
                String editorName=indicator.getName();
                CorePlugin.getDefault().runInDQViewer(tdDataProvider,query,editorName);
              }
            }
);
            if (((indicator instanceof PatternFreqIndicator || indicator instanceof PatternLowFreqIndicator))) {
              MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
              itemCreatePatt.setText(DefaultMessagesImpl.getString("String_Node_Str"));
              itemCreatePatt.addSelectionListener(new SelectionAdapter(){
                @Override public void widgetSelected(                SelectionEvent e){
                  DbmsLanguage language=DbmsLanguageFactory.createDbmsLanguage(analysis);
                  PatternTransformer pattTransformer=new PatternTransformer(language);
                  createPattern(analysis,itemEntity,pattTransformer);
                }
              }
);
            }
          }
          if (PluginChecker.isTDCPLoaded()) {
            if (indicator instanceof DuplicateCountIndicator || indicator instanceof UniqueCountIndicator || indicator instanceof DistinctCountIndicator) {
              MenuItem rmDuplicated=new MenuItem(menu,SWT.PUSH);
              rmDuplicated.setText("String_Node_Str");
              rmDuplicated.addSelectionListener(new SelectionAdapter(){
                @Override public void widgetSelected(                SelectionEvent e){
                  TdColumn column=(TdColumn)indicator.getAnalyzedElement();
                  DataManager dataManager=analysis.getContext().getConnection();
                  try {
                    IDatabaseJobService service=(IDatabaseJobService)GlobalServiceRegister.getDefault().getService(IJobService.class);
                    if (service != null) {
                      DBConnectionParameter parameter=buildParameter(dataManager);
                      service.setConnectionParameter(parameter);
                      service.setSelectedColumn(column);
                      service.executeJob();
                    }
                  }
 catch (                  Exception e2) {
                    e2.printStackTrace();
                  }
                }
                private DBConnectionParameter buildParameter(                DataManager dataManager){
                  DBConnectionParameter parameter=ParameterFactory.createDBConnectionParameter();
                  DataProvider dataProvider=(DataProvider)dataManager;
                  TdProviderConnection providerConnection=(TdProviderConnection)dataProvider.getResourceConnection().get(0);
                  Properties prop=new Properties();
                  prop.setProperty(TaggedValueHelper.USER,DataProviderHelper.getUser(providerConnection));
                  prop.setProperty(TaggedValueHelper.PASSWORD,DataProviderHelper.getClearTextPassword(providerConnection));
                  parameter.setParameters(prop);
                  parameter.setHost(DataProviderHelper.getHost(providerConnection));
                  parameter.setPort(DataProviderHelper.getPort(providerConnection));
                  parameter.setDbName(DataProviderHelper.getDBName(providerConnection));
                  parameter.setJdbcUrl(providerConnection.getConnectionString());
                  parameter.setDriverClassName(providerConnection.getDriverClassName());
                  parameter.setSqlTypeName(DataProviderHelper.getDBType(providerConnection));
                  return parameter;
                }
              }
);
            }
          }
          menu.setVisible(true);
        }
      }
    }
  }
);
  addTooltipOnTableItem(table);
}

Fixed version (ground truth):
public static void addMenuAndTip(final TableViewer tbViewer,final IDataExplorer explorer,final Analysis analysis){
  final Table table=tbViewer.getTable();
  table.addMouseListener(new MouseAdapter(){
    @Override public void mouseDown(    MouseEvent e){
      if (table.getMenu() != null) {
        table.getMenu().setVisible(false);
      }
      ExecutionLanguage currentEngine=analysis.getParameters().getExecutionLanguage();
      if (e.button == 3 && ExecutionLanguage.JAVA != currentEngine) {
        StructuredSelection selection=(StructuredSelection)tbViewer.getSelection();
        ChartDataEntity dataEntity=(ChartDataEntity)selection.getFirstElement();
        if (dataEntity == null) {
          return;
        }
        final Indicator indicator=dataEntity.getIndicator();
        if (indicator != null) {
          Menu menu=new Menu(table.getShell(),SWT.POP_UP);
          table.setMenu(menu);
          MenuItemEntity[] itemEntities=ChartTableMenuGenerator.generate(explorer,analysis,dataEntity);
          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){
                DataManager connection=analysis.getContext().getConnection();
                TdDataProvider tdDataProvider=SwitchHelpers.TDDATAPROVIDER_SWITCH.doSwitch(connection);
                String query=itemEntity.getQuery();
                String editorName=indicator.getName();
                CorePlugin.getDefault().runInDQViewer(tdDataProvider,query,editorName);
              }
            }
);
            if (((indicator instanceof PatternFreqIndicator || indicator instanceof PatternLowFreqIndicator))) {
              MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
              itemCreatePatt.setText(DefaultMessagesImpl.getString("String_Node_Str"));
              itemCreatePatt.addSelectionListener(new SelectionAdapter(){
                @Override public void widgetSelected(                SelectionEvent e){
                  DbmsLanguage language=DbmsLanguageFactory.createDbmsLanguage(analysis);
                  PatternTransformer pattTransformer=new PatternTransformer(language);
                  createPattern(analysis,itemEntity,pattTransformer);
                }
              }
);
            }
          }
          if (PluginChecker.isTDCPLoaded()) {
            if (indicator instanceof DuplicateCountIndicator || indicator instanceof UniqueCountIndicator || indicator instanceof DistinctCountIndicator) {
              MenuItem rmDuplicated=new MenuItem(menu,SWT.PUSH);
              rmDuplicated.setText("String_Node_Str");
              rmDuplicated.addSelectionListener(new SelectionAdapter(){
                @Override public void widgetSelected(                SelectionEvent e){
                  TdColumn column=(TdColumn)indicator.getAnalyzedElement();
                  DataManager dataManager=analysis.getContext().getConnection();
                  try {
                    IDatabaseJobService service=(IDatabaseJobService)GlobalServiceRegister.getDefault().getService(IJobService.class);
                    if (service != null) {
                      DBConnectionParameter parameter=buildParameter(dataManager);
                      service.setConnectionParameter(parameter);
                      service.setSelectedColumn(column);
                      service.setAnalysis(analysis);
                      service.executeJob();
                    }
                  }
 catch (                  Exception e2) {
                    e2.printStackTrace();
                  }
                }
                private DBConnectionParameter buildParameter(                DataManager dataManager){
                  DBConnectionParameter parameter=ParameterFactory.createDBConnectionParameter();
                  DataProvider dataProvider=(DataProvider)dataManager;
                  TdProviderConnection providerConnection=(TdProviderConnection)dataProvider.getResourceConnection().get(0);
                  Properties prop=new Properties();
                  prop.setProperty(TaggedValueHelper.USER,DataProviderHelper.getUser(providerConnection));
                  prop.setProperty(TaggedValueHelper.PASSWORD,DataProviderHelper.getClearTextPassword(providerConnection));
                  parameter.setParameters(prop);
                  parameter.setHost(DataProviderHelper.getHost(providerConnection));
                  parameter.setPort(DataProviderHelper.getPort(providerConnection));
                  parameter.setDbName(DataProviderHelper.getDBName(providerConnection));
                  parameter.setJdbcUrl(providerConnection.getConnectionString());
                  parameter.setDriverClassName(providerConnection.getDriverClassName());
                  parameter.setSqlTypeName(DataProviderHelper.getDBType(providerConnection));
                  return parameter;
                }
              }
);
            }
          }
          menu.setVisible(true);
        }
      }
    }
  }
);
  addTooltipOnTableItem(table);
}