Program: 168106
Project: 168106
Buggy source:
/** 
 * Adds "Classify" and "Help" buttons on the Naive Bayes Classifier form
 */
private void addButtonsToToolBar(){
  IToolBarManager mgr=form.getToolBarManager();
  mgr.add(new Action(){
    @Override public ImageDescriptor getImageDescriptor(){
      return (NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImageDescriptor(IMAGE_LRUN_OBJ));
    }
    @Override public String getToolTipText(){
      return "String_Node_Str";
    }
    String classificationInputDir;
    String outputDir;
    String tempkValue;
    @Override public void run(){
      final ArrayList<String> trainingDataPaths=new ArrayList<String>();
      final HashMap<String,List<String>> tempClassPaths=new HashMap<String,List<String>>();
      final NaiveBayesClassifier nbc=new NaiveBayesClassifier();
      classPaths=new HashMap<String,List<String>>();
      consolidateSelectedFiles(classLayoutData,classPaths);
      TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
      TacitFormComposite.updateStatusMessage(getViewSite(),null,null,form);
      job=new Job("String_Node_Str"){
        @Override protected IStatus run(        IProgressMonitor monitor){
          TacitFormComposite.setConsoleViewInFocus();
          TacitFormComposite.updateStatusMessage(getViewSite(),null,null,form);
          monitor.beginTask("String_Node_Str",100);
          Date dateObj=new Date();
          Display.getDefault().syncExec(new Runnable(){
            @Override public void run(){
              outputDir=outputPath.getText();
              classificationInputDir=classifyInputText.getText();
              tempkValue=kValueText.getText();
              isPreprocessEnabled=preprocessEnabled.getSelection();
              isClassificationEnabled=classificationEnabled.getSelection();
            }
          }
);
          HashMap<Integer,String> perf;
          if (monitor.isCanceled()) {
            TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            return handledCancelRequest("String_Node_Str");
          }
          NaiveBayesClassifierWeka cv;
          int kValue=Integer.parseInt(tempkValue);
          monitor.worked(1);
          if (isPreprocessEnabled) {
            monitor.subTask("String_Node_Str");
            try {
              preprocessTask=new Preprocess("String_Node_Str");
              for (              String dirPath : classPaths.keySet()) {
                if (monitor.isCanceled()) {
                  TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                  return handledCancelRequest("String_Node_Str");
                }
                List<String> selectedFiles=classPaths.get(dirPath);
                String preprocessedDirPath=preprocessTask.doPreprocessing(selectedFiles,new File(dirPath).getName());
                trainingDataPaths.add(preprocessedDirPath);
                List<String> temp=new ArrayList<String>();
                for (                File f : new File(preprocessedDirPath).listFiles()) {
                  temp.add(f.getAbsolutePath());
                }
                tempClassPaths.put(preprocessedDirPath,temp);
                monitor.worked(1);
                if (monitor.isCanceled()) {
                  TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                  return handledCancelRequest("String_Node_Str");
                }
              }
              if (monitor.isCanceled()) {
                TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                return handledCancelRequest("String_Node_Str");
              }
              if (isClassificationEnabled) {
                ArrayList<String> files=new ArrayList<String>();
                nbc.selectAllFiles(classificationInputDir,files);
                classificationInputDir=preprocessTask.doPreprocessing(files,new File(classificationInputDir).getName());
                monitor.worked(1);
              }
              if (monitor.isCanceled()) {
                TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                return handledCancelRequest("String_Node_Str");
              }
            }
 catch (            Exception e) {
              return handleException(monitor,e,"String_Node_Str");
            }
            monitor.worked(10);
          }
 else {
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
            try {
              nbc.createTempDirectories(classPaths,trainingDataPaths,monitor);
            }
 catch (            IOException e) {
              return handleException(monitor,e,"String_Node_Str");
            }
            monitor.worked(10);
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
          }
          try {
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
            monitor.subTask("String_Node_Str");
            if (!isPreprocessEnabled) {
              cv=new NaiveBayesClassifierWeka(classPaths);
            }
 else {
              cv=new NaiveBayesClassifierWeka(tempClassPaths);
            }
            cv.initializeInstances();
            cv.doCrossValidate(kValue,monitor,dateObj);
            monitor.worked(40);
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
            if (isClassificationEnabled) {
              monitor.subTask("String_Node_Str");
              ConsoleView.printlInConsoleln("String_Node_Str");
              cv.doClassify(classificationInputDir,outputDir,monitor,dateObj);
              ConsoleView.printlInConsoleln("String_Node_Str");
            }
            monitor.worked(15);
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
            if (!isPreprocessEnabled)             nbc.deleteTempDirectories(trainingDataPaths);
            monitor.worked(10);
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
          }
 catch (          IOException e) {
            TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            return handleException(monitor,e,"String_Node_Str");
          }
catch (          EvalError e) {
            TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            return handleException(monitor,e,"String_Node_Str");
          }
catch (          Exception e) {
            e.printStackTrace();
          }
          if (monitor.isCanceled()) {
            TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            return handledCancelRequest("String_Node_Str");
          }
          if (isPreprocessEnabled) {
            preprocessTask.clean();
          }
          monitor.worked(100);
          monitor.done();
          return Status.OK_STATUS;
        }
      }
;
      job.setUser(true);
      canProceed=canItProceed(classPaths);
      if (canProceed) {
        job.schedule();
        job.addJobChangeListener(new JobChangeAdapter(){
          public void done(          IJobChangeEvent event){
            if (!event.getResult().isOK()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            }
 else {
              TacitFormComposite.updateStatusMessage(getViewSite(),"String_Node_Str",IStatus.OK,form);
              ConsoleView.printlInConsoleln("String_Node_Str");
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            }
          }
        }
);
      }
    }
  }
);
  Action helpAction=new Action(){
    @Override public ImageDescriptor getImageDescriptor(){
      return (NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImageDescriptor(IMAGE_HELP_CO));
    }
    @Override public String getToolTipText(){
      return "String_Node_Str";
    }
    @Override public void run(){
      PlatformUI.getWorkbench().getHelpSystem().displayHelp("String_Node_Str");
    }
  }
;
  mgr.add(helpAction);
  PlatformUI.getWorkbench().getHelpSystem().setHelp(helpAction,"String_Node_Str");
  PlatformUI.getWorkbench().getHelpSystem().setHelp(form,"String_Node_Str");
  form.getToolBarManager().update(true);
}

Fixed version (ground truth):
/** 
 * Adds "Classify" and "Help" buttons on the Naive Bayes Classifier form
 */
private void addButtonsToToolBar(){
  IToolBarManager mgr=form.getToolBarManager();
  mgr.add(new Action(){
    @Override public ImageDescriptor getImageDescriptor(){
      return (NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImageDescriptor(IMAGE_LRUN_OBJ));
    }
    @Override public String getToolTipText(){
      return "String_Node_Str";
    }
    String classificationInputDir;
    String outputDir;
    String tempkValue;
    @Override public void run(){
      final ArrayList<String> trainingDataPaths=new ArrayList<String>();
      final HashMap<String,List<String>> tempClassPaths=new HashMap<String,List<String>>();
      final NaiveBayesClassifier nbc=new NaiveBayesClassifier();
      classPaths=new HashMap<String,List<String>>();
      consolidateSelectedFiles(classLayoutData,classPaths);
      TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
      TacitFormComposite.updateStatusMessage(getViewSite(),null,null,form);
      job=new Job("String_Node_Str"){
        @Override protected IStatus run(        IProgressMonitor monitor){
          TacitFormComposite.setConsoleViewInFocus();
          TacitFormComposite.updateStatusMessage(getViewSite(),null,null,form);
          monitor.beginTask("String_Node_Str",100);
          Date dateObj=new Date();
          Display.getDefault().syncExec(new Runnable(){
            @Override public void run(){
              outputDir=outputPath.getText();
              classificationInputDir=classifyInputText.getText();
              tempkValue=kValueText.getText();
              isPreprocessEnabled=preprocessEnabled.getSelection();
              isClassificationEnabled=classificationEnabled.getSelection();
            }
          }
);
          HashMap<Integer,String> perf;
          if (monitor.isCanceled()) {
            TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            return handledCancelRequest("String_Node_Str");
          }
          NaiveBayesClassifierWeka cv;
          int kValue=Integer.parseInt(tempkValue);
          monitor.worked(1);
          if (isPreprocessEnabled) {
            ConsoleView.printlInConsole("String_Node_Str");
            monitor.subTask("String_Node_Str");
            try {
              preprocessTask=new Preprocess("String_Node_Str");
              for (              String dirPath : classPaths.keySet()) {
                if (monitor.isCanceled()) {
                  TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                  return handledCancelRequest("String_Node_Str");
                }
                List<String> selectedFiles=classPaths.get(dirPath);
                String preprocessedDirPath=preprocessTask.doPreprocessing(selectedFiles,new File(dirPath).getName());
                trainingDataPaths.add(preprocessedDirPath);
                List<String> temp=new ArrayList<String>();
                for (                File f : new File(preprocessedDirPath).listFiles()) {
                  temp.add(f.getAbsolutePath());
                }
                tempClassPaths.put(preprocessedDirPath,temp);
                monitor.worked(1);
                if (monitor.isCanceled()) {
                  TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                  return handledCancelRequest("String_Node_Str");
                }
              }
              if (monitor.isCanceled()) {
                TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                return handledCancelRequest("String_Node_Str");
              }
              if (isClassificationEnabled) {
                ArrayList<String> files=new ArrayList<String>();
                nbc.selectAllFiles(classificationInputDir,files);
                classificationInputDir=preprocessTask.doPreprocessing(files,new File(classificationInputDir).getName());
                monitor.worked(1);
              }
              if (monitor.isCanceled()) {
                TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                return handledCancelRequest("String_Node_Str");
              }
            }
 catch (            Exception e) {
              return handleException(monitor,e,"String_Node_Str");
            }
            monitor.worked(10);
          }
 else {
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
            try {
              nbc.createTempDirectories(classPaths,trainingDataPaths,monitor);
            }
 catch (            IOException e) {
              return handleException(monitor,e,"String_Node_Str");
            }
            monitor.worked(10);
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
          }
          try {
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
            monitor.subTask("String_Node_Str");
            if (!isPreprocessEnabled) {
              cv=new NaiveBayesClassifierWeka(classPaths);
            }
 else {
              cv=new NaiveBayesClassifierWeka(tempClassPaths);
            }
            cv.initializeInstances();
            cv.doCrossValidate(kValue,monitor,dateObj);
            monitor.worked(40);
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
            if (isClassificationEnabled) {
              monitor.subTask("String_Node_Str");
              ConsoleView.printlInConsoleln("String_Node_Str");
              cv.doClassify(classificationInputDir,outputDir,monitor,dateObj);
              ConsoleView.printlInConsoleln("String_Node_Str");
            }
            monitor.worked(15);
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
            if (!isPreprocessEnabled)             nbc.deleteTempDirectories(trainingDataPaths);
            monitor.worked(10);
            if (monitor.isCanceled()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handledCancelRequest("String_Node_Str");
            }
          }
 catch (          IOException e) {
            TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            return handleException(monitor,e,"String_Node_Str");
          }
catch (          EvalError e) {
            TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            return handleException(monitor,e,"String_Node_Str");
          }
catch (          Exception e) {
            e.printStackTrace();
          }
          if (monitor.isCanceled()) {
            TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            return handledCancelRequest("String_Node_Str");
          }
          if (isPreprocessEnabled) {
            preprocessTask.clean();
          }
          monitor.worked(100);
          monitor.done();
          return Status.OK_STATUS;
        }
      }
;
      job.setUser(true);
      canProceed=canItProceed(classPaths);
      if (canProceed) {
        job.schedule();
        job.addJobChangeListener(new JobChangeAdapter(){
          @Override public void done(          IJobChangeEvent event){
            if (!event.getResult().isOK()) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            }
 else {
              TacitFormComposite.updateStatusMessage(getViewSite(),"String_Node_Str",IStatus.OK,form);
              ConsoleView.printlInConsoleln("String_Node_Str");
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
            }
          }
        }
);
      }
    }
  }
);
  Action helpAction=new Action(){
    @Override public ImageDescriptor getImageDescriptor(){
      return (NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImageDescriptor(IMAGE_HELP_CO));
    }
    @Override public String getToolTipText(){
      return "String_Node_Str";
    }
    @Override public void run(){
      PlatformUI.getWorkbench().getHelpSystem().displayHelp("String_Node_Str");
    }
  }
;
  mgr.add(helpAction);
  PlatformUI.getWorkbench().getHelpSystem().setHelp(helpAction,"String_Node_Str");
  PlatformUI.getWorkbench().getHelpSystem().setHelp(form,"String_Node_Str");
  form.getToolBarManager().update(true);
}