예제 #1
0
파일: Opener.java 프로젝트: kkkkxu/BioImage
 /**
  * Displays a JFileChooser and then opens the tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or
  * text files selected by the user. Displays error messages if one or more of the selected files
  * is not in one of the supported formats. This is the method that ImageJ's File/Open command uses
  * to open files if "Open/Save Using JFileChooser" is checked in EditOptions/Misc.
  */
 public void openMultiple() {
   Java2.setSystemLookAndFeel();
   // run JFileChooser in a separate thread to avoid possible thread deadlocks
   try {
     EventQueue.invokeAndWait(
         new Runnable() {
           public void run() {
             JFileChooser fc = new JFileChooser();
             fc.setMultiSelectionEnabled(true);
             File dir = null;
             String sdir = OpenDialog.getDefaultDirectory();
             if (sdir != null) dir = new File(sdir);
             if (dir != null) fc.setCurrentDirectory(dir);
             int returnVal = fc.showOpenDialog(IJ.getInstance());
             if (returnVal != JFileChooser.APPROVE_OPTION) return;
             omFiles = fc.getSelectedFiles();
             if (omFiles.length == 0) { // getSelectedFiles does not work on some JVMs
               omFiles = new File[1];
               omFiles[0] = fc.getSelectedFile();
             }
             omDirectory = fc.getCurrentDirectory().getPath() + File.separator;
           }
         });
   } catch (Exception e) {
   }
   if (omDirectory == null) return;
   OpenDialog.setDefaultDirectory(omDirectory);
   for (int i = 0; i < omFiles.length; i++) {
     String path = omDirectory + omFiles[i].getName();
     open(path);
     if (i == 0 && Recorder.record) Recorder.recordPath("open", path);
     if (i == 0 && !error) Menus.addOpenRecentItem(path);
   }
 }
예제 #2
0
파일: Opener.java 프로젝트: kkkkxu/BioImage
 /**
  * Displays a file open dialog box and then opens the tiff, dicom, fits, pgm, jpeg, bmp, gif, lut,
  * roi, or text file selected by the user. Displays an error message if the selected file is not
  * in a supported format. This is the method that ImageJ's File/Open command uses to open files.
  *
  * @see ij.IJ#open()
  * @see ij.IJ#open(String)
  * @see ij.IJ#openImage()
  * @see ij.IJ#openImage(String)
  */
 public void open() {
   OpenDialog od = new OpenDialog("Open", "");
   String directory = od.getDirectory();
   String name = od.getFileName();
   if (name != null) {
     String path = directory + name;
     error = false;
     open(path);
     if (!error) Menus.addOpenRecentItem(path);
   }
 }
예제 #3
0
파일: Opener.java 프로젝트: kkkkxu/BioImage
 /**
  * Opens the specified file and adds it to the File/Open Recent menu. Returns true if the file was
  * opened successfully.
  */
 public boolean openAndAddToRecent(String path) {
   open(path);
   if (!error) Menus.addOpenRecentItem(path);
   return error;
 }