@Override ProductExpressionPane getProductExpressionPane(Product currentProduct) { return ProductExpressionPane.createGeneralExpressionPane( new Product[]{currentProduct}, currentProduct, null); } }
private void invokeExpressionEditor(final int colorIndex) { final Window window = SwingUtilities.getWindowAncestor(this); final String title = "Edit " + getComponentName(colorIndex) + " Expression"; if (product != null) { final ExpressionPane pane; final Product[] products = getCompatibleProducts(product, openedProducts); pane = ProductExpressionPane.createGeneralExpressionPane(products, product, preferences); pane.setCode(getExpression(colorIndex)); int status = pane.showModalDialog(window, title); if (status == ModalDialog.ID_OK) { setExpression(colorIndex, pane.getCode()); } } else { final JTextArea textArea = new JTextArea(8, 48); textArea.setFont(EXPRESSION_FONT); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setText(getExpression(colorIndex)); final ModalDialog modalDialog = new ModalDialog(window, title, ModalDialog.ID_OK_CANCEL, ""); final JPanel panel = new JPanel(new BorderLayout(2, 2)); panel.add(new JLabel("Expression:"), BorderLayout.NORTH); panel.add(new JScrollPane(textArea), BorderLayout.CENTER); modalDialog.setContent(panel); final int status = modalDialog.show(); if (status == ModalDialog.ID_OK) { setExpression(colorIndex, textArea.getText()); } } }
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; } };
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; }
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 void actionPerformed(ActionEvent e) { ProductExpressionPane expressionPane = ProductExpressionPane.createGeneralExpressionPane(new Product[]{contextProduct}, contextProduct, null); expressionPane.setCode(variableItem.variableConfig.getExpr()); int status = expressionPane.showModalDialog(getJDialog(), "Expression Editor"); if (status == ModalDialog.ID_OK) { bindingContext.getBinding(PROPERTY_EXPRESSION).setPropertyValue(expressionPane.getCode()); } expressionPane.dispose(); } };
private ActionListener createEditExpressionButtonListener() { return e -> { Product[] compatibleProducts = getCompatibleProducts(); ProductExpressionPane pep = ProductExpressionPane.createGeneralExpressionPane(compatibleProducts, targetProduct, SnapApp.getDefault().getPreferencesPropertyMap()); pep.setCode(getExpression()); int status = pep.showModalDialog(getJDialog(), "Band Maths Expression Editor"); if (status == ModalDialog.ID_OK) { bindingContext.getBinding(PROPERTY_NAME_EXPRESSION).setPropertyValue(pep.getCode()); } pep.dispose(); }; }