Program: 139231
Project: 139231
Buggy source:
@Override public void mouseDown(MouseEvent e){
  if (table.getMenu() != null) {
    table.getMenu().setVisible(false);
  }
  ExecutionLanguage currentEngine=analysis.getParameters().getExecutionLanguage();
  if (e.button == 3) {
    StructuredSelection selection=(StructuredSelection)tbViewer.getSelection();
    final 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);
      if (ExecutionLanguage.JAVA != currentEngine) {
        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 (isPatternFrequencyIndicator(indicator)) {
            MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
            itemCreatePatt.setText(DefaultMessagesImpl.getString("String_Node_Str"));
            itemCreatePatt.setImage(ImageLib.getImage(ImageLib.PATTERN_REG));
            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()) {
          final IDatabaseJobService service=(IDatabaseJobService)GlobalServiceRegister.getDefault().getService(IJobService.class);
          if (service != null) {
            service.setIndicator(indicator);
            service.setAnalysis(analysis);
            MenuItem item=null;
            if (isDUDIndicator(indicator)) {
              item=new MenuItem(menu,SWT.PUSH);
              item.setText(DefaultMessagesImpl.getString("String_Node_Str"));
            }
 else             if (isPatternMatchingIndicator(indicator)) {
              item=new MenuItem(menu,SWT.PUSH);
              item.setText("String_Node_Str");
            }
            if (item != null) {
              item.setImage(ImageLib.getImage(ImageLib.ICON_PROCESS));
              item.addSelectionListener(getAdapter(service));
            }
          }
        }
      }
 else       if (isDatePatternFrequencyIndicator(indicator) && ExecutionLanguage.JAVA == currentEngine) {
        final DatePatternFreqIndicator dateIndicator=(DatePatternFreqIndicator)indicator;
        MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
        itemCreatePatt.setText(DefaultMessagesImpl.getString("String_Node_Str"));
        itemCreatePatt.setImage(ImageLib.getImage(ImageLib.PATTERN_REG));
        itemCreatePatt.addSelectionListener(new SelectionAdapter(){
          @Override public void widgetSelected(          SelectionEvent e){
            DbmsLanguage language=DbmsLanguageFactory.createDbmsLanguage(analysis);
            IFolder folder=ResourceManager.getPatternRegexFolder();
            String model=dataEntity.getLabel();
            String regex=dateIndicator.getRegex(model);
            new CreatePatternAction(folder,ExpressionType.REGEXP,"String_Node_Str" + regex + "String_Node_Str",language.getDbmsName()).run();
          }
        }
);
      }
      menu.setVisible(true);
    }
  }
}

Fixed version (ground truth):
@Override public void mouseDown(MouseEvent e){
  if (table.getMenu() != null) {
    table.getMenu().setVisible(false);
  }
  if (e.button == 3) {
    StructuredSelection selection=(StructuredSelection)tbViewer.getSelection();
    final ChartDataEntity dataEntity=(ChartDataEntity)selection.getFirstElement();
    final Indicator indicator=dataEntity != null ? dataEntity.getIndicator() : null;
    if (indicator != null && dataEntity != null) {
      Menu menu=new Menu(table.getShell(),SWT.POP_UP);
      table.setMenu(menu);
      if (!isJAVALanguage) {
        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){
              String query=itemEntity.getQuery();
              String editorName=indicator.getName();
              CorePlugin.getDefault().runInDQViewer(tdDataProvider,query,editorName);
            }
          }
);
          if (isPatternFrequencyIndicator(indicator)) {
            MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
            itemCreatePatt.setText(DefaultMessagesImpl.getString("String_Node_Str"));
            itemCreatePatt.setImage(ImageLib.getImage(ImageLib.PATTERN_REG));
            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() && !isMDMAnalysis) {
          final IDatabaseJobService service=(IDatabaseJobService)GlobalServiceRegister.getDefault().getService(IJobService.class);
          if (service != null) {
            service.setIndicator(indicator);
            service.setAnalysis(analysis);
            MenuItem item=null;
            if (isDUDIndicator(indicator)) {
              item=new MenuItem(menu,SWT.PUSH);
              item.setText(DefaultMessagesImpl.getString("String_Node_Str"));
            }
 else             if (isPatternMatchingIndicator(indicator)) {
              item=new MenuItem(menu,SWT.PUSH);
              item.setText("String_Node_Str");
            }
            if (item != null) {
              item.setImage(ImageLib.getImage(ImageLib.ICON_PROCESS));
              item.addSelectionListener(getAdapter(service));
            }
          }
        }
      }
 else       if (isDatePatternFrequencyIndicator(indicator) && isJAVALanguage) {
        final DatePatternFreqIndicator dateIndicator=(DatePatternFreqIndicator)indicator;
        MenuItem itemCreatePatt=new MenuItem(menu,SWT.PUSH);
        itemCreatePatt.setText(DefaultMessagesImpl.getString("String_Node_Str"));
        itemCreatePatt.setImage(ImageLib.getImage(ImageLib.PATTERN_REG));
        itemCreatePatt.addSelectionListener(new SelectionAdapter(){
          @Override public void widgetSelected(          SelectionEvent e){
            DbmsLanguage language=DbmsLanguageFactory.createDbmsLanguage(analysis);
            IFolder folder=ResourceManager.getPatternRegexFolder();
            String model=dataEntity.getLabel();
            String regex=dateIndicator.getRegex(model);
            new CreatePatternAction(folder,ExpressionType.REGEXP,"String_Node_Str" + regex + "String_Node_Str",language.getDbmsName()).run();
          }
        }
);
      }
      menu.setVisible(true);
    }
  }
}