private static File getExportFile() { final Preferences preferences = SnapApp.getDefault().getPreferences(); final File currentDir = new File(preferences.get(lastExportDirPreferenceKey, SystemUtils.getUserHomeDir().getPath())); final SnapFileChooser fileChooser = new SnapFileChooser(); fileChooser.setDialogTitle("Export list of products"); fileChooser.setCurrentDirectory(currentDir); final int result = fileChooser.showSaveDialog(SnapApp.getDefault().getMainFrame()); if (result == JFileChooser.APPROVE_OPTION) { final File file = fileChooser.getSelectedFile(); if (file != null) { final File parentFolder = file.getAbsoluteFile().getParentFile(); if (parentFolder != null) { preferences.put(lastExportDirPreferenceKey, parentFolder.getPath()); } return file; } } return null; }
final int status = snapFileChooser.showSaveDialog(this); if (snapFileChooser.getSelectedFile() == null) { selectedFile = null;
private static File requestFolderForSave2(String title, final String preferenceKey) { Assert.notNull(preferenceKey, "preferenceKey"); String lastDir = SnapApp.getDefault().getPreferences().get(preferenceKey, SystemUtils.getUserHomeDir().getPath()); File currentDir = new File(lastDir); SnapFileChooser fileChooser = new SnapFileChooser(); fileChooser.setCurrentDirectory(currentDir); fileChooser.setDialogTitle(Dialogs.getDialogTitle(title)); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setAcceptAllFileFilterUsed(false); int result = fileChooser.showSaveDialog(SnapApp.getDefault().getMainFrame()); if (fileChooser.getCurrentDirectory() != null) { SnapApp.getDefault().getPreferences().put(preferenceKey, fileChooser.getCurrentDirectory().getPath()); } if (result == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); if (file == null || file.getName().equals("")) { return null; } String path = file.getPath(); return new File(path); } return null; }
fileChooser.setAccessory(accessory); int result = fileChooser.showSaveDialog(SnapApp.getDefault().getMainFrame()); if (fileChooser.getCurrentDirectory() != null) { getPreferences().put(preferenceKey, fileChooser.getCurrentDirectory().getPath());
void exportPlacemarkDataTable() { final SnapFileChooser fileChooser = new SnapFileChooser(); fileChooser.setDialogTitle(MessageFormat.format("Export {0} Data Table", /*I18N*/ StringUtils.firstLetterUp(placemarkDescriptor.getRoleLabel()))); setComponentName(fileChooser, "Export_Data_Table"); fileChooser.setFileFilter(PlacemarkIO.createTextFileFilter()); final File ioDir = getIODir(); fileChooser.setCurrentDirectory(ioDir); fileChooser.setSelectedFile(new File(ioDir, "Data")); int result = fileChooser.showSaveDialog(SwingUtilities.getWindowAncestor(this)); if (result == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); if (file != null) { if (Boolean.TRUE.equals(Dialogs.requestOverwriteDecision(getTitle(), file))) { setIODir(file.getAbsoluteFile().getParentFile()); file = FileUtils.ensureExtension(file, PlacemarkIO.FILE_EXTENSION_FLAT_TEXT); try { try (Writer writer = new FileWriter(file)) { writePlacemarkDataTableText(writer); } } catch (IOException ignored) { Dialogs.showError(MessageFormat.format("I/O Error.\nFailed to export {0} data table.", /*I18N*/ placemarkDescriptor.getRoleLabel())); } } } } }
private void exportColorPaletteDef() { final ImageInfo imageInfo = getFormModel().getModifiedImageInfo(); if (imageInfo == null) { // Normally this code is unreachable because, the export Button should be // disabled if the color manipulation form has no ImageInfo. return; } final SnapFileChooser fileChooser = new SnapFileChooser(); fileChooser.setDialogTitle("Export Colour Palette"); /*I18N*/ fileChooser.setFileFilter(getOrCreateColorPaletteDefinitionFileFilter()); fileChooser.setCurrentDirectory(getIODir().toFile()); final int result = fileChooser.showSaveDialog(getToolViewPaneControl()); File file = fileChooser.getSelectedFile(); if (file != null && file.getParentFile() != null) { setIODir(file.getParentFile()); } if (result == JFileChooser.APPROVE_OPTION) { if (file != null) { if (Boolean.TRUE.equals(Dialogs.requestOverwriteDecision(titlePrefix, file))) { file = FileUtils.ensureExtension(file, FILE_EXTENSION); try { final ColorPaletteDef colorPaletteDef = imageInfo.getColorPaletteDef(); ColorPaletteDef.storeColorPaletteDef(colorPaletteDef, file); } catch (IOException e) { showErrorDialog("Failed to export colour palette:\n" + e.getMessage()); /*I18N*/ } } } } }
fileChooser.setFileFilter(snapFileFilter); File outputAsciiFile; int result = fileChooser.showSaveDialog(SnapApp.getDefault().getMainFrame()); if (result == JFileChooser.APPROVE_OPTION) { outputAsciiFile = fileChooser.getSelectedFile();
fileChooser.setCurrentDirectory(ioDir); fileChooser.setSelectedFile(new File(ioDir, placemarkDescriptor.getRoleName())); int result = fileChooser.showSaveDialog(SwingUtilities.getWindowAncestor(this)); if (result == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile();
int result = fileChooser.showSaveDialog(SnapApp.getDefault().getMainFrame()); File file = fileChooser.getSelectedFile(); fileChooser.addPropertyChangeListener(evt -> {
int result = fileChooser.showSaveDialog(snapApp.getMainFrame()); File file = fileChooser.getSelectedFile(); fileChooser.addPropertyChangeListener(evt -> {