Program: 168206
Project: 168206
Buggy source:
/** 
 * Creates a input section for Naive Bayes Classifier
 * @param parent - Parent composite
 * @param toolkit
 * @param layout - The layout to be applied on the section
 * @param title - Title for the section
 * @param description - Description for the section.
 */
private void createInputSection(final Composite parent,FormToolkit toolkit,GridLayout layout,String title,String description){
  Section section=toolkit.createSection(parent,Section.TITLE_BAR | Section.EXPANDED | Section.DESCRIPTION);
  GridDataFactory.fillDefaults().grab(true,false).span(1,1).applyTo(section);
  GridLayoutFactory.fillDefaults().numColumns(3).applyTo(section);
  section.setText(title);
  section.setDescription(description);
  GridData gd=new GridData(SWT.FILL,SWT.FILL,true,true);
  section.setLayoutData(gd);
  Composite client=toolkit.createComposite(section,SWT.NONE);
  client.setLayout(layout);
  NlputilsFormComposite.createEmptyRow(toolkit,client);
  trainingClassPathTree=new Tree(client,SWT.MULTI);
  GridData gd_tree=new GridData(SWT.FILL,SWT.FILL,true,false,1,0);
  gd_tree.heightHint=100;
  trainingClassPathTree.setLayoutData(gd_tree);
  final TreeItem trainingItem=new TreeItem(trainingClassPathTree,SWT.NULL);
  trainingItem.setText("String_Node_Str");
  trainingItem.setData("String_Node_Str");
  trainingClassPathTree.addListener(SWT.Expand,new Listener(){
    @Override public void handleEvent(    Event event){
      TreeItem root=(TreeItem)event.item;
      File file=new File(root.getData().toString());
      File[] files=file.listFiles();
      if (files == null) {
        return;
      }
 else {
        root.getItems()[0].dispose();
      }
      for (int i=0; i < files.length; i++) {
        TreeItem item=new TreeItem(root,SWT.NULL);
        item.setText(files[i].getName());
        item.setData(files[i]);
        item.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FILE_OBJ));
        if (files[i].isDirectory()) {
          item.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FOLDER_OBJ));
          new TreeItem(item,SWT.NULL);
        }
      }
    }
  }
);
  testingClassPathTree=new Tree(client,SWT.MULTI);
  testingClassPathTree.setLayoutData(gd_tree);
  final TreeItem testingItem=new TreeItem(testingClassPathTree,SWT.NULL);
  testingItem.setText("String_Node_Str");
  testingItem.setData("String_Node_Str");
  testingClassPathTree.addListener(SWT.Expand,new Listener(){
    @Override public void handleEvent(    Event event){
      TreeItem root=(TreeItem)event.item;
      File file=new File(root.getData().toString());
      File[] files=file.listFiles();
      if (files == null) {
        return;
      }
 else {
        root.getItems()[0].dispose();
      }
      for (int i=0; i < files.length; i++) {
        TreeItem item=new TreeItem(root,SWT.NULL);
        item.setText(files[i].getName());
        item.setData(files[i]);
        item.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FILE_OBJ));
        if (files[i].isDirectory()) {
          item.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FOLDER_OBJ));
          new TreeItem(item,SWT.NULL);
        }
      }
    }
  }
);
  Composite buttonComposite=new Composite(client,SWT.NONE);
  GridLayout buttonLayout=new GridLayout();
  buttonLayout.marginWidth=buttonLayout.marginHeight=0;
  buttonLayout.makeColumnsEqualWidth=true;
  buttonComposite.setLayout(buttonLayout);
  buttonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  Button addClassButton=new Button(buttonComposite,SWT.PUSH);
  addClassButton.setText("String_Node_Str");
  GridDataFactory.fillDefaults().grab(false,false).span(1,1).applyTo(addClassButton);
  addClassButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      Shell shell=parent.getShell();
      ClassifierDialog cDialog=new ClassifierDialog(shell);
      cDialog.create();
      if (cDialog.open() == Window.OK) {
        File file=null;
        TreeItem trainingSubItem=new TreeItem(trainingItem,SWT.NULL);
        trainingSubItem.setText("String_Node_Str" + "String_Node_Str" + cDialog.getTrainDataPath());
        trainingSubItem.setData(cDialog.getTrainDataPath());
        trainingSubItem.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FILE_OBJ));
        file=new File(cDialog.getTrainDataPath());
        if (file.isDirectory()) {
          trainingSubItem.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FOLDER_OBJ));
          new TreeItem(trainingSubItem,SWT.NULL);
        }
        TreeItem testingSubItem=new TreeItem(testingItem,SWT.NONE);
        testingSubItem.setText("String_Node_Str" + "String_Node_Str" + cDialog.getTestDataPath());
        testingSubItem.setData(cDialog.getTestDataPath());
        testingSubItem.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FILE_OBJ));
        file=new File(cDialog.getTestDataPath());
        if (file.isDirectory()) {
          testingSubItem.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FOLDER_OBJ));
          new TreeItem(testingSubItem,SWT.NULL);
        }
        trainingClassPathTree.getItems()[0].setExpanded(true);
        testingClassPathTree.getItems()[0].setExpanded(true);
      }
    }
  }
);
  Button removeClassButton=new Button(buttonComposite,SWT.PUSH);
  removeClassButton.setText("String_Node_Str");
  GridDataFactory.fillDefaults().grab(false,false).span(1,1).applyTo(removeClassButton);
  removeClassButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      TreeItem[] tempSelected=trainingClassPathTree.getSelection();
      for (      TreeItem ti : tempSelected) {
        int index=getIndex(ti);
        if (-1 != index) {
          testingClassPathTree.getItems()[0].getItem(index).dispose();
          ti.dispose();
        }
      }
    }
  }
);
  section.setClient(client);
}

Fixed version (ground truth):
/** 
 * Creates a input section for Naive Bayes Classifier
 * @param parent - Parent composite
 * @param toolkit
 * @param layout - The layout to be applied on the section
 * @param title - Title for the section
 * @param description - Description for the section.
 */
private void createInputSection(final Composite parent,FormToolkit toolkit,GridLayout layout,String title,String description){
  Section section=toolkit.createSection(parent,Section.TITLE_BAR | Section.EXPANDED | Section.DESCRIPTION);
  GridDataFactory.fillDefaults().grab(true,false).span(1,1).applyTo(section);
  GridLayoutFactory.fillDefaults().numColumns(3).applyTo(section);
  section.setText(title);
  section.setDescription(description);
  GridData gd=new GridData(SWT.FILL,SWT.FILL,true,true);
  section.setLayoutData(gd);
  Composite client=toolkit.createComposite(section,SWT.NONE);
  client.setLayout(layout);
  NlputilsFormComposite.createEmptyRow(toolkit,client);
  trainingClassPathTree=new Tree(client,SWT.MULTI);
  GridData gd_tree=new GridData(SWT.FILL,SWT.FILL,true,false,1,0);
  gd_tree.heightHint=100;
  trainingClassPathTree.setLayoutData(gd_tree);
  final TreeItem trainingItem=new TreeItem(trainingClassPathTree,SWT.NULL);
  trainingItem.setText("String_Node_Str");
  trainingItem.setData("String_Node_Str");
  trainingClassPathTree.addListener(SWT.Expand,new Listener(){
    @Override public void handleEvent(    Event event){
      TreeItem root=(TreeItem)event.item;
      File file=new File(root.getData().toString());
      File[] files=file.listFiles();
      if (files == null) {
        return;
      }
 else {
        root.getItems()[0].dispose();
      }
      for (int i=0; i < files.length; i++) {
        TreeItem item=new TreeItem(root,SWT.NULL);
        item.setText(files[i].getName());
        item.setData(files[i]);
        item.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FILE_OBJ));
        if (files[i].isDirectory()) {
          item.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FOLDER_OBJ));
          new TreeItem(item,SWT.NULL);
        }
      }
    }
  }
);
  testingClassPathTree=new Tree(client,SWT.MULTI);
  testingClassPathTree.setLayoutData(gd_tree);
  final TreeItem testingItem=new TreeItem(testingClassPathTree,SWT.NULL);
  testingItem.setText("String_Node_Str");
  testingItem.setData("String_Node_Str");
  testingClassPathTree.addListener(SWT.Expand,new Listener(){
    @Override public void handleEvent(    Event event){
      TreeItem root=(TreeItem)event.item;
      File file=new File(root.getData().toString());
      File[] files=file.listFiles();
      if (files == null) {
        return;
      }
 else {
        root.getItems()[0].dispose();
      }
      for (int i=0; i < files.length; i++) {
        TreeItem item=new TreeItem(root,SWT.NULL);
        item.setText(files[i].getName());
        item.setData(files[i]);
        item.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FILE_OBJ));
        if (files[i].isDirectory()) {
          item.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FOLDER_OBJ));
          new TreeItem(item,SWT.NULL);
        }
      }
    }
  }
);
  Composite buttonComposite=new Composite(client,SWT.NONE);
  GridLayout buttonLayout=new GridLayout();
  buttonLayout.marginWidth=buttonLayout.marginHeight=0;
  buttonLayout.makeColumnsEqualWidth=true;
  buttonComposite.setLayout(buttonLayout);
  buttonComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  Button addClassButton=new Button(buttonComposite,SWT.PUSH);
  addClassButton.setText("String_Node_Str");
  GridDataFactory.fillDefaults().grab(false,false).span(1,1).applyTo(addClassButton);
  addClassButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      Shell shell=parent.getShell();
      ClassifierDialog cDialog=new ClassifierDialog(shell);
      cDialog.create();
      if (cDialog.open() == Window.OK) {
        File file=null;
        TreeItem trainingSubItem=new TreeItem(trainingItem,SWT.NULL);
        trainingSubItem.setText("String_Node_Str" + "String_Node_Str" + cDialog.getTrainDataPath());
        trainingSubItem.setData(cDialog.getTrainDataPath());
        trainingSubItem.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FILE_OBJ));
        file=new File(cDialog.getTrainDataPath());
        if (file.isDirectory()) {
          trainingSubItem.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FOLDER_OBJ));
          new TreeItem(trainingSubItem,SWT.NULL);
        }
        TreeItem testingSubItem=new TreeItem(testingItem,SWT.NONE);
        String tempClassname="String_Node_Str";
        if (!cDialog.getTestDataPath().isEmpty())         tempClassname=cDialog.getTestDataPath();
        testingSubItem.setText("String_Node_Str" + "String_Node_Str" + tempClassname);
        testingSubItem.setData(cDialog.getTestDataPath());
        if (!tempClassname.equalsIgnoreCase("String_Node_Str")) {
          testingSubItem.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FILE_OBJ));
        }
        file=new File(cDialog.getTestDataPath());
        if (file.isDirectory()) {
          testingSubItem.setImage(NaiveBayesClassifierViewImageRegistry.getImageIconFactory().getImage(IMAGE_FOLDER_OBJ));
          new TreeItem(testingSubItem,SWT.NULL);
        }
        trainingClassPathTree.getItems()[0].setExpanded(true);
        testingClassPathTree.getItems()[0].setExpanded(true);
        form.getMessageManager().removeMessage("String_Node_Str");
        form.getMessageManager().removeMessage("String_Node_Str");
      }
    }
  }
);
  Button removeClassButton=new Button(buttonComposite,SWT.PUSH);
  removeClassButton.setText("String_Node_Str");
  GridDataFactory.fillDefaults().grab(false,false).span(1,1).applyTo(removeClassButton);
  removeClassButton.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      TreeItem[] tempSelected=trainingClassPathTree.getSelection();
      for (      TreeItem ti : tempSelected) {
        int index=getIndex(ti);
        if (-1 != index) {
          testingClassPathTree.getItems()[0].getItem(index).dispose();
          ti.dispose();
        }
      }
    }
  }
);
  section.setClient(client);
}