/** Brings up the folder chooser. */ private void download() { JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame(); FileChooser chooser = new FileChooser( f, FileChooser.FOLDER_CHOOSER, "Download", "Select where to download the file.", null, true); chooser.setSelectedFileFull(view.getRefObjectName()); IconManager icons = IconManager.getInstance(); chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48)); chooser.setApproveButtonText("Download"); chooser.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (FileChooser.APPROVE_SELECTION_PROPERTY.equals(name)) { String path = (String) evt.getNewValue(); if (path == null) { path = UIUtilities.getDefaultFolderAsString(); } if (!path.endsWith(File.separator)) path += File.separator; model.download(new File(path)); } } }); chooser.centerDialog(); }
/** Brings up a dialog so that the user can select where to download the file. */ private void download() { String name = null; if (data instanceof FileAnnotationData) { name = ((FileAnnotationData) data).getFileName(); } JFrame f = MetadataViewerAgent.getRegistry().getTaskBar().getFrame(); FileChooser chooser = new FileChooser( f, FileChooser.SAVE, "Download", "Select where to download the files.", null, true); if (name != null && name.trim().length() > 0) chooser.setSelectedFileFull(name); IconManager icons = IconManager.getInstance(); chooser.setTitleIcon(icons.getIcon(IconManager.DOWNLOAD_48)); chooser.setApproveButtonText("Download"); chooser.addPropertyChangeListener(this); chooser.centerDialog(); }