List of usage examples for javax.swing JFileChooser setAcceptAllFileFilterUsed
@BeanProperty(preferred = true, description = "Sets whether the AcceptAll FileFilter is used as an available choice in the choosable filter list.") public void setAcceptAllFileFilterUsed(boolean b)
AcceptAll FileFilter
is used as an available choice in the choosable filter list. From source file:org.martus.client.swingui.FxInSwingMainWindow.java
private JFileChooser createFileChooser(String title, File directory, Vector<FormatFilter> filters) { JFileChooser fileChooser = new JFileChooser(directory); fileChooser.setDialogTitle(title);//from ww w. ja v a2 s .com filters.forEach(filter -> fileChooser.addChoosableFileFilter(filter)); // NOTE: Apparently the all file filter has a Mac bug, so this is a workaround fileChooser.setAcceptAllFileFilterUsed(false); return fileChooser; }
From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void loadPositiveNegativeNT() throws IOException { JFileChooser chooser = new JFileChooser("Load multiple nt files. Please choose a directory"); chooser.setCurrentDirectory(frame.defaultDirectory); if (geoFile != null) { chooser.setCurrentDirectory(geoFile); }//from w ww. j a va 2s. com chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); int returnVal = chooser.showSaveDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { System.out.print("Loading..."); frame.loadPositiveNegativeNT(chooser.getSelectedFile()); System.out.println("loading finished."); } }
From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void savePositiveNegativeNT() throws IOException { JFileChooser chooser = new JFileChooser("Save as multiple nt files. Please choose a directory"); chooser.setCurrentDirectory(frame.defaultDirectory); if (geoFile != null) { chooser.setCurrentDirectory(geoFile); }//from w w w . j a v a2 s .co m chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); int returnVal = chooser.showSaveDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { frame.savePositiveNegativeNT(chooser.getSelectedFile()); } }
From source file:ch.tatool.app.export.FileDataExporter.java
private String getStorageDirectory(Component parentFrame) { JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new FileFilter() { @Override/*from w ww . j a v a2 s . c o m*/ public String getDescription() { return "CSV (*.csv)"; } @Override public boolean accept(File f) { if (f.isDirectory()) { return true; } String extension = getExtension(f); if (extension != null) { if (extension.equals("csv")) { return true; } else { return false; } } return false; } }); chooser.setAcceptAllFileFilterUsed(false); // chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setMultiSelectionEnabled(false); int returnVal = chooser.showSaveDialog(parentFrame); if (returnVal == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile(); String filename = ""; if (f == null) { throw new RuntimeException(); } String extension = getExtension(f); if (extension == null || !getExtension(f).equals("csv")) { filename = f + ".csv"; } else { filename = f.getPath(); } return filename; } else { return null; } }
From source file:it.staiger.jmeter.protocol.http.config.gui.DynamicFilePanel.java
/** * opens a dialog box to choose a file and returns selected file's * folder./*from www . j a v a2 s. c o m*/ * * @return a new File object of selected folder */ private String browseAndGetFolderPath() { String path = folder.getText(); if (path.isEmpty()) path = FileDialoger.getLastJFCDirectory(); JFileChooser chooser = new JFileChooser(new File(path)); chooser.setDialogTitle("select folder");// $NON-NLS-1$ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(GuiPackage.getInstance().getMainFrame()) == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); FileDialoger.setLastJFCDirectory(path); } return path; }
From source file:SciTK.Plot.java
/** * Save data for generic plot to file /*from w w w .j a v a2s . co m*/ */ public void saveData() { JFileChooser fc = new JFileChooser(); fc.addChoosableFileFilter(new ExtensionFileFilter("CSV", new String[] { "csv,CSV" })); // remove default option: fc.setAcceptAllFileFilterUsed(false); // Select a file using the JFileChooser dialog: int fc_return = fc.showSaveDialog(this); if (fc_return == JFileChooser.APPROVE_OPTION) // user wants to save { //get the file name from the filter: File save_file = fc.getSelectedFile(); // check to see if the user entered an extension: if (!save_file.getName().endsWith(".csv") && !save_file.getName().endsWith(".CSV")) { save_file = new File(save_file.getAbsolutePath() + ".csv"); } // create a string to save String s = toString(); // IO inside a try/catch try { // Create a File Writer FileWriter fw = new FileWriter(save_file); fw.write(s); fw.close(); } // If there was an error, launch an error dialog box: catch (IOException e) { DialogError emsg = new DialogError(this, " There was an error saving the file." + System.getProperty("line.separator") + e.getMessage()); } } }
From source file:gui.TheGui.java
private String saveAs() { final JFileChooser fc = new JFileChooser(); fc.setMultiSelectionEnabled(false);/*from w w w . j ava2 s .c o m*/ fc.setAcceptAllFileFilterUsed(false); OpenFileFilter m3u_filter = new OpenFileFilter(".m3u", "*.m3u, Playlist in m3u format"); OpenFileFilter xspf_filter = new OpenFileFilter(".xspf", "*.xspf, Playlist in xspf format"); if (playlistType == PlaylistType.M3U) { fc.addChoosableFileFilter(new OpenFileFilter(".m3u", "*.m3u, Playlist in m3u format")); } else { fc.addChoosableFileFilter(new OpenFileFilter(".xspf", "*.xspf, Playlist in xspf format")); } int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); filePath = file.getPath(); jTextArea1.append("Saving: " + file.getName() + "." + newline); if (playlistType == PlaylistType.M3U) { return file.getPath() + ".m3u"; } else { return file.getPath() + ".xspf"; } } else { jTextArea1.append("Save command cancelled by user." + newline); return null; } }
From source file:org.pgptool.gui.ui.encryptone.EncryptOnePm.java
public SaveFileChooserDialog getTargetFileChooser() { if (targetFileChooser == null) { targetFileChooser = new SaveFileChooserDialog(findRegisteredWindowIfAny(), "action.chooseTargetFile", "action.choose", appProps, "EncryptionTargetChooser") { @Override//from ww w. ja va 2 s . com protected String onDialogClosed(String filePathName, JFileChooser ofd) { String ret = super.onDialogClosed(filePathName, ofd); if (ret != null) { targetFile.setValueByOwner(ret); } return ret; } @Override protected void onFileChooserPostConstrct(JFileChooser ofd) { ofd.setAcceptAllFileFilterUsed(false); ofd.addChoosableFileFilter(new FileNameExtensionFilter("GPG Files (.pgp)", "pgp")); // NOTE: Should we support other extensions?.... ofd.addChoosableFileFilter(ofd.getAcceptAllFileFilter()); ofd.setFileFilter(ofd.getChoosableFileFilters()[0]); } @Override protected void suggestTarget(JFileChooser ofd) { String sourceFileStr = sourceFile.getValue(); if (StringUtils.hasText(targetFile.getValue())) { use(ofd, targetFile.getValue()); } else if (encryptionDialogParameters != null && encryptionDialogParameters.getTargetFile() != null) { if (encryptionDialogParameters.getSourceFile().equals(sourceFile.getValue())) { use(ofd, encryptionDialogParameters.getTargetFile()); } else { use(ofd, madeUpTargetFileName(sourceFile.getValue(), FilenameUtils .getFullPathNoEndSeparator(encryptionDialogParameters.getTargetFile()))); } } else if (StringUtils.hasText(sourceFileStr) && new File(sourceFileStr).exists()) { String basePath = FilenameUtils.getFullPathNoEndSeparator(sourceFileStr); ofd.setCurrentDirectory(new File(basePath)); ofd.setSelectedFile(new File(madeUpTargetFileName(sourceFileStr, basePath))); } } private void use(JFileChooser ofd, String filePathName) { ofd.setCurrentDirectory(new File(FilenameUtils.getFullPathNoEndSeparator(filePathName))); ofd.setSelectedFile(new File(filePathName)); } }; } return targetFileChooser; }
From source file:gui.TheGui.java
private String saveAs() { final JFileChooser fc = new JFileChooser(); fc.setMultiSelectionEnabled(false);/*from w w w. ja v a2s .co m*/ fc.setAcceptAllFileFilterUsed(false); OpenFileFilter m3u_filter = new OpenFileFilter(".m3u", "*.m3u, Playlist in m3u format"); OpenFileFilter xspf_filter = new OpenFileFilter(".xspf", "*.xspf, Playlist in xspf format"); if (playlistType == PlaylistType.M3U) fc.addChoosableFileFilter(new OpenFileFilter(".m3u", "*.m3u, Playlist in m3u format")); else fc.addChoosableFileFilter(new OpenFileFilter(".xspf", "*.xspf, Playlist in xspf format")); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); filePath = file.getPath(); jTextArea1.append("Saving: " + file.getName() + "." + newline); if (playlistType == PlaylistType.M3U) return file.getPath() + ".m3u"; else return file.getPath() + ".xspf"; } else { jTextArea1.append("Save command cancelled by user." + newline); return null; } }
From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java
private void saveReference(boolean mustSupportEvaluation, boolean includeEvaluation) throws FileNotFoundException { Set<ReferenceFormat> formats = mustSupportEvaluation ? ReferenceFormats.REFERENCE_FORMATS.evaluationIncludingFormats : ReferenceFormats.REFERENCE_FORMATS.formats; formats.retainAll(ReferenceFormats.REFERENCE_FORMATS.writeableFormats); ReferenceFormat format = formatChooser(formats); if (format == null) { return;//from w w w.j a v a 2 s.co m } JFileChooser chooser = new JFileChooser("Save reference. Please choose a file."); chooser.setCurrentDirectory(frame.defaultDirectory); chooser.setFileSelectionMode( format.readsDirectory() ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_ONLY); if (format.getFileExtension() != null) { chooser.addChoosableFileFilter( new FilesystemFilter(format.getFileExtension(), format.getDescription())); } else { chooser.setAcceptAllFileFilterUsed(true); } int returnVal = chooser.showSaveDialog(frame); if (returnVal != JFileChooser.APPROVE_OPTION) return; System.out.print("Saving..."); format.writeReference(frame.reference, chooser.getSelectedFile(), includeEvaluation); //frame.loadPositiveNegativeNT(chooser.getSelectedFile()); System.out.println("saving finished."); }