private File getIODir() { File dir = SystemUtils.getUserHomeDir(); if (propertyMap != null) { dir = new File(propertyMap.getPropertyString(PROPERTY_KEY_IO_DIR, dir.getPath())); } return dir; }
private File getIODir(final PropertyMap propertyMap) { final File dir = SystemUtils.getUserHomeDir(); return new File(propertyMap.getPropertyString(shapeIoDirPreferencesKey, dir.getPath())); }
private void applyCurrentDirectory(JFileChooser fileChooser) { if (appContext != null) { String homeDirPath = SystemUtils.getUserHomeDir().getPath(); String lastDir = appContext.getPreferences().getPropertyString(lastDirPreferenceKey, homeDirPath); fileChooser.setCurrentDirectory(new File(lastDir)); } }
/** * Optionally creates and returns the current user's application data directory. * * @param force if true, the directory will be created if it didn't exist before * * @return the current user's application data directory * * @since BEAM 4.2 */ public static File getApplicationDataDir(boolean force) { String contextId = getApplicationContextId(); final File dir = new File(getUserHomeDir(), "." + contextId); if (force && !dir.exists()) { dir.mkdirs(); } return dir; }
private String getDefaultOutputPath(AppContext appContext) { final Property dirProperty = container.getProperty("outputDir"); String lastDir = appContext.getPreferences().getPropertyString(LAST_OPEN_OUTPUT_DIR, "."); String path; try { path = new File(lastDir).getCanonicalPath(); } catch (IOException ignored) { path = SystemUtils.getUserHomeDir().getPath(); } try { dirProperty.setValue(new File(path)); } catch (ValidationException ignore) { } return path; }
File getDirectory() { File directory = SystemUtils.getUserHomeDir(); if (VisatApp.getApp().getPreferences() != null) { directory = new File(VisatApp.getApp().getPreferences().getPropertyString("mask.io.dir", directory.getPath())); } return directory; } }
PropertyMap preferences = appContext.getPreferences(); String lastDir = preferences.getPropertyString(LAST_OPEN_PLACEMARK_DIR, SystemUtils.getUserHomeDir().getPath()); final JFileChooser fileChooser = new JFileChooser(); fileChooser.addChoosableFileFilter(PlacemarkIO.createPlacemarkFileFilter());
final Window window = SwingUtilities.getWindowAncestor((JComponent) event.getSource()); String homeDirPath = SystemUtils.getUserHomeDir().getPath(); String openDir = appContext.getPreferences().getPropertyString(BasicApp.PROPERTY_KEY_APP_LAST_OPEN_DIR, homeDirPath);
@Test public void testGetUserHomeDir() { assertNotNull(SystemUtils.getUserHomeDir()); }
@Test public void testGetApplicationDataDir() { final File applicationDataDir = SystemUtils.getApplicationDataDir(); assertNotNull(applicationDataDir); final String prefix = SystemUtils.getUserHomeDir().getPath(); assertTrue(applicationDataDir.getPath().startsWith(prefix)); }
@Override public void actionPerformed(ActionEvent e) { final FolderChooser folderChooser = new FolderChooser(); final VisatApp visatApp = VisatApp.getApp(); final PropertyMap preferences = visatApp.getPreferences(); String lastDir = preferences.getPropertyString(PROPERTY_KEY_LAST_OPEN_TS_DIR, SystemUtils.getUserHomeDir().getPath()); folderChooser.setCurrentDirectory(new File(lastDir)); final int result = folderChooser.showOpenDialog(ProductLocationsPane.this); if (result != JFileChooser.APPROVE_OPTION) { return; } File currentDir = folderChooser.getSelectedFolder(); model.addDirectory(currentDir, recursive); if (currentDir != null) { preferences.setPropertyString(PROPERTY_KEY_LAST_OPEN_TS_DIR, currentDir.getAbsolutePath()); } } }
final PropertyMap preferences = appContext.getPreferences(); String lastDir = preferences.getPropertyString(lastOpenInputDir, SystemUtils.getUserHomeDir().getPath()); String lastFormat = preferences.getPropertyString(lastOpenedFormat, ALL_FILES_FORMAT);
private JFileChooser createFileChooser(final VisatApp visatApp) { String lastDirPath = visatApp.getPreferences().getPropertyString(GCP_EXPORT_DIR_PREFERENCES_KEY, SystemUtils.getUserHomeDir().getPath()); BeamFileChooser fileChooser = new BeamFileChooser(); HelpSys.enableHelpKey(fileChooser, getHelpId()); fileChooser.setAcceptAllFileFilterUsed(false); fileChooser.setCurrentDirectory(new File(lastDirPath)); fileChooser.setFileFilter( new BeamFileFilter(GCP_FILE_DESCRIPTION, GCP_FILE_EXTENSION, GCP_FILE_DESCRIPTION)); fileChooser.setDialogTitle(DIALOG_TITLE); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); return fileChooser; } }
@Override public void propertyChange(PropertyChangeEvent evt) { final Product product = (Product) evt.getNewValue(); final TargetProductSelectorModel selectorModel = targetProductSelector.getModel(); if (product != null) { final String formatName = product.getProductReader().getReaderPlugIn().getFormatNames()[0]; final ProductIOPlugInManager ioPlugInManager = ProductIOPlugInManager.getInstance(); final Iterator<ProductWriterPlugIn> writerIterator = ioPlugInManager.getWriterPlugIns(formatName); if (writerIterator.hasNext()) { selectorModel.setFormatName(formatName); } else { final String errMsg = "Cannot write to update product."; final String iseMsg = String.format("No product writer found for format '%s'", formatName); appContext.handleError(errMsg, new IllegalStateException(iseMsg)); } final File fileLocation = product.getFileLocation(); final String fileName = FileUtils.getFilenameWithoutExtension(fileLocation); final File fileDir = fileLocation.getParentFile(); selectorModel.setProductName(fileName); selectorModel.setProductDir(fileDir); } else { selectorModel.setFormatName(ProductIO.DEFAULT_FORMAT_NAME); selectorModel.setProductName("mosaic"); String homeDirPath = SystemUtils.getUserHomeDir().getPath(); final PropertyMap prefs = appContext.getPreferences(); String saveDir = prefs.getPropertyString(BasicApp.PROPERTY_KEY_APP_LAST_SAVE_DIR, homeDirPath); selectorModel.setProductDir(new File(saveDir)); } } }
@Override public void actionPerformed(ActionEvent e) { PropertyMap preferences = appContext.getPreferences(); final BeamFileChooser fileChooser = getFileChooser( preferences.getPropertyString(LAST_OPEN_CSV_DIR, SystemUtils.getUserHomeDir().getPath())); int answer = fileChooser.showDialog(parent, "Select"); if (answer == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); preferences.setPropertyString(LAST_OPEN_CSV_DIR, selectedFile.getParent()); try { final List<SimpleFeature> extendedFeatures = PixExOpUtils.extractFeatures(selectedFile); for (SimpleFeature extendedFeature : extendedFeatures) { final GenericPlacemarkDescriptor placemarkDescriptor = new GenericPlacemarkDescriptor( extendedFeature.getFeatureType()); final Placemark placemark = placemarkDescriptor.createPlacemark(extendedFeature); if (extendedFeature.getAttribute("Name") != null) { placemark.setName(extendedFeature.getAttribute("Name").toString()); } setPlacemarkGeoPos(extendedFeature, placemark); tableModel.addPlacemark(placemark); } } catch (IOException exception) { appContext.handleError(String.format("Error occurred while reading file: %s \n" + exception.getLocalizedMessage() + "\nPossible reason: Other char separator than tabulator used", selectedFile), exception); } } }
final String lastDir = visatApp.getPreferences().getPropertyString( EXPORT_DIR_PREFERENCES_KEY, SystemUtils.getUserHomeDir().getPath()); final File currentDir = new File(lastDir);
protected SingleTargetProductDialog(AppContext appContext, String title, int buttonMask, String helpID, TargetProductSelectorModel model, boolean alwaysWriteOutput) { super(appContext.getApplicationWindow(), title, buttonMask, helpID); this.appContext = appContext; targetProductSelector = new TargetProductSelector(model, alwaysWriteOutput); String homeDirPath = SystemUtils.getUserHomeDir().getPath(); String saveDir = appContext.getPreferences().getPropertyString(BasicApp.PROPERTY_KEY_APP_LAST_SAVE_DIR, homeDirPath); targetProductSelector.getModel().setProductDir(new File(saveDir)); if (!alwaysWriteOutput) { targetProductSelector.getOpenInAppCheckBox().setText("Open in " + appContext.getApplicationName()); } targetProductSelector.getModel().getValueContainer().addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("saveToFileSelected") || evt.getPropertyName().equals("openInAppSelected")) { updateRunButton(); } } }); AbstractButton button = getButton(ID_APPLY); button.setText("Run"); button.setMnemonic('R'); updateRunButton(); }
final VisatApp visatApp = VisatApp.getApp(); final PropertyMap preferences = visatApp.getPreferences(); String lastDir = preferences.getPropertyString(PROPERTY_KEY_LAST_OPEN_INSITU_DIR, SystemUtils.getUserHomeDir().getPath()); final BeamFileChooser fileChooser = new BeamFileChooser(new File(lastDir)); fileChooser.setAcceptAllFileFilterUsed(true);
final String lastDir = visatApp.getPreferences().getPropertyString( IMAGE_EXPORT_DIR_PREFERENCES_KEY, SystemUtils.getUserHomeDir().getPath()); final File currentDir = new File(lastDir);
private JFileChooser showOpenFileDialog() { String lastDir = getPreferences().getPropertyString(PROPERTY_KEY_APP_LAST_OPEN_DIR, SystemUtils.getUserHomeDir().getPath()); String lastFormat = getPreferences().getPropertyString(PROPERTY_KEY_APP_LAST_OPEN_FORMAT, ALL_FILES_IDENTIFIER);