예제 #1
0
 /** adds a file or many files depending on the value of singleSelection */
 public void showFileChooserAndAddFiles(boolean singleSelection) {
   if (panel.getMainTable().getModel().getRowCount() >= panel.getMaxSelectableFiles()) {
     JOptionPane.showMessageDialog(
         panel,
         GettextResource.gettext(
             Configuration.getInstance().getI18nResourceBundle(),
             "Selection table is full, please remove some pdf document."),
         GettextResource.gettext(
             Configuration.getInstance().getI18nResourceBundle(), "Table full"),
         JOptionPane.INFORMATION_MESSAGE);
   } else {
     if (singleSelection) {
       fileChooser.setMultiSelectionEnabled(false);
     } else {
       fileChooser.setMultiSelectionEnabled(true);
     }
     if (!(workQueue.getRunning() > 0)) {
       if (fileChooser.showOpenDialog(panel) == JFileChooser.APPROVE_OPTION) {
         if (fileChooser.isMultiSelectionEnabled()) {
           addFiles(fileChooser.getSelectedFiles(), true);
         } else {
           addFile(fileChooser.getSelectedFile());
         }
       }
     } else {
       log.info(
           GettextResource.gettext(
               Configuration.getInstance().getI18nResourceBundle(),
               "Please wait while all files are processed.."));
     }
   }
 }
예제 #2
0
  public void openFile() {
    JFileChooser choose = new JFileChooser();
    choose.setMultiSelectionEnabled(true);
    choose.setFileFilter(
        new FileFilter() {
          public boolean accept(File pathName) {
            if (pathName.isDirectory()) return true;
            return (pathName.getName().endsWith(".xls"));
          }

          public String getDescription() {
            return "Microsoft Excel (*.xls)";
          }
        });
    if (choose.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      File[] files = choose.getSelectedFiles();
      if (files.length > 0) {
        StringBuffer sb = new StringBuffer();
        sb.append(files[0]);
        for (int i = 1; i < files.length; i++) {
          sb.append(",").append(files[i]);
        }
        getTxtFile().setText(sb.toString());
      }
    }
  }
예제 #3
0
  /** Handles the clicking of the <b>Add</b> button on the GUI. */
  public void handleOpen() {
    File defaultFile = new File(PCGenSettings.getPcgDir());
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(defaultFile);

    String[] pcgs = new String[] {FILENAME_PCG, FILENAME_PCP};
    SimpleFileFilter ff =
        new SimpleFileFilter(pcgs, LanguageBundle.getString("in_pcgen_file")); // $NON-NLS-1$
    chooser.addChoosableFileFilter(ff);
    chooser.setFileFilter(ff);
    chooser.setMultiSelectionEnabled(true);
    Component component = GMGenSystem.inst;
    Cursor originalCursor = component.getCursor();
    component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    int option = chooser.showOpenDialog(GMGenSystem.inst);

    if (option == JFileChooser.APPROVE_OPTION) {
      for (File selectedFile : chooser.getSelectedFiles()) {
        if (PCGFile.isPCGenCharacterOrPartyFile(selectedFile)) {
          messageHandler.handleMessage(
              new RequestOpenPlayerCharacterMessage(this, selectedFile, false));
        }
      }
    } else {
      /* this means the file is invalid */
    }

    GMGenSystem.inst.setCursor(originalCursor);
  }
예제 #4
0
  public void doImport() {

    try {

      JFileChooser chooser = new JFileChooser();
      chooser.setDialogTitle("Select input tree file...");
      chooser.setMultiSelectionEnabled(false);
      chooser.setCurrentDirectory(frame.getWorkingDirectory());

      int returnValue = chooser.showOpenDialog(Utils.getActiveFrame());

      if (returnValue == JFileChooser.APPROVE_OPTION) {

        File file = chooser.getSelectedFile();

        if (file != null) {

          //					dataList.treeFilesList.add(file);
          treeFileNameText.setText(file.getName());

          importFromFile(file);

          File tmpDir = chooser.getCurrentDirectory();
          if (tmpDir != null) {
            frame.setWorkingDirectory(tmpDir);
          }
        } // END: file opened check
      } // END: dialog cancelled check

    } catch (IOException e) {
      e.printStackTrace();
    } catch (ImportException e) {
      e.printStackTrace();
    } // END: try-catch block
  } // END: doImport
예제 #5
0
  private java.io.File chooseSaveFile() {
    // get file name
    JFileChooser fc = new JFileChooser();
    fc.setAcceptAllFileFilterUsed(true);
    fc.setMultiSelectionEnabled(false);
    fc.setFileFilter(
        new FileFilter() {
          @Override
          public boolean accept(java.io.File pathname) {
            return pathname.isDirectory() || pathname.getName().endsWith(".osm");
          }

          @Override
          public String getDescription() {
            return tr("OSM files");
          }
        });
    int result = fc.showOpenDialog(Main.parent);

    if (result != JFileChooser.APPROVE_OPTION) {
      return null;
    } else {
      return fc.getSelectedFile();
    }
  }
  private void jMenuItemImportActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItemImportActionPerformed
    JFileChooser jfc = new JFileChooser();
    jfc.setMultiSelectionEnabled(true);
    if (lastPath != null) {
      jfc.setCurrentDirectory(lastPath);
    }
    int fileDialogReturnVal = jfc.showOpenDialog(this);

    // now select the file
    if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) {
      // add code here to allow selection of a document class

      DocumentClassDialog d = DocumentClassDialog.showClassDialog(this, this.theProject);

      DocumentClass selectedClass = d.getSelectedDocumentClass();

      File[] selected = jfc.getSelectedFiles();
      for (int i = 0; i < selected.length; i++) {
        theProject.addNewDocument(selected[i], 1.0f, selected[i].toString(), selectedClass);
      }

      docFrameTableModel.fireTableDataChanged();

      lastPath = new File(jfc.getSelectedFile().getPath());
    }
  } // GEN-LAST:event_jMenuItemImportActionPerformed
예제 #7
0
  void exportToExcel(JasperPrint jasperPrint) throws Exception {
    javax.swing.JFileChooser jfc = new javax.swing.JFileChooser("reportsample/");

    jfc.setDialogTitle("Send Report to Excel");
    jfc.setFileFilter(
        new javax.swing.filechooser.FileFilter() {
          public boolean accept(java.io.File file) {
            String filename = file.getName();
            return (filename.toLowerCase().endsWith(".xls")
                || file.isDirectory()
                || filename.toLowerCase().endsWith(".jrxml"));
          }

          public String getDescription() {
            return "Laporan *.xls";
          }
        });

    jfc.setMultiSelectionEnabled(false);

    jfc.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);
    if (jfc.showSaveDialog(null) == javax.swing.JOptionPane.OK_OPTION) {

      JExcelApiExporter exporter = new JExcelApiExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      exporter.setParameter(
          JRExporterParameter.OUTPUT_FILE_NAME,
          changeFileExtension(jfc.getSelectedFile().getPath(), "xls"));
      exporter.setParameter(JExcelApiExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
      exporter.setParameter(JExcelApiExporterParameter.IS_FONT_SIZE_FIX_ENABLED, Boolean.TRUE);
      exporter.exportReport();
    }
  }
예제 #8
0
  /** Call this to browse for a custom gradle executor. */
  private void browseForCustomGradleExecutor() {
    File startingDirectory = new File(SystemProperties.getInstance().getUserHome());
    File currentFile = gradlePluginLord.getCustomGradleExecutor();
    if (currentFile != null) {
      startingDirectory = currentFile.getAbsoluteFile();
    } else {
      if (gradlePluginLord.getCurrentDirectory() != null) {
        startingDirectory = gradlePluginLord.getCurrentDirectory();
      }
    }

    JFileChooser chooser = new JFileChooser(startingDirectory);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(false);

    File file = null;
    if (chooser.showOpenDialog(mainPanel) == JFileChooser.APPROVE_OPTION) {
      file = chooser.getSelectedFile();
    }

    if (file != null) {
      setCustomGradleExecutor(file);
    } else { // if they canceled, and they have no custom gradle executor specified, then we must
             // clear things
      // This will reset the UI back to 'not using a custom executor'. We can't have them check the
      // field and not have a value here.
      if (gradlePluginLord.getCustomGradleExecutor() == null) {
        setCustomGradleExecutor(null);
      }
    }
  }
예제 #9
0
 public void actionPerformed(ActionEvent e) {
   FileChooseTableModel model = (FileChooseTableModel) reviewTable.getModel();
   List<FileNameObj> fileNames = model.getFileNameSet();
   JFileChooser fileDialog = new JFileChooser();
   fileDialog.setMultiSelectionEnabled(true);
   int result = fileDialog.showOpenDialog(mainFrame);
   if (result == JFileChooser.APPROVE_OPTION) {
     File[] files = fileDialog.getSelectedFiles();
     for (File file : files) {
       FileNameObj fNameObj = new FileNameObj(file.getAbsolutePath());
       boolean isAdded = false;
       Iterator iter = fileNames.iterator();
       while (iter.hasNext()) {
         if (fNameObj.equals(iter.next())) {
           isAdded = true;
           break;
         }
       }
       if (!isAdded) {
         fileNames.add(fNameObj);
       }
     }
   }
   model.fireTableDataChanged();
 }
  public ExitCode showSetupDialog() {

    JFileChooser chooser = new JFileChooser();

    for (FileFilter filter : filters) chooser.setFileFilter(filter);
    chooser.setFileFilter(filters[0]);

    File lastFiles[] = getParameter(fileNames).getValue();
    if ((lastFiles != null) && (lastFiles.length > 0)) {
      File currentDir = lastFiles[0].getParentFile();
      if ((currentDir != null) && (currentDir.exists())) chooser.setCurrentDirectory(currentDir);
    }

    chooser.setMultiSelectionEnabled(true);

    int returnVal = chooser.showOpenDialog(MZmineCore.getDesktop().getMainWindow());

    if (returnVal != JFileChooser.APPROVE_OPTION) return ExitCode.CANCEL;

    File selectedFiles[] = chooser.getSelectedFiles();

    getParameter(fileNames).setValue(selectedFiles);

    return ExitCode.OK;
  }
  /** Selects a file to use as target for the report processing. */
  protected void performSelectFile() {
    if (fileChooser == null) {
      fileChooser = new JFileChooser();
      final FilesystemFilter filter =
          new FilesystemFilter(
              CSVDataExportDialog.CSV_FILE_EXTENSION,
              getResources().getString("csvexportdialog.csv-file-description")); // $NON-NLS-1$
      fileChooser.addChoosableFileFilter(filter);
      fileChooser.setMultiSelectionEnabled(false);
    }

    fileChooser.setSelectedFile(new File(getFilename()));
    final int option = fileChooser.showSaveDialog(this);
    if (option == JFileChooser.APPROVE_OPTION) {
      final File selFile = fileChooser.getSelectedFile();
      String selFileName = selFile.getAbsolutePath();

      // Test if ends on csv
      if (StringUtils.endsWithIgnoreCase(selFileName, CSVDataExportDialog.CSV_FILE_EXTENSION)
          == false) {
        selFileName = selFileName + CSVDataExportDialog.CSV_FILE_EXTENSION;
      }
      setFilename(selFileName);
    }
  }
  /**
   * Actions-handling method.
   *
   * @param e The event.
   */
  public void actionPerformed(ActionEvent e) {
    // Prepares the file chooser
    JFileChooser fc = new JFileChooser();
    fc.setCurrentDirectory(new File(idata.getInstallPath()));
    fc.setMultiSelectionEnabled(false);
    fc.addChoosableFileFilter(fc.getAcceptAllFileFilter());
    // fc.setCurrentDirectory(new File("."));

    // Shows it
    try {
      if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
        // We handle the xml data writing
        File file = fc.getSelectedFile();
        FileOutputStream out = new FileOutputStream(file);
        BufferedOutputStream outBuff = new BufferedOutputStream(out, 5120);
        parent.writeXMLTree(idata.xmlData, outBuff);
        outBuff.flush();
        outBuff.close();

        autoButton.setEnabled(false);
      }
    } catch (Exception err) {
      err.printStackTrace();
      JOptionPane.showMessageDialog(
          this,
          err.toString(),
          parent.langpack.getString("installer.error"),
          JOptionPane.ERROR_MESSAGE);
    }
  }
예제 #13
0
 public boolean saveFile(Signal sign) throws IOException {
   /* select where save */
   JFileChooser fileChooser = new JFileChooser();
   fileChooser.setDialogTitle("Choose a file");
   fileChooser.setVisible(true);
   fileChooser.setCurrentDirectory(new File(".\\files"));
   fileChooser.setMultiSelectionEnabled(false);
   int returnValue = fileChooser.showOpenDialog(null);
   if (returnValue == JFileChooser.APPROVE_OPTION) {
     file = fileChooser.getSelectedFile();
     SaveConfig sc = new SaveConfig(sign, file);
     sc.setVisible(true);
   }
   /*
    * create byte array output stream ByteArrayOutputStream bytestream =
    * new ByteArrayOutputStream(); DataOutputStream datastream = new
    * DataOutputStream(bytestream); /* write signal parameters
    */
   /*
    * datastream.writeShort(sign.getT0());
    * datastream.writeShort(sign.getF());
    * datastream.writeByte(sign.getFlag());
    * datastream.writeInt(sign.getSamples()); for (double d :
    * sign.getContent()) { datastream.writeDouble(d); }
    * datastream.writeShort(sign.getT0()); datastream.flush(); /* convert
    * to byte array and write to file
    *
    * byte[] bytes = bytestream.toByteArray(); FileOutputStream
    * fileoutputstream = new FileOutputStream(file); for (int i = 0; i <
    * bytes.length; i++) { fileoutputstream.write(bytes[i]); }
    * fileoutputstream.close(); return true;
    */
   return true;
 }
 public void loadFlameButton_clicked() {
   try {
     JFileChooser chooser = new FlameFileChooser(prefs);
     if (prefs.getInputFlamePath() != null) {
       try {
         chooser.setCurrentDirectory(new File(prefs.getInputFlamePath()));
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     }
     chooser.setMultiSelectionEnabled(true);
     if (chooser.showOpenDialog(poolFlamePreviewPnl) == JFileChooser.APPROVE_OPTION) {
       for (File file : chooser.getSelectedFiles()) {
         List<Flame> newFlames = new FlameReader(prefs).readFlames(file.getAbsolutePath());
         prefs.setLastInputFlameFile(file);
         if (newFlames != null && newFlames.size() > 0) {
           for (Flame newFlame : newFlames) {
             project.getFlames().add(validateDancingFlame(newFlame));
           }
         }
       }
       refreshProjectFlames();
       enableControls();
     }
   } catch (Throwable ex) {
     errorHandler.handleError(ex);
   }
 }
예제 #15
0
  private void onTranslation() {
    final JFileChooser fc = new JFileChooser();
    fc.setCurrentDirectory(filePath);

    fc.setMultiSelectionEnabled(false);
    final int returnVal = fc.showOpenDialog(panel);
    filePath = fc.getCurrentDirectory();

    if (returnVal == JFileChooser.APPROVE_OPTION) {
      translationFilePath = fc.getSelectedFile();

      if (fc.getName(translationFilePath).endsWith(".txt")) {
        if (translationFilePath.exists()) {
          translationDoc = fc.getName(translationFilePath);
          fieldTranslation.setText(translationFilePath.getPath());
        } else {
          JOptionPane.showMessageDialog(
              panel,
              getString("MSG.ERROR.FILE_NOTFOUND"),
              getString("MSG.ERROR"),
              JOptionPane.ERROR_MESSAGE);

          fieldTranslation.setText("");
        }
      }
      //  ToDo: remember filename by preferences
    }
  }
예제 #16
0
    public void actionPerformed(ActionEvent ev) {

      try {

        String[] logFiles = new String[] {"log"};

        JFileChooser chooser = new JFileChooser();
        chooser.setDialogTitle("Opening log file...");
        chooser.setMultiSelectionEnabled(false);
        chooser.addChoosableFileFilter(new SimpleFileFilter(logFiles, "Log files (*.log)"));
        chooser.setCurrentDirectory(workingDirectory);

        chooser.showOpenDialog(Utils.getActiveFrame());
        File file = chooser.getSelectedFile();
        logFilename = file.getAbsolutePath();
        System.out.println("Opened " + logFilename + "\n");

        File tmpDir = chooser.getCurrentDirectory();

        if (tmpDir != null) {
          workingDirectory = tmpDir;
        }

      } catch (Exception e) {
        System.err.println("Could not Open! \n");
      }
    }
  protected FileChooserPanel getFileChooserPanel() {
    // LoadFileDataSourceQueryChoosers share the same JFileChooser so that the user's
    // work is not lost when he switches data-source types. Also, the JFileChooser options
    // are set once because setting them is slow (freezes the GUI for a few seconds).
    // [Jon Aquino]
    if (blackboard().get(FILE_CHOOSER_PANEL_KEY) == null) {
      final JFileChooser fileChooser = GUIUtil.createJFileChooserWithExistenceChecking();
      fileChooser.setMultiSelectionEnabled(true);
      fileChooser.setControlButtonsAreShown(false);

      blackboard().put(FILE_CHOOSER_KEY, fileChooser);
      blackboard().put(FILE_CHOOSER_PANEL_KEY, new FileChooserPanel(fileChooser, blackboard()));

      if (PersistentBlackboardPlugIn.get(context).get(FILE_CHOOSER_DIRECTORY_KEY) != null) {
        fileChooser.setCurrentDirectory(
            new File(
                (String) PersistentBlackboardPlugIn.get(context).get(FILE_CHOOSER_DIRECTORY_KEY)));
        ((FileChooserPanel) blackboard().get(FILE_CHOOSER_PANEL_KEY))
            .setSelectedCoordinateSystem(
                (String)
                    PersistentBlackboardPlugIn.get(context)
                        .get(FILE_CHOOSER_COORDINATE_SYSTEM_KEY));
      }

      if (CoordinateSystemSupport.isEnabled(blackboard())) {
        ((FileChooserPanel) blackboard().get(FILE_CHOOSER_PANEL_KEY))
            .setCoordinateSystemComboBoxVisible(true);
      }
    }

    return (FileChooserPanel) blackboard().get(FILE_CHOOSER_PANEL_KEY);
  }
예제 #18
0
  /**
   * The implementation that the other methods delegate to. This provides the caller with all
   * available options for customizing the <tt>JFileChooser</tt> instance. If a <tt>FileDialog</tt>
   * is displayed instead of a <tt>JFileChooser</tt> (on OS X, for example), most or all of these
   * options have no effect.
   *
   * @param parent the <tt>Component</tt> that should be the dialog's parent
   * @param titleKey the key for the locale-specific string to use for the file dialog title
   * @param approveKey the key for the locale-specific string to use for the approve button text
   * @param directory the directory to open the dialog to
   * @param mode the "mode" to open the <tt>JFileChooser</tt> in from the <tt>JFileChooser</tt>
   *     class, such as <tt>JFileChooser.DIRECTORIES_ONLY</tt>
   * @param option the option to look for in the return code, such as
   *     <tt>JFileChooser.APPROVE_OPTION</tt>
   * @param allowMultiSelect true if the chooser allows multiple files to be chosen
   * @param filter the <tt>FileFilter</tt> instance for customizing the files that are displayed --
   *     if this is null, no filter is used
   * @return the selected <tt>File</tt> instance, or <tt>null</tt> if a file was not selected
   *     correctly
   */
  public static List<File> getInput(
      Component parent,
      String titleKey,
      String approveKey,
      File directory,
      int mode,
      int option,
      boolean allowMultiSelect,
      final FileFilter filter) {
    if (!OSUtils.isAnyMac()) {
      JFileChooser fileChooser = getDirectoryChooser(titleKey, approveKey, directory, mode, filter);
      fileChooser.setMultiSelectionEnabled(allowMultiSelect);
      try {
        if (fileChooser.showOpenDialog(parent) != option) return null;
      } catch (NullPointerException npe) {
        // ignore NPE.  can't do anything with it ...
        return null;
      }

      if (allowMultiSelect) {
        File[] chosen = fileChooser.getSelectedFiles();
        if (chosen.length > 0) setLastInputDirectory(chosen[0]);
        return Arrays.asList(chosen);
      } else {
        File chosen = fileChooser.getSelectedFile();
        setLastInputDirectory(chosen);
        return Collections.singletonList(chosen);
      }

    } else {
      FileDialog dialog;
      if (mode == JFileChooser.DIRECTORIES_ONLY) dialog = MacUtils.getFolderDialog();
      else dialog = new FileDialog(GUIMediator.getAppFrame(), "");

      dialog.setTitle(I18n.tr(titleKey));
      if (filter != null) {
        FilenameFilter f =
            new FilenameFilter() {
              public boolean accept(File dir, String name) {
                return filter.accept(new File(dir, name));
              }
            };
        dialog.setFilenameFilter(f);
      }

      dialog.setVisible(true);
      String dirStr = dialog.getDirectory();
      String fileStr = dialog.getFile();
      if ((dirStr == null) || (fileStr == null)) return null;
      setLastInputDirectory(new File(dirStr));
      // if the filter didn't work, pretend that the person picked
      // nothing
      File f = new File(dirStr, fileStr);
      if (filter != null && !filter.accept(f)) return null;

      return Collections.singletonList(f);
    }
  }
예제 #19
0
  /**
   * Create text panel with the specified title, text, and mode
   *
   * @param container Reference to the container of this panel
   * @param title Title for this panel, to appear in the title field of a frame, or title of a tab
   * @param filename The name of the file to be opened
   * @param type The predefined file type
   * @param project
   */
  public EPlusEditorPanel(
      Container container, String title, String filename, FileType type, JEPlusProject project) {
    initComponents();
    initRSTA(type.getRSTA_Style());
    FC.setFileFilter(type.getFileFilter());
    FC.setMultiSelectionEnabled(false);
    this.ContainerComponent = container;
    this.Title = title;
    this.CurrentFileName = filename;
    if (CurrentFileName != null) {
      this.rsTextArea.setText(getFileContent(CurrentFileName));
    }
    this.ContentType = type;
    this.ContentChanged = false;
    this.Project = project;
    switch (ContentType) {
      case IDF:
        updateSearchStrings((Project == null) ? null : Project.getSearchStrings());
        this.cmdLoad.setEnabled(true);
        this.cmdCheck.setEnabled(false);
        this.cmdSave.setEnabled(true);
        break;
      case EPW:
      case RVI:
        updateSearchStrings(null);
        this.cmdLoad.setEnabled(false);
        this.cmdCheck.setEnabled(false);
        this.cmdSave.setEnabled(true);
        break;
      case RVX:
        updateSearchStrings(RVX.quickIndex());
        this.cmdLoad.setEnabled(false);
        this.cmdCheck.setEnabled(true);
        this.cmdSave.setEnabled(true);
        break;
      case JSON:
        updateSearchStrings(null);
        this.cmdLoad.setEnabled(false);
        this.cmdCheck.setEnabled(true);
        this.cmdSave.setEnabled(false);
        break;
      case PYTHON:
      case CSV:
      case XML:
      case PLAIN:
      default:
        updateSearchStrings(null);
        this.cmdLoad.setEnabled(true);
        this.cmdCheck.setEnabled(false);
        this.cmdSave.setEnabled(true);
    }
    // this.cboSearchStrings.setEditable(true);

    this.Document = rsTextArea.getDocument();
    Document.addDocumentListener(this);
  }
 private JFileChooser createFileChooser(
     final File base, final String resourceName, final FileFilter filter) {
   final JFileChooser fc = new JFileChooser(base);
   fc.setName(resourceName);
   fc.setMultiSelectionEnabled(false);
   fc.setAcceptAllFileFilterUsed(true);
   fc.setFileFilter(filter);
   getContext().getResourceMap().injectComponents(fc);
   return fc;
 }
예제 #21
0
 private void buttonPathActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_buttonPathActionPerformed
   JFileChooser chooser = new JFileChooser();
   chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
   chooser.setMultiSelectionEnabled(false);
   chooser.setDialogTitle(
       NbBundle.getMessage(JFXSigningPanel.class, "TITLE_KeystoreBrowser")); // NOI18N
   if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) {
     File file = FileUtil.normalizeFile(chooser.getSelectedFile());
     textFieldPath.setText(file.getAbsolutePath());
   }
 } // GEN-LAST:event_buttonPathActionPerformed
예제 #22
0
  /**
   * Display a file chooser dialog box.
   *
   * @param owner <code>Component</code> which 'owns' the dialog
   * @param mode Can be either <code>OPEN</code>, <code>SCRIPT</code> or <code>SAVE</code>
   * @return The path to selected file, null otherwise
   */
  public static String chooseFile(Component owner, int mode) {
    JFileChooser chooser = getFileChooser(owner, mode);
    chooser.setMultiSelectionEnabled(false);

    if (chooser.showDialog(owner, null) == JFileChooser.APPROVE_OPTION) {
      /*Jext*/ AbstractEditorPanel.setProperty(
          "lastdir." + mode, chooser.getSelectedFile().getParent());
      return chooser.getSelectedFile().getAbsolutePath();
    } else owner.repaint();

    return null;
  }
예제 #23
0
  private JFileChooser getFileChooser() {
    if (fileChooser == null) {
      JFileChooser chooser = new JFileChooser();
      chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      chooser.setMultiSelectionEnabled(false);
      chooser.setDialogType(JFileChooser.OPEN_DIALOG);
      chooser.setDialogTitle(Bundle.SnapshotCustomizer_SelectSnapshotDialogCaption());
      fileChooser = chooser;
    }

    return fileChooser;
  }
예제 #24
0
 private void jButtonBrowserActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButtonBrowserActionPerformed
   JFrame frame = new JFrame();
   JFileChooser chooser = new JFileChooser();
   FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG & GIF Images", "jpg", "gif");
   chooser.setFileFilter(filter);
   chooser.setMultiSelectionEnabled(true);
   int returnVal = chooser.showOpenDialog(frame);
   if (returnVal == JFileChooser.APPROVE_OPTION) {
     jLabelImegaesPath.setText(getImagesName(chooser.getSelectedFiles()));
   }
 } // GEN-LAST:event_jButtonBrowserActionPerformed
예제 #25
0
 public static String chooseCSVFile() {
   JFileChooser fc = new JFileChooser(DEFAULT_DIRECTORY);
   fc.setAcceptAllFileFilterUsed(false);
   fc.addChoosableFileFilter(new CSVChooserFilter());
   fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
   fc.setMultiSelectionEnabled(false);
   int selection = fc.showOpenDialog(fc);
   if (selection == JFileChooser.APPROVE_OPTION) {
     return fc.getSelectedFile().getAbsolutePath();
   }
   return "";
 }
예제 #26
0
  @Action(block = Task.BlockingScope.APPLICATION)
  public Task add() throws IOException {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setMultiSelectionEnabled(true);

    if (fileChooser.showDialog(this, i18n.text(WorkspaceResources.create_attachment))
        == JFileChooser.APPROVE_OPTION) {
      final File[] selectedFiles = fileChooser.getSelectedFiles();

      return new AddAttachmentTask(selectedFiles);
    } else return null;
  }
예제 #27
0
  private void fileLocButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_fileLocButtonActionPerformed
    JFileChooser fileChooser = new JFileChooser();
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Zip Archive (.zip)", "zip");
    fileChooser.setFileFilter(filter);
    fileChooser.setMultiSelectionEnabled(false);

    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      loadVCardFile(fileChooser.getSelectedFile());
    }

    checkCurrentPIN();
  } // GEN-LAST:event_fileLocButtonActionPerformed
예제 #28
0
  // Builds a file selection dialog box for saving / opening an environment
  private JFileChooser getFileChooser(boolean isSave) {
    File file = new File(System.getProperty("user.home") + "/anemone/save/");
    file.mkdirs();

    JFileChooser diag = new JFileChooser(file);
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Environment (.env)", "env");
    diag.setFileFilter(filter);
    if (isSave) diag.setDialogTitle("Save Environment");
    else diag.setDialogTitle("Open Environment");
    diag.setMultiSelectionEnabled(false);

    return diag;
  }
예제 #29
0
 public static String saveAsFile() {
   JFileChooser fc = new JFileChooser(DEFAULT_DIRECTORY);
   fc.setAcceptAllFileFilterUsed(false);
   fc.addChoosableFileFilter(new CSVChooserFilter());
   //		fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   fc.setMultiSelectionEnabled(false);
   fc.setDialogTitle("Save as CSV file");
   int selection = fc.showSaveDialog(fc);
   if (selection == JFileChooser.APPROVE_OPTION) {
     return fc.getSelectedFile().getAbsolutePath();
   }
   return null;
 }
예제 #30
0
 public static String chooseCSVFolder() {
   JFileChooser fc = new JFileChooser(DEFAULT_DIRECTORY);
   fc.setAcceptAllFileFilterUsed(false);
   fc.setDialogTitle("Choose a directory containing all the series setting files");
   //		fc.addChoosableFileFilter(new CSVChooserFilter());
   fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
   fc.setMultiSelectionEnabled(false);
   int selection = fc.showOpenDialog(fc);
   if (selection == JFileChooser.APPROVE_OPTION) {
     return fc.getSelectedFile().getAbsolutePath();
   }
   return null;
 }