private int editExpression(String[] value, final boolean booleanExpected) { Product product; try { product = mosaicModel.getReferenceProduct(); } catch (IOException ioe) { appContext.handleError(ioe.getMessage(), ioe); return 0; } if(product == null) { final String msg = "No source product specified."; appContext.handleError(msg, new IllegalStateException(msg)); return 0; } final ProductExpressionPane pep; if (booleanExpected) { pep = ProductExpressionPane.createBooleanExpressionPane(new Product[]{product}, product, appContext.getPreferences()); } else { pep = ProductExpressionPane.createGeneralExpressionPane(new Product[]{product}, product, appContext.getPreferences()); } pep.setCode(value[0]); final int i = pep.showModalDialog(appContext.getApplicationWindow(), value[0]); if (i == ModalDialog.ID_OK) { value[0] = pep.getCode(); } return i; }
@Override public int show() { ioForm.addProduct(appContext.getSelectedProduct()); return super.show(); }
public synchronized void initProducts() { productListModel.removeAllElements(); for (Product product : appContext.getProductManager().getProducts()) { addProduct(product); } final Product selectedProduct = appContext.getSelectedProduct(); if (selectedProduct != null && productFilter.accept(selectedProduct)) { productListModel.setSelectedItem(selectedProduct); } appContext.getProductManager().addListener(productManagerListener); }
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; }
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; }
@Override public void actionPerformed(ActionEvent e) { PropertyMap preferences = appContext.getPreferences(); String lastDir = preferences.getPropertyString(LAST_OPEN_PLACEMARK_DIR, SystemUtils.getUserHomeDir().getPath()); appContext.handleError(String.format("Error occurred while reading file: %s", selectedFile), ioe); } finally { if (reader != null) {
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(); }
@Override public void actionPerformed(ActionEvent e) { JTextArea wktArea = new JTextArea(30, 40); wktArea.setEditable(false); wktArea.setText(wkt); final JScrollPane scrollPane = new JScrollPane(wktArea); final ModalDialog dialog = new ModalDialog(appContext.getApplicationWindow(), "Coordinate reference system as well known text", scrollPane, ModalDialog.ID_OK, null); dialog.show(); } });
product = mosaicModel.getReferenceProduct(); } catch (IOException ioe) { appContext.handleError(ioe.getMessage(), ioe); return; final BandChooser bandChooser = new BandChooser(appContext.getApplicationWindow(), "Band Chooser", null,
@Override public void handleException(Exception e) { appContext.handleError("Unable to perform download. Reason: " + e.getMessage(), e); }
@Override protected void onApply() { if (!canApply()) { return; } String productDir = targetProductSelector.getModel().getProductDir().getAbsolutePath(); appContext.getPreferences().setPropertyString(BasicApp.PROPERTY_KEY_APP_LAST_SAVE_DIR, productDir); Product targetProduct = null; try { targetProduct = createTargetProduct(); if (targetProduct == null) { throw new NullPointerException("Target product is null."); } } catch (Throwable t) { handleInitialisationError(t); } if (targetProduct == null) { return; } targetProduct.setName(targetProductSelector.getModel().getProductName()); if (targetProductSelector.getModel().isSaveToFileSelected()) { targetProduct.setFileLocation(targetProductSelector.getModel().getProductFile()); final ProgressMonitorSwingWorker worker = new ProductWriterSwingWorker(targetProduct); worker.executeWithBlocking(); } else if (targetProductSelector.getModel().isOpenInAppSelected()) { appContext.getProductManager().addProduct(targetProduct); showOpenInAppInfo(); } }
@Override public LayerContext getLayerContext() { return appContext.getSelectedProductSceneView().getLayerContext(); }
private ProductTreeModel createTreeModel(AppContext ctx) { Product selectedProduct = ctx.getSelectedProductSceneView().getProduct(); ArrayList<CompatibleNodeList> compatibleNodeLists = new ArrayList<CompatibleNodeList>(3); List<RasterDataNode> compatibleNodes = new ArrayList<RasterDataNode>(); compatibleNodes.addAll(Arrays.asList(selectedProduct.getBands())); compatibleNodes.addAll(Arrays.asList(selectedProduct.getTiePointGrids())); if (!compatibleNodes.isEmpty()) { compatibleNodeLists.add(new CompatibleNodeList(selectedProduct.getDisplayName(), compatibleNodes)); } RasterDataNode raster = ctx.getSelectedProductSceneView().getRaster(); GeoCoding geoCoding = raster.getGeoCoding(); CoordinateReferenceSystem modelCRS = ImageManager.getModelCrs(geoCoding); final ProductManager productManager = ctx.getProductManager(); final Product[] products = productManager.getProducts(); for (Product product : products) { if (product == selectedProduct) { continue; } compatibleNodes = new ArrayList<RasterDataNode>(); collectCompatibleRasterDataNodes(modelCRS, product.getBands(), compatibleNodes); collectCompatibleRasterDataNodes(modelCRS, product.getTiePointGrids(), compatibleNodes); if (!compatibleNodes.isEmpty()) { compatibleNodeLists.add(new CompatibleNodeList(product.getDisplayName(), compatibleNodes)); } } return new ProductTreeModel(compatibleNodeLists); }
final Product existingProduct = appContext.getProductManager().getProduct(productName); if (existingProduct != null) { String message = MessageFormat.format( "A product with the name ''{0}'' is already opened in {1}.\n\n" + "Do you want to continue?", productName, appContext.getApplicationName() ); final int answer = JOptionPane.showConfirmDialog(getJDialog(), message,
private Product[] filterProducts() { List<Product> currentlyOpenedProducts = Arrays.asList(listModel.getSourceProducts()); List<Product> productManagerProducts = Arrays.asList(appContext.getProductManager().getProducts()); ArrayList<Product> result = new ArrayList<>(); for (Product product : productManagerProducts) { if (!currentlyOpenedProducts.contains(product)) { result.add(product); } } return result.toArray(new Product[result.size()]); }
private void showOpenInAppInfo() { final String message = MessageFormat.format( "The target product has successfully been created and opened in {0}.\n\n" + "Actual processing of source to target data will be performed only on demand,\n" + "for example, if the target product is saved or an image view is opened.", appContext.getApplicationName() ); showSuppressibleInformationDialog(message, "openInAppInfo"); }
private SelectionManager getSelectionManager() { // on first access the selection manager is initialised // this can not be done in the constructor because, at the time it is called, the AppContext is not // fully initialised if (selectionManager == null) { selectionManager = getAppContext().getApplicationPage().getSelectionManager(); // todo - this is needed to consistently update the enable state of the action // todo - probably a call to updateChange() is missing in the framework at the time the menu gets visible selectionManager.addSelectionChangeListener(this); } return selectionManager; }
private void setInputProductDir(final File currentDirectory) { applicationContext.getPreferences().setPropertyString(INPUT_PRODUCT_DIR_KEY, currentDirectory.getAbsolutePath()); }
@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 protected JComponent createCrsComponent() { final CustomCrsPanel panel = new CustomCrsPanel(getAppContext().getApplicationWindow()); panel.addPropertyChangeListener("crs", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { fireCrsChanged(); } }); return panel; }