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 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 setInputProductDir(final File currentDirectory) { applicationContext.getPreferences().setPropertyString(INPUT_PRODUCT_DIR_KEY, currentDirectory.getAbsolutePath()); }
private void setInputProductDir(final File currentDirectory) { applicationContext.getPreferences().setPropertyString(INPUT_PRODUCT_DIR_KEY, currentDirectory.getAbsolutePath()); }
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 void preserveCurrentDirectory(JFileChooser fileChooser) { if (appContext != null) { String lastDir = fileChooser.getCurrentDirectory().getAbsolutePath(); appContext.getPreferences().setPropertyString(lastDirPreferenceKey, lastDir); } }
public void actionPerformed(ActionEvent e) { ensureDefaultDirSet(); DiagramGraphIO.writeGraphs(null, "Export Endmembers", new SnapFileFilter[]{DiagramGraphIO.SPECTRA_CSV_FILE_FILTER}, appContext.getPreferences(), endmemberDiagram.getGraphs()); } }
public void actionPerformed(ActionEvent e) { ensureDefaultDirSet(); DiagramGraph[] diagramGraphs = DiagramGraphIO.readGraphs(null, "Add Endmembers", new SnapFileFilter[]{DiagramGraphIO.SPECTRA_CSV_FILE_FILTER}, appContext.getPreferences()); Endmember[] endmembers = convertGraphsToEndmembers(diagramGraphs); for (Endmember endmember : endmembers) { addEndmember(endmember); } }
@Override public void actionPerformed(ActionEvent event) { final Window window = SwingUtilities.getWindowAncestor((JComponent) event.getSource()); String homeDirPath = SystemUtils.getUserHomeDir().getPath(); String openDir = appContext.getPreferences().getPropertyString(OpenProductAction.PREFERENCES_KEY_LAST_PRODUCT_DIR, homeDirPath); currentDirectory = new File(openDir); chooser.setCurrentDirectory(currentDirectory); if (chooser.showDialog(window, APPROVE_BUTTON_TEXT) == JFileChooser.APPROVE_OPTION) { SwingWorker cursorWorker = new CursorWorker(window, chooser); cursorWorker.execute(); currentDirectory = chooser.getCurrentDirectory(); appContext.getPreferences().setPropertyString(OpenProductAction.PREFERENCES_KEY_LAST_PRODUCT_DIR, currentDirectory.getAbsolutePath()); } }
@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()); } } }
private String getDefaultOutputPath(AppContext appContext) { final Property dirProperty = container.getProperty("outputDir"); String userHomePath = SystemUtils.getUserHomeDir().getAbsolutePath(); String lastDir = appContext.getPreferences().getPropertyString(PROPERTY_NAME_LAST_OPEN_OUTPUT_DIR, userHomePath); String path; try { path = new File(lastDir).getCanonicalPath(); } catch (IOException ignored) { path = userHomePath; } try { dirProperty.setValue(new File(path)); } catch (ValidationException ignore) { } return path; }
public void actionPerformed(ActionEvent e) { List<SpectrumInput> spectrumList = new ArrayList<>(spectrumListModel.getSize()); for (int index = 0; index < spectrumListModel.size(); index++) { spectrumList.add(spectrumListModel.get(index)); } SpectrumCsvIO.writeSpectrumList(null, "Export Spectrum Classes", new SnapFileFilter[]{DiagramGraphIO.SPECTRA_CSV_FILE_FILTER}, appContext.getPreferences(), spectrumList); } }
public void actionPerformed(ActionEvent e) { SpectrumInput[] csvSpectrumInput = SpectrumCsvIO.readSpectrum(null, "Load spectrum csv", new SnapFileFilter[]{SpectrumCsvIO.CSV_FILE_FILTER}, appContext.getPreferences()); for (SpectrumInput spectrumInputCSV : csvSpectrumInput) { boolean exists = false; for(int index = 0; index < spectrumListModel.getSize(); index++){ if(spectrumListModel.get(index).getName().equals(spectrumInputCSV.getName())){ exists = true; } } if(!exists) { spectrumListModel.addElement(spectrumInputCSV); } } } }
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(); } }
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(SaveProductAsAction.PREFERENCES_KEY_LAST_PRODUCT_DIR, homeDirPath); targetProductSelector.getModel().setProductDir(new File(saveDir)); if (!alwaysWriteOutput) { targetProductSelector.getOpenInAppCheckBox().setText("Open in " + appContext.getApplicationName()); } targetProductSelector.getModel().getValueContainer().addPropertyChangeListener(evt -> { if (evt.getPropertyName().equals("saveToFileSelected") || evt.getPropertyName().equals("openInAppSelected")) { updateRunButton(); } }); AbstractButton button = getButton(ID_APPLY); button.setText("Run"); button.setMnemonic('R'); updateRunButton(); }
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 protected void onApply() { if (!canApply()) { return; } TargetProductSelectorModel model = targetProductSelector.getModel(); String productDirPath = model.getProductDir().getAbsolutePath(); appContext.getPreferences().setPropertyString(SaveProductAsAction.PREFERENCES_KEY_LAST_PRODUCT_DIR, productDirPath); Product targetProduct = null; try { long t0 = System.currentTimeMillis(); targetProduct = createTargetProduct(); createTargetProductTime = System.currentTimeMillis() - t0; } catch (Throwable t) { handleInitialisationError(t); return; } if (targetProduct == null) { throw new NullPointerException("The target product is null."); } targetProduct.setName(model.getProductName()); targetProduct.setFileLocation(model.getProductFile()); GRMProductWriterSwingWorker worker = new GRMProductWriterSwingWorker(targetProduct); worker.executeWithBlocking(); // start the thread }
@Override protected void onApply() { if (!canApply()) { return; } TargetProductSelectorModel model = targetProductSelector.getModel(); String productDirPath = model.getProductDir().getAbsolutePath(); appContext.getPreferences().setPropertyString(SaveProductAsAction.PREFERENCES_KEY_LAST_PRODUCT_DIR, productDirPath); try { HashMap<String, Product> sourceProducts = ioParametersPanel.createSourceProductsMap(); Product currentSourceProduct = sourceProducts.get(RECENT_PRODUCT_PROPERTY); Product previousSourceProduct = sourceProducts.get(PREVIOUS_PRODUCT_PROPERTY); ProductManager productManager = appContext.getProductManager(); Component parentComponent = getJDialog(); TargetProductSwingWorker worker = new TargetProductSwingWorker(parentComponent, productManager, model, currentSourceProduct, previousSourceProduct, this.parameterSupport.getParameterMap()); worker.executeWithBlocking(); // start the thread } catch (Throwable t) { handleInitialisationError(t); return; } }
private AbstractButton createOutputDirChooserButton(final Property outputFileProperty) { AbstractButton button = new JButton("..."); button.addActionListener(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(PROPERTY_NAME_LAST_OPEN_OUTPUT_DIR, selectedFile.getAbsolutePath()); } catch (ValidationException ve) { // not expected to ever come here appContext.handleError("Invalid input path", ve); } }); return button; }
public void actionPerformed(ActionEvent e) { ProductExpressionPane pep = ProductExpressionPane.createGeneralExpressionPane(getCompatibleProducts(), targetProduct, appContext.getPreferences()); pep.setCode(paramExpression.getValueAsText()); int status = pep.showModalDialog(SwingUtilities.getWindowAncestor(panel), "Arithmetic Expression Editor"); if (status == ModalDialog.ID_OK) { paramExpression.setValue(pep.getCode(), null); Debug.trace("BandArithmetikDialog: expression is: " + pep.getCode()); bandDesc.expression = paramExpression.getValueAsText(); } pep.dispose(); pep = null; } };