private void saveToFile() { final File file = new FileChooserBuilder(AttachmentsPanel.class) .setFilesOnly(true).showSaveDialog(); if (file != null) { String progressFormat = NbBundle.getMessage( SaveAttachmentAction.class, "Attachment.saveToFile.progress"); //NOI18N String progressMessage = MessageFormat.format(progressFormat, getFilename()); final ProgressHandle handle = ProgressHandleFactory.createHandle(progressMessage); handle.start(); handle.switchToIndeterminate(); Support.getInstance().getParallelRP().post(new Runnable() { @Override public void run() { try { getAttachmentData(file); } catch (IOException ioex) { LOG.log(Level.INFO, ioex.getMessage(), ioex); } finally { handle.finish(); } } }); } }
/** * Get the save location for the file. * pops up a save dialog * @return a file from the save dialog */ public File getSaveLocation() { if (fcb == null) { fcb = new FileChooserBuilder("Export-directory"); fcb.setTitle(FILECHOOSER_TITLE); fcb.setApproveText(FILECHOOSER_OK); fcb.addFileFilter(new FileFilter() { @Override public boolean accept(File pathname) { if (pathname.isDirectory() && pathname.getName().startsWith(".")) { return false; } return true; } @Override public String getDescription() { return FILECHOOSER_FILE_DESC; } }); } File workingDirectory = new File(SensorPreference.LAST_EXPORT_DIR.getValue()); fcb.setDefaultWorkingDirectory(workingDirectory); return fcb.showSaveDialog(); }