final ParamProperties paramProperties = getParameter().getProperties(); final P p; try { UIUtils.setRootFrameWaitCursor(getEditorComponent()); p = getSelectedProduct(paramProperties); } catch (IOException e) { JOptionPane.showMessageDialog(getEditorComponent(), "Failed to invoke expression editor:\n" + return; } finally { UIUtils.setRootFrameDefaultCursor(getEditorComponent()); JOptionPane.showMessageDialog(getEditorComponent(), "Failed to invoke expression editor:\n" + "No input product selected.", /*I18N*/ return; final Product[] sourceProducts = getInputProducts(paramProperties); final PropertyMap preferences = getPreferences(paramProperties); final ProductExpressionPane exprPane = createProductExpressionPane(sourceProducts != null ? sourceProducts: new Product[]{p.product}, p.product, preferences); exprPane.setCode(getParameterExprValue()); if (exprPane.showModalDialog(null, "Expression Editor") == ModalDialog.ID_OK) { setParameterExprValue(exprPane.getCode());
private String getParameterExprValue() { return (String) getParameter().getValue(); }
private P getSelectedProduct(final ParamProperties paramProperties) throws IOException { final Object propertyValue = paramProperties.getPropertyValue(PROPERTY_KEY_SELECTED_PRODUCT); if (propertyValue == null) { return null; } if (propertyValue instanceof Product) { return new P((Product) propertyValue, false); } else if (propertyValue instanceof String) { return new P(openProduct((String) propertyValue), true); } else { throw new IllegalStateException( "parameter property '" + PROPERTY_KEY_SELECTED_PRODUCT + "' has an illegal type"); } }
private void setParameterExprValue(final String value) { getParameter().setValue(value, null); }