private void setInputProductDir(final File currentDirectory) { applicationContext.getPreferences().setPropertyString(INPUT_PRODUCT_DIR_KEY, currentDirectory.getAbsolutePath()); }
private File getInputProductDir() { final String path = applicationContext.getPreferences().getPropertyString(INPUT_PRODUCT_DIR_KEY); final File inputProductDir; if (path != null) { inputProductDir = new File(path); } else { inputProductDir = null; } return inputProductDir; }
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)); } }
private File getLastDirectory() { PropertyMap preferences = getContext().getAppContext().getPreferences(); String dirPath = preferences.getPropertyString(PROPERTY_LAST_DIR, System.getProperty("user.home")); File lastDir = new File(dirPath); if (!lastDir.isDirectory()) { lastDir = new File(System.getProperty("user.home")); } return lastDir; } }
private File getLastDirectory() { PropertyMap preferences = getContext().getAppContext().getPreferences(); String dirPath = preferences.getPropertyString(LAST_DIR, System.getProperty("user.home")); File lastDir = new File(dirPath); if (!lastDir.isDirectory()) { lastDir = new File(System.getProperty("user.home")); } return lastDir; }
private void preserveCurrentDirectory(JFileChooser fileChooser) { if (appContext != null) { String lastDir = fileChooser.getCurrentDirectory().getAbsolutePath(); appContext.getPreferences().setPropertyString(lastDirPreferenceKey, lastDir); } }
public OpendapAccessPanel(AppContext appContext, String helpId) { super(); this.propertyMap = appContext.getPreferences(); this.helpId = helpId; this.appContext = appContext; initComponents(); initContentPane(); }
public void actionPerformed(ActionEvent e) { ensureDefaultDirSet(); DiagramGraph[] diagramGraphs = DiagramGraphIO.readGraphs(null, "Add Endmembers", new BeamFileFilter[]{DiagramGraphIO.SPECTRA_CSV_FILE_FILTER}, appContext.getPreferences()); Endmember[] endmembers = convertGraphsToEndmembers(diagramGraphs); for (Endmember endmember : endmembers) { addEndmember(endmember); } }
public void actionPerformed(ActionEvent e) { ensureDefaultDirSet(); DiagramGraphIO.writeGraphs(null, "Export Endmembers", new BeamFileFilter[]{DiagramGraphIO.SPECTRA_CSV_FILE_FILTER}, appContext.getPreferences(), endmemberDiagram.getGraphs()); } }
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; }
@Override public void actionPerformed(ActionEvent e) { ProductExpressionPane pep = ProductExpressionPane.createBooleanExpressionPane(new Product[]{activeProduct}, activeProduct, appContext.getPreferences()); pep.setCode(expressionArea.getText()); final int i = pep.showModalDialog(parentWindow, "Expression Editor"); if (i == ModalDialog.ID_OK) { expressionArea.setText(pep.getCode()); } } }
/** * Shows an information dialog on top of this dialog. * The shown dialog will contain a user option allowing to not show the message anymore. * * @param infoMessage The message. * @param propertyName The (simple) property name used to store the user option in the application's preferences. */ public void showSuppressibleInformationDialog(String infoMessage, String propertyName) { final SuppressibleOptionPane optionPane = new SuppressibleOptionPane(appContext.getPreferences()); optionPane.showMessageDialog(getClass().getName() + "." + propertyName, getJDialog(), infoMessage, getTitle(), JOptionPane.INFORMATION_MESSAGE); }
@Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.addChoosableFileFilter(filter); fileChooser.setCurrentDirectory(getLastDirectory()); LayerSourcePageContext pageContext = getContext(); fileChooser.showOpenDialog(pageContext.getWindow()); if (fileChooser.getSelectedFile() != null) { String filePath = fileChooser.getSelectedFile().getPath(); imageHistoryModel.setSelectedItem(filePath); PropertyMap preferences = pageContext.getAppContext().getPreferences(); preferences.setPropertyString(LAST_DIR, fileChooser.getCurrentDirectory().getAbsolutePath()); onFileSelected(pageContext, filePath); pageContext.updateState(); } }
@Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setAcceptAllFileFilterUsed(false); final FileNameExtensionFilter shapefileFilter = new FileNameExtensionFilter("ESRI Shapefile", "shp"); fileChooser.addChoosableFileFilter(shapefileFilter); fileChooser.setFileFilter(shapefileFilter); File lastDir = getLastDirectory(); fileChooser.setCurrentDirectory(lastDir); LayerSourcePageContext pageContext = getContext(); fileChooser.showOpenDialog(pageContext.getWindow()); if (fileChooser.getSelectedFile() != null) { String filePath = fileChooser.getSelectedFile().getPath(); fileHistoryModel.setSelectedItem(filePath); PropertyMap preferences = pageContext.getAppContext().getPreferences(); preferences.setPropertyString(PROPERTY_LAST_DIR, fileChooser.getCurrentDirectory().getAbsolutePath()); pageContext.updateState(); } }
private void ensureDefaultDirSet() { if (!defaultEndmemberDir.exists()) { final ResourceInstaller resourceInstaller = new ResourceInstaller(ResourceInstaller.getSourceUrl(SpectralUnmixingDialog.class), "auxdata/", defaultEndmemberDir); try { resourceInstaller.install(".*", com.bc.ceres.core.ProgressMonitor.NULL); } catch (IOException e) { // failed, so what } } final String key = DiagramGraphIO.DIAGRAM_GRAPH_IO_LAST_DIR_KEY; final PropertyMap preferences = appContext.getPreferences(); if (preferences.getPropertyString(key, null) == null) { preferences.setPropertyString(key, defaultEndmemberDir.getPath()); } }
public RestoredSession restore(AppContext appContext, URI rootURI, ProgressMonitor pm, ProblemSolver problemSolver) throws CanceledException { try { pm.beginTask("Restoring session", 100); ArrayList<Exception> problems = new ArrayList<Exception>(); ProductManager productManager = restoreProducts(rootURI, SubProgressMonitor.create(pm, 80), problemSolver, problems); // Note: ProductManager is used for the SessionDomConverter ProductNodeView[] views = restoreViews(productManager, appContext.getPreferences(), SubProgressMonitor.create(pm, 20), problems ); return new RestoredSession(productManager.getProducts(), views, problems.toArray(new Exception[problems.size()])); } finally { pm.done(); } }
@Override public void actionPerformed(ActionEvent e) { FolderChooser folderChooser = new FolderChooser(); folderChooser.setCurrentDirectory(new File(getDefaultOutputPath(appContext))); folderChooser.setDialogTitle("Select output directory"); folderChooser.setMultiSelectionEnabled(false); int result = folderChooser.showDialog(appContext.getApplicationWindow(), "Select"); /*I18N*/ if (result != JFileChooser.APPROVE_OPTION) { return; } File selectedFile = folderChooser.getSelectedFile(); setOutputDirPath(selectedFile.getAbsolutePath()); try { outputFileProperty.setValue(selectedFile); appContext.getPreferences().setPropertyString(LAST_OPEN_OUTPUT_DIR, selectedFile.getAbsolutePath()); } catch (ValidationException ve) { // not expected to ever come here appContext.handleError("Invalid input path", ve); } } });
private String editExpression(String expression) { final Product product = binningFormModel.getContextProduct(); if (product == null) { return null; } final ProductExpressionPane expressionPane; expressionPane = ProductExpressionPane.createBooleanExpressionPane(new Product[]{product}, product, appContext.getPreferences()); expressionPane.setCode(expression); final int i = expressionPane.showModalDialog(appContext.getApplicationWindow(), "Expression Editor"); if (i == ModalDialog.ID_OK) { return expressionPane.getCode(); } return null; }
@Override public AbstractLayerSourceAssistantPage getNextPage() { imageHistoryModel.getHistory().copyInto(getContext().getAppContext().getPreferences()); createTransform(getContext()); return new ImageFileAssistantPage2(); }
@Override public boolean performFinish() { imageHistoryModel.getHistory().copyInto(getContext().getAppContext().getPreferences()); createTransform(getContext()); return ImageFileLayerSource.insertImageLayer(getContext()); }