Program: 168092
Project: 168092
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 Preprocessor("String_Node_Str",isPreprocessEnabled);
              for (              String dirPath : classPaths.keySet()) {
                if (monitor.isCanceled()) {
                  TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                  return handledCancelRequest("String_Node_Str");
                }
                List<String> allSelectedClassFiles=classPaths.get(dirPath);
                List<Object> tempFiles=new ArrayList<Object>();
                tempFiles.addAll(allSelectedClassFiles);
                List<String> preprocessedFilePaths=preprocessTask.processData(new File(dirPath).getName(),tempFiles);
                String preProcessedClassDir=null;
                if (!preprocessedFilePaths.isEmpty())                 preProcessedClassDir=new File(preprocessedFilePaths.get(0)).getParent();
                trainingDataPaths.add(preProcessedClassDir);
                tempClassPaths.put(preProcessedClassDir,preprocessedFilePaths);
                monitor.worked(1);
              }
              if (monitor.isCanceled()) {
                TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                return handledCancelRequest("String_Node_Str");
              }
              if (isClassificationEnabled) {
                List<Object> files=new ArrayList<Object>();
                nbc.selectAllFiles(classificationInputDir,files);
                List<String> preprocessedFilePaths=preprocessTask.processData(new File(classificationInputDir).getName(),files);
                if (!preprocessedFilePaths.isEmpty())                 classificationInputDir=new File(preprocessedFilePaths.get(0)).getParent();
                monitor.worked(1);
              }
            }
 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) {
            monitor.subTask("String_Node_Str");
            try {
              preprocessTask=new Preprocessor("String_Node_Str",isPreprocessEnabled);
              for (              String dirPath : classPaths.keySet()) {
                if (monitor.isCanceled()) {
                  TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                  return handledCancelRequest("String_Node_Str");
                }
                List<String> allSelectedClassFiles=classPaths.get(dirPath);
                List<Object> tempFiles=new ArrayList<Object>();
                tempFiles.addAll(allSelectedClassFiles);
                List<String> preprocessedFilePaths=preprocessTask.processData(new File(dirPath).getName(),tempFiles);
                String preProcessedClassDir=null;
                if (!preprocessedFilePaths.isEmpty())                 preProcessedClassDir=new File(preprocessedFilePaths.get(0)).getParent();
                trainingDataPaths.add(preProcessedClassDir);
                tempClassPaths.put(preProcessedClassDir,preprocessedFilePaths);
                monitor.worked(1);
              }
              if (monitor.isCanceled()) {
                TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                return handledCancelRequest("String_Node_Str");
              }
              if (isClassificationEnabled) {
                List<Object> files=new ArrayList<Object>();
                nbc.selectAllFiles(classificationInputDir,files);
                List<String> preprocessedFilePaths=preprocessTask.processData(new File(classificationInputDir).getName(),files);
                if (!preprocessedFilePaths.isEmpty())                 classificationInputDir=new File(preprocessedFilePaths.get(0)).getParent();
                monitor.worked(1);
              }
            }
 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);
            }
            try {
              cv.initializeInstances();
              cv.doCrossValidate(kValue,monitor,dateObj);
            }
 catch (            IllegalArgumentException iae) {
              TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
              return handleException(monitor,iae,"String_Node_Str");
            }
            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");
              try {
                cv.doClassify(classificationInputDir,outputDir,monitor,dateObj);
              }
 catch (              IllegalArgumentException iae) {
                TacitFormComposite.writeConsoleHeaderBegining("String_Node_Str");
                return handleException(monitor,iae,"String_Node_Str");
              }
              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);
}