/** * Prompts the user to choose a file from their filesystems for our own * devious uses. This method maintains the last directory the user visited * before dismissing the dialog. This does NOT imply they actually chose a * file from that directory, only that they closed the dialog there. It is * the caller's responsibility to check to see if the selected file is * non-null. * @param filename The name of a file with path. If the filename points * to an existing file, the directory in which it lies, will be used * as the starting point for the returned JFileChooser. * * @return the JFileChooser that interacted with the user, after they are * finished using it - null if no file was chosen * @see #promptToOpenFile() */ public static JFileChooser promptToSaveFile(String filename) { return promptToSaveFile(filename, null); }
/** * Prompts the user to choose a file or a directory from their filesystems for our own * devious uses. This method maintains the last directory the user visited * before dismissing the dialog. This does NOT imply they actually chose a * file from that directory, only that they closed the dialog there. It is * the caller's responsibility to check to see if the selected file is * non-null. * * @return the JFileChooser that interacted with the user, after they are * finished using it - null if no file was chosen */ public static JFileChooser promptToOpenFile() { return promptToOpenFile((String)null); }
try { final String [] _txt={".txt"}; //$NON-NLS-1$ final JFileChooser dialog = FileDialoger.promptToOpenFile(_txt); if (dialog != null) { tableModel.manager.addFile(dialog.getSelectedFile().getAbsolutePath()); final JFileChooser chooser = FileDialoger.promptToSaveFile("auth.txt"); //$NON-NLS-1$ if (chooser != null) { tableModel.manager.save(chooser.getSelectedFile().getAbsolutePath());
clearFileFilters(); if (extensions != null) { jfc.addChoosableFileFilter(new JMeterFileFilter(extensions));
reportError("Unexpected error. {}", ex, true); FileDialoger.setLastJFCDirectory(f.getParentFile().getAbsolutePath()); guiPackage.updateCurrentGui(); guiPackage.getMainFrame().repaint();
} else if (action.equals(LOAD_COMMAND)) { try { final JFileChooser chooser = FileDialoger.promptToOpenFile(); if (chooser != null) { headerManager.addFile(chooser.getSelectedFile().getAbsolutePath()); final JFileChooser chooser = FileDialoger.promptToSaveFile(null); if (chooser != null) { headerManager.save(chooser.getSelectedFile().getAbsolutePath());
clearFileFilters(); if(exts != null && exts.length > 0) { JMeterFileFilter currentFilter = new JMeterFileFilter(exts);
@Override public void actionPerformed(ActionEvent ev) { if (ev.getSource() == saveTable) { JFileChooser chooser = FileDialoger.promptToSaveFile("summary.csv");//$NON-NLS-1$ if (chooser == null) { return; } try (FileOutputStream fo = new FileOutputStream(chooser.getSelectedFile()); OutputStreamWriter writer = new OutputStreamWriter(fo, Charset.forName("UTF-8"))) { CSVSaveService.saveCSVStats(StatGraphVisualizer.getAllTableData(model, FORMATS),writer, saveHeaders.isSelected() ? StatGraphVisualizer.getLabels(COLUMNS) : null); } catch (IOException e) { JMeterUtils.reportErrorToUser(e.getMessage(), "Error saving data"); } } } }
try { final String [] _txt={".txt"}; //$NON-NLS-1$ final JFileChooser chooser = FileDialoger.promptToOpenFile(_txt); if (chooser != null) { CookieManager manager = new CookieManager(); final JFileChooser chooser = FileDialoger.promptToSaveFile("cookies.txt"); //$NON-NLS-1$ if (chooser != null) { ((CookieManager) createTestElement()).save(chooser.getSelectedFile().getAbsolutePath());
/** * Prompts the user to choose a file or a directory from their filesystems for our own * devious uses. This method maintains the last directory the user visited * before dismissing the dialog. This does NOT imply they actually chose a * file from that directory, only that they closed the dialog there. It is * the caller's responsibility to check to see if the selected file is * non-null. * @param existingFileName The name of a file with path. If the filename points * to an existing file, the directory in which it lies, will be used * as the starting point for the returned JFileChooser. * * @return the JFileChooser that interacted with the user, after they are * finished using it - null if no file was chosen */ public static JFileChooser promptToOpenFile(String existingFileName) { return promptToOpenFile(new String[0], existingFileName); }
@Override public void actionPerformed(ActionEvent ev) { if (ev.getSource() == saveTable) { JFileChooser chooser = FileDialoger.promptToSaveFile("aggregate.csv");//$NON-NLS-1$ if (chooser == null) { return; } try (FileOutputStream fo = new FileOutputStream(chooser.getSelectedFile()); OutputStreamWriter writer = new OutputStreamWriter(fo, Charset.forName("UTF-8"))){ CSVSaveService.saveCSVStats(StatGraphVisualizer.getAllTableData(model, StatGraphVisualizer.getFormatters()), writer, saveHeaders.isSelected() ? StatGraphVisualizer.getLabels(StatGraphVisualizer.getColumns()) : null); } catch (IOException e) { JMeterUtils.reportErrorToUser(e.getMessage(), "Error saving data"); } } } }
/** * Prompts the user to choose a file or a directory from their filesystems for our own * devious uses. This method maintains the last directory the user visited * before dismissing the dialog. This does NOT imply they actually chose a * file from that directory, only that they closed the dialog there. It is * the caller's responsibility to check to see if the selected file is * non-null. * @param exts The list of allowed file extensions. If empty, any * file extension is allowed * * @return the JFileChooser that interacted with the user, after they are * finished using it - null if no file was chosen */ public static JFileChooser promptToOpenFile(String[] exts) { return promptToOpenFile(exts, null); }
@Override public void actionPerformed(ActionEvent ev) { if (ev.getSource() == saveTable) { JFileChooser chooser = FileDialoger .promptToSaveFile("synthesis.csv"); if (chooser == null) { return; } FileWriter writer = null; try { writer = new FileWriter(chooser.getSelectedFile()); // TODO // Charset ? CSVSaveService.saveCSVStats(getAllDataAsTable(model, FORMATS, getLabels(COLUMNS)), writer, saveHeaders.isSelected()); } catch (IOException e) { log.warn(e.getMessage()); } finally { JOrphanUtils.closeQuietly(writer); } } }
/** * Prompts the user to choose a file or a directory from their filesystems for our own * devious uses. This method maintains the last directory the user visited * before dismissing the dialog. This does NOT imply they actually chose a * file from that directory, only that they closed the dialog there. It is * the caller's responsibility to check to see if the selected file is * non-null. * @param exts The list of allowed file extensions. If empty, any * file extension is allowed * @param existingFileName The name of a file with path. If the filename points * to an existing file, the directory in which it lies, will be used * as the starting point for the returned JFileChooser. * * @return the JFileChooser that interacted with the user, after they are * finished using it - null if no file was chosen */ public static JFileChooser promptToOpenFile(String[] exts, String existingFileName) { return promptToOpenFile(exts, null, false); }
@Override public void actionPerformed(ActionEvent ev) { if (ev.getSource() == saveTable) { JFileChooser chooser = FileDialoger .promptToSaveFile("synthesis.csv"); if (chooser == null) { return; } FileWriter writer = null; try { writer = new FileWriter(chooser.getSelectedFile()); // TODO // Charset ? CSVSaveService.saveCSVStats(getAllTableData(model, FORMATS), writer, saveHeaders.isSelected() ? getLabels(COLUMNS) : null); } catch (FileNotFoundException e) { log.warn(e.getMessage()); } catch (IOException e) { log.warn(e.getMessage()); } finally { JOrphanUtils.closeQuietly(writer); } } }
/** * Prompts the user to choose a file or a directory from their filesystems for our own * devious uses. This method maintains the last directory the user visited * before dismissing the dialog. This does NOT imply they actually chose a * file from that directory, only that they closed the dialog there. It is * the caller's responsibility to check to see if the selected file is * non-null. * @param existingFileName The name of a file with path. If the filename points * to an existing file, the directory in which it lies, will be used * as the starting point for the returned JFileChooser. * @param onlyDirectories If true, only directories are displayed in the FileChooser * * @return the JFileChooser that interacted with the user, after they are * finished using it - null if no file was chosen */ public static JFileChooser promptToOpenFile(String existingFileName, boolean onlyDirectories) { return promptToOpenFile(new String[0], existingFileName, onlyDirectories); }
private void saveImage(JComponent comp) { JFileChooser chooser = FileDialoger.promptToSaveFile( GuiPackage.getInstance().getTreeListener().getCurrentNode().getName(), extensions);
/** * opens a dialog box to choose a file and returns selected file's * path. * * @return a new File object */ private String browseAndGetFilePath() { String path = ""; //$NON-NLS-1$ JFileChooser chooser = FileDialoger.promptToOpenFile(); if (chooser != null) { File file = chooser.getSelectedFile(); if (file != null) { path = file.getPath(); } } return path; }
JFileChooser chooser = FileDialoger.promptToSaveFile("statistics.csv"); //$NON-NLS-1$ if (chooser == null) { return;
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(ACTION_BROWSE)) { JFileChooser chooser; if(filetypes == null || filetypes.length == 0){ chooser = FileDialoger.promptToOpenFile(filename.getText(),onlyDirectories); } else { chooser = FileDialoger.promptToOpenFile(filetypes, filename.getText(),onlyDirectories); } if (chooser != null && chooser.getSelectedFile() != null) { filename.setText(chooser.getSelectedFile().getPath()); fireFileChanged(); } } else { fireFileChanged(); } } }