private void browseBySourceFile() {
      enableOutputDirPanel(false);
      finishButton.setEnabled(false);

      EDFFileFilter filter = new EDFFileFilter(new String[] {extName}, description);

      JFileChooser chooser = new JFileChooser();
      chooser.setCurrentDirectory(Keywords.fileFolderChooser.getCurrentDirectory());
      chooser.setFileFilter(
          filter); // to use multiple filter, use chooser.addChoosableFileFilter(anotherFilter);
      chooser.setAcceptAllFileFilterUsed(false);
      chooser.setMultiSelectionEnabled(true);
      chooser.setFileSelectionMode(
          JFileChooser
              .FILES_ONLY); // this selection mode guarrentees the unselection of directories.
      chooser.setDialogTitle("Select EDF Files");
      Keywords.fileFolderChooser = chooser;

      int option = chooser.showOpenDialog(null);
      if (option != JFileChooser.APPROVE_OPTION) return;
      File[] choosedFiles = chooser.getSelectedFiles();
      int sz = choosedFiles.length;
      sourceFiles = new ArrayList<File>(sz);

      for (int i = 0; i < choosedFiles.length; i++) {
        sourceFiles.add(choosedFiles[i]);
      }
      fileNumber = sourceFiles.size(); // Wei Wang, 05/21/2014

      // evaluate source directory;
      sourceDirectory = sourceFiles.get(0).getParentFile();
      selectedFileCountLabel.setText("(" + sourceFiles.size() + " EDF files are selected)");
      // selectedFileCountLabel.setHorizontalAlignment(JLabel.CENTER);
      selectedFileCountLabel.setVisible(true);

      srcFilesDirField.setText(sourceDirectory.toString());

      File tempWkDirectory = Utility.parseDirNameCollision(sourceDirectory, defaultDirectoryName);
      workingDirField.setText(tempWkDirectory.getAbsolutePath());

      // workingDirField.setText(workingDirectory.toString());
      enableOutputDirPanel(true);
      finishButton.setEnabled(true);
    }
    private void browseBySourceDir() {

      EDFFileFilter filter = new EDFFileFilter(new String[] {""}, "(Directory)");
      JFileChooser chooser = new JFileChooser();
      chooser.setCurrentDirectory(Keywords.fileFolderChooser.getCurrentDirectory());
      chooser.setFileFilter(
          filter); // to use multiple filter, use chooser.addChoosableFileFilter(anotherFilter);
      chooser.setAcceptAllFileFilterUsed(false);
      chooser.setMultiSelectionEnabled(false);
      chooser.setFileSelectionMode(
          JFileChooser
              .DIRECTORIES_ONLY); // this selection mode guarrentees the selection of directories.
      chooser.setDialogTitle("Select Source Directory for EDF Files");

      int option = chooser.showOpenDialog(null);
      if (option != JFileChooser.APPROVE_OPTION) return;
      // evaluate source directory;
      sourceDirectory = chooser.getSelectedFile();
      Keywords.fileFolderChooser = chooser;

      @SuppressWarnings("unused")
      File[] dirList = sourceDirectory.listFiles();

      /**
       * Move the loop into Utility package and improve the finding algorithm. wei wang, 5/27/2014
       */
      ArrayList<File> listOfFiles = new ArrayList<File>();
      listOfFiles = Utility.findFileAddRecursive(sourceDirectory, listOfFiles);

      //            ArrayList<File> listOfDirectories = new ArrayList<File>();
      //            for (int i = 0; i < dirList.length; i++) {
      //                if (dirList[i].isFile()) {
      //                    String str = dirList[i].getName().toLowerCase();
      //                    if (str.toLowerCase().endsWith(".edf")) {
      //                        listOfFiles.add(dirList[i]);
      //                    }
      //                }
      //                if (dirList[i].isDirectory()) {
      //                    listOfDirectories.add(dirList[i]);
      //                }
      //            }
      //
      //            for (int i = 0; i < listOfDirectories.size(); i++) {
      //                dirList = listOfDirectories.get(i).listFiles();
      //                for (int j = 0; j < dirList.length; j++) {
      //                    if (dirList[j].isFile()) {
      //                        String str = dirList[j].getName().toLowerCase();
      //                        if (str.toLowerCase().endsWith(".edf")) {
      //                            listOfFiles.add(dirList[j]);
      //                        }
      //                    }
      //                }
      //            }

      sourceFiles = new ArrayList<File>(listOfFiles.size());
      for (int i = 0; i < listOfFiles.size(); i++) {
        sourceFiles.add(listOfFiles.get(i));
      }
      fileNumber = sourceFiles.size(); // Wei Wang, 05/21/2014
      scale = (int) Math.ceil(fileNumber * 1.0 / 100);
      //            if(fileNumber > 100)
      //            	scale = fileNumber / 100;

      /*
       * need to check if there is any name collision.
       * Fangping, 08/16/2010
       */
      File tempWkDirectory = Utility.parseDirNameCollision(sourceDirectory, defaultDirectoryName);
      workingDirField.setText(tempWkDirectory.getAbsolutePath()); // (workingDirectory.toString());

      activateSelectedCounterLabel(true);
      srcFilesDirField.setText(sourceDirectory.toString());
      enableOutputDirPanel(true);
      finishButton.setEnabled(true);
    }