@Override public void handleException(Exception e) { appContext.handleError("Unable to perform download. Reason: " + e.getMessage(), e); }
public void actionPerformed(ActionEvent event) { final String expression = editExpression(validPixelExpressionField.getText()); if (expression != null) { try { binningFormModel.setProperty(BinningFormModel.PROPERTY_KEY_MASK_EXPR, expression); } catch (ValidationException e) { appContext.handleError("Invalid expression", e); } } } });
protected void handleProcessingError(Throwable t) { String msg; if (isInternalException(t)) { msg = MessageFormat.format("An internal error occurred during the target product processing.\n{0}", formatThrowable(t)); } else { msg = MessageFormat.format("A problem occurred during processing the target product processing.\n{0}", formatThrowable(t)); } appContext.handleError(msg, t); }
protected void handleInitialisationError(Throwable t) { String msg; if (isInternalException(t)) { msg = MessageFormat.format("An internal error occurred during the target product initialisation.\n{0}", formatThrowable(t)); } else { msg = MessageFormat.format("A problem occurred during the target product initialisation.\n{0}", formatThrowable(t)); } appContext.handleError(msg, t); }
@Override protected void done() { try { Product firstProduct = get(); if (firstProduct != null) { binningFormModel.useAsContextProduct(firstProduct); firstProduct.dispose(); } } catch (Exception ex) { String msg = String.format("Cannot open source products.\n%s", ex.getMessage()); appContext.handleError(msg, ex); } } };
public void resolveCatalogReferenceNode(DefaultMutableTreeNode catalogReferenceNode, boolean expandPath) { final DefaultTreeModel model = (DefaultTreeModel) jTree.getModel(); final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) catalogReferenceNode.getParent(); model.removeNodeFromParent(catalogReferenceNode); try { List<InvDataset> catalogDatasets = CatalogTreeUtils.getCatalogDatasets(catalogReferenceNode); insertCatalogElements(catalogDatasets, parent, expandPath); } catch (Exception e) { String msg = MessageFormat.format("Unable to completely resolve catalog. Reason: {0}", e.getMessage()); BeamLogManager.getSystemLogger().warning(msg); appContext.handleError(msg, e); } }
@Override protected void done() { try { get(); Object outputDir = parameterMap.get("outputDir"); String message; if (outputDir != null) { message = String.format( "The pixel extraction tool has run successfully and written the result file(s) to %s.", outputDir.toString()); } else { message = "The pixel extraction tool has run successfully and written the result file to to std.out."; } JOptionPane.showMessageDialog(getJDialog(), message); } catch (InterruptedException ignore) { } catch (ExecutionException e) { appContext.handleError(e.getMessage(), e); } finally { AbstractButton runButton = getButton(ID_OK); runButton.setEnabled(true); } } }
@Override public void selectionChanged(SelectionChangeEvent event) { final Product product = (Product) event.getSelection().getSelectedValue(); try { if (product != null) { final Map<String, Object> map = MosaicOp.getOperatorParameters(product); for (Map.Entry<String, Object> entry : map.entrySet()) { if (propertySet.getProperty(entry.getKey()) != null) { propertySet.setValue(entry.getKey(), entry.getValue()); } } } propertySet.setValue(MosaicFormModel.PROPERTY_UPDATE_PRODUCT, product); } catch (OperatorException e) { appContext.handleError("Selected product cannot be used for update mode.", e); } } });
appContext.handleError(String.format("Error occurred while reading file: %s", selectedFile), ioe); } finally { if (reader != null) {
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; }
product = mosaicModel.getReferenceProduct(); } catch (IOException ioe) { appContext.handleError(ioe.getMessage(), ioe); return;
} catch (ValidationException ve) { appContext.handleError("Invalid input path", ve);
@Override public void contentsChanged(ListDataEvent event) { final Product[] sourceProducts = sourceProductList.getSourceProducts(); try { binningFormModel.setProperty(BinningFormModel.PROPERTY_KEY_SOURCE_PRODUCTS, sourceProducts); } catch (ValidationException e) { appContext.handleError("Unable to set source products.", e); } if (sourceProducts.length > 0) { binningFormModel.useAsContextProduct(sourceProducts[0]); return; } String[] sourceProductPath = binningFormModel.getSourceProductPath(); if (sourceProductPath != null && sourceProductPath.length > 0) { openFirstProduct(sourceProductPath); return; } binningFormModel.useAsContextProduct(null); }
@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); } } });
@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)); } } }
} catch (ValidationException ve) { appContext.handleError("Invalid input path", ve);
@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); } } }
appContext.handleError("Could not create a 'Coordinate Reference System'.\n" + e.getMessage(), e);