org.opengis.filter.expression.Function Java Examples

The following examples show how to use org.opengis.filter.expression.Function. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtractAttributes.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Extract function attribute.
 *
 * @param foundList the found list
 * @param function the function
 * @return the class
 */
private Class<?> extractFunctionAttribute(List<String> foundList, Function function) {
    Class<?> returnType;
    FunctionName functionName = function.getFunctionName();
    List<Parameter<?>> argumentList = functionName.getArguments();
    int index = 0;

    for (Expression parameterExpression : function.getParameters()) {
        Parameter<?> parameter = argumentList.get(index);
        extractAttribute(parameter.getType(), parameterExpression, foundList);

        if (index < argumentList.size()) {
            index++;
        }

        if (index >= argumentList.size()) {
            index = argumentList.size() - 1;
        }
    }

    returnType = functionName.getReturn().getType();
    return returnType;
}
 
Example #2
Source File: StyleUtilities.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the offset in a symbolizer.
 * 
 * @param symbolizer the symbolizer.
 * @param text the text representing the offsets in the CSV form.
 */
@SuppressWarnings({"rawtypes", "unchecked"})
public static void setOffset( Symbolizer symbolizer, String text ) {
    if (text.indexOf(',') == -1) {
        return;
    }
    String[] split = text.split(",");
    if (split.length != 2) {
        return;
    }
    double xOffset = Double.parseDouble(split[0]);
    double yOffset = Double.parseDouble(split[1]);

    Expression geometry = symbolizer.getGeometry();
    if (geometry != null) {
        if (geometry instanceof FilterFunction_offset) {
            FilterFunction_offset offsetFunction = (FilterFunction_offset) geometry;
            List parameters = offsetFunction.getParameters();
            parameters.set(1, ff.literal(xOffset));
            parameters.set(2, ff.literal(yOffset));
        }
    } else {
        Function function = ff.function("offset", ff.property("the_geom"), ff.literal(xOffset), ff.literal(yOffset));
        symbolizer.setGeometry(function);
    }
}
 
Example #3
Source File: TestFilterPanelv2.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testInFunction() {

    TestFilterPanelv2Dialog testPanel = new TestFilterPanelv2Dialog(null);
    testPanel.configure("test", String.class, false);

    List<Expression> expList = new ArrayList<Expression>();
    expList.add(ff.literal(1));
    expList.add(ff.literal(2));

    Function func = functionFactory.function("in", expList, null);
    Filter filter = ff.equal(func, ff.literal(true), true);
    String expected = filter.toString();
    testPanel.filterDialog(String.class, filter);

    String actual = testPanel.getFilterString();

    assertEquals(expected, actual);
}
 
Example #4
Source File: ExtractAttributesTest.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testFunctionExpression() {
    DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();

    StyledLayerDescriptor sld = createTestSLD(dummy);
    List<Rule> ruleList = getRuleList(sld);

    ExtractAttributes extract = new ExtractAttributes();
    Rule rule = DefaultSymbols.createNewRule();

    String expectedEnvVar = "testenvvar";
    Function function = ff.function("env", ff.property(expectedEnvVar));

    Filter filter = ff.equal(ff.literal("not equal"), function, true);
    rule.setFilter(filter);
    ruleList.clear();
    ruleList.add(rule);
    extract.extractDefaultFields(sld);

    // Check fields extracted ok
    List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
    assertEquals(1, actualFieldnameList.size());
    DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
    assertEquals(String.class, dataSourceField.getType());
}
 
Example #5
Source File: FunctionInterfaceUtils.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * The missing toString() method.
 *
 * @param expression the expression
 * @return the string
 */
private static String missingToString(Function expression) {
    StringBuilder sb = new StringBuilder();
    sb.append(expression.getName());
    sb.append("(");
    List<org.opengis.filter.expression.Expression> params = expression.getParameters();
    if (params != null) {
        org.opengis.filter.expression.Expression exp;
        for (Iterator<org.opengis.filter.expression.Expression> it = params.iterator();
                it.hasNext(); ) {
            exp = it.next();
            sb.append("[");
            sb.append(exp);
            sb.append("]");
            if (it.hasNext()) {
                sb.append(", ");
            }
        }
    }
    sb.append(")");
    return sb.toString();
}
 
Example #6
Source File: FilterPanelv2.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds the expression.
 *
 * @param node the node
 * @return the expression
 */
private Expression addExpression(ExpressionNode node) {
    Expression expression = node.getExpression();

    if (expression instanceof LiteralExpressionImpl) {
        return expression;
    } else if (expression instanceof AttributeExpressionImpl) {
        return expression;
    } else if (expression instanceof FunctionExpressionImpl) {
        FunctionExpressionImpl functionExpression = (FunctionExpressionImpl) expression;

        return addFunctionExpression(node, expression, functionExpression);
    } else if (expression instanceof MathExpressionImpl) {
        MathExpressionImpl mathExpression = (MathExpressionImpl) expression;
        return addMathsExpression(node, mathExpression);
    } else if (expression instanceof Function) {
        Function function = (Function) expression;
        return addFunction(node, function);
    }
    return null;
}
 
Example #7
Source File: ExpressionNode.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the function optional.
 *
 * @param functionExpression the function expression
 * @param overallIndex the overall index
 * @param param the param
 * @return the int
 */
private int setFunctionOptional(
        Function functionExpression, int overallIndex, Parameter<?> param) {
    ExpressionNode childNode = new ExpressionNode();
    childNode.setParameter(param);
    childNode.setOptional();

    if (overallIndex < functionExpression.getParameters().size()) {
        childNode.setExpression(functionExpression.getParameters().get(overallIndex));
        childNode.setOptionalParamUsed(true);
    } else {
        childNode.setExpression(null);
    }
    overallIndex++;
    this.insert(childNode, this.getChildCount());
    return overallIndex;
}
 
Example #8
Source File: ExpressionNode.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/** Sets the function. */
private void setFunction() {
    Function functionExpression = (Function) this.expression;
    FunctionName functionName = functionExpression.getFunctionName();

    TypeManager.getInstance().setDataType(functionName.getReturn().getType());

    int overallIndex = 0;
    for (Parameter<?> param : functionName.getArguments()) {
        if (param.getMinOccurs() == 0) {
            overallIndex = setFunctionOptional(functionExpression, overallIndex, param);
        } else {
            overallIndex = setFunctionFixed(functionExpression, overallIndex, param);
        }
    }
}
 
Example #9
Source File: ExpressionNode.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the function fixed.
 *
 * @param functionExpression the function expression
 * @param overallIndex the overall index
 * @param param the param
 * @return the int
 */
private int setFunctionFixed(
        Function functionExpression, int overallIndex, Parameter<?> param) {
    for (int index = 0; index < param.getMinOccurs(); index++) {
        ExpressionNode childNode = new ExpressionNode();
        childNode.setParameter(param);

        if (index < functionExpression.getParameters().size()) {
            if (overallIndex < functionExpression.getParameters().size()) {
                childNode.setExpression(functionExpression.getParameters().get(overallIndex));
            } else {
                childNode.setExpression(null);
            }
        }

        overallIndex++;
        this.insert(childNode, this.getChildCount());
    }
    return overallIndex;
}
 
Example #10
Source File: ExtractAttributes.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Extract attribute.
 *
 * @param attributeType the attribute type
 * @param expression the expression
 * @param foundList the found list
 * @return the class
 */
protected Class<?> extractAttribute(
        Class<?> attributeType, Expression expression, List<String> foundList) {
    Class<?> returnType = String.class;

    if (expression instanceof AttributeExpressionImpl) {
        AttributeExpressionImpl attribute = (AttributeExpressionImpl) expression;
        extractPropertyAttribute(attributeType, foundList, attribute);
    } else if (expression instanceof Function) {
        Function function = (Function) expression;
        returnType = extractFunctionAttribute(foundList, function);
    } else if (expression instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) expression;
        returnType = extractLiteralAttribute(returnType, literal);
    }

    return returnType;
}
 
Example #11
Source File: VectorLayerFactory.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
private void visit(Expression expression) {
	if (expression instanceof Function) {
		Function f = (Function) expression;
		for (Expression param : f.getParameters()) {
			Object keyValue = param.evaluate(null);
			if (keyValue instanceof Map) {
				Object bf = ((Map) keyValue).get(BUFFER_SIZE);
				if (bf != null) {
					preRenderBuffer = Integer.parseInt(bf.toString());
				}
			}
		}
	}
}
 
Example #12
Source File: FilterPanelv2.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds the function.
 *
 * @param node the node
 * @param function the function
 * @return the expression
 */
private Expression addFunction(ExpressionNode node, Function function) {
    List<Expression> expList = new ArrayList<>();
    for (Expression exp : function.getParameters()) {
        expList.add(exp);
    }

    for (int index = 0; index < node.getChildCount(); index++) {
        ExpressionNode childNode = (ExpressionNode) node.getChildAt(index);
        expList.add(addExpression(childNode));
    }

    return function;
}
 
Example #13
Source File: FunctionInterfaceUtils.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Handle function interface.
 *
 * @param parentNode the parent node
 * @param index the index
 * @param expression the expression
 */
public static void handleFunctionInterface(
        ExpressionNode parentNode, int index, Expression expression) {
    Function function = (Function) parentNode.getExpression();

    List<Expression> parameterList = new ArrayList<>();
    for (Expression exp : function.getParameters()) {
        parameterList.add(exp);
    }

    if (index < parameterList.size()) {
        parameterList.remove(index);
    }

    if (expression != null) {
        parameterList.add(index, expression);
    }

    if (parentNode.getExpression() instanceof InterpolateFunction) {
        parentNode.setExpression(
                new InterpolateFunction(parameterList, function.getFallbackValue()));
    } else if (parentNode.getExpression() instanceof CategorizeFunction) {
        parentNode.setExpression(
                new CategorizeFunction(parameterList, function.getFallbackValue()));
    } else if (parentNode.getExpression() instanceof RecodeFunction) {
        parentNode.setExpression(
                new RecodeFunction(parameterList, function.getFallbackValue()));
    } else if (parentNode.getExpression() instanceof StringTemplateFunction) {
        parentNode.setExpression(
                new StringTemplateFunction(parameterList, function.getFallbackValue()));
    }
}
 
Example #14
Source File: ExpressionNode.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the expression.
 *
 * @param expression the expression to set
 */
public void setExpression(Expression expression) {
    this.expression = expression;
    if (expression instanceof LiteralExpressionImpl) {
        Object value = ((LiteralExpressionImpl) expression).getValue();
        if (value instanceof AttributeExpressionImpl) {
            this.expression = (AttributeExpressionImpl) value;
        }
    }

    setDisplayString();

    this.removeAllChildren();

    if (this.expression instanceof EnvFunction) {
        setEnvFunction();
    } else if (this.expression instanceof FunctionExpression) {
        setFunctionExpression();
    } else if (this.expression instanceof FunctionImpl) {
        setFunctionImpl();
    } else if (this.expression instanceof Function) {
        setFunction();
    } else if (expression instanceof MathExpressionImpl) {
        setMathExpression(expression);
    } else if (expression instanceof AttributeExpressionImpl) {
        //        AttributeExpressionImpl property = (AttributeExpressionImpl) expression;

        // TypeManager.getInstance().setLiteralType(literal.getValue().getClass());
    } else if (expression instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) expression;
        if (literal.getValue() != null) {
            TypeManager.getInstance().setDataType(literal.getValue().getClass());
        }
    }
}
 
Example #15
Source File: FunctionTableModel.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the expression.
 *
 * @param factory the factory
 * @return the expression
 */
public ProcessFunction getExpression(FunctionFactory factory) {
    if (factory == null) {
        return null;
    }

    List<Expression> overallParameterList = new ArrayList<>();

    for (ProcessFunctionParameterValue value : valueList) {
        List<Expression> parameterList = new ArrayList<>();
        parameterList.add(ff.literal(value.getName()));

        boolean setValue = true;
        if (value.isOptional()) {
            setValue = value.isIncluded();
        }

        if (setValue && (value.getObjectValue() != null)) {
            Expression expression = value.getObjectValue().getExpression();
            if (expression != null) {
                parameterList.add(expression);
            }
        }

        if (setValue) {
            Function function = factory.function(PARAMETER, parameterList, null);

            overallParameterList.add(function);
        }
    }

    if (this.selectedFunction.getFunctionName() == null) {
        return null;
    }
    Function processFunction =
            factory.function(
                    this.selectedFunction.getFunctionName(), overallParameterList, null);

    return (ProcessFunction) processFunction;
}
 
Example #16
Source File: ExtractTimeFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
private boolean containsTime(final Function function) {
  boolean yes = false;
  for (final Expression expression : function.getParameters()) {
    yes |= expressionContainsTime(expression);
  }
  return yes;
}
 
Example #17
Source File: FieldConfigGeometryFieldTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigGeometryField#generateExpression()}. Test method
 * for {@link
 * com.sldeditor.ui.detail.config.FieldConfigGeometryField#populateExpression(java.lang.Object)}.
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigGeometryField#populateField(java.lang.String)}.
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigGeometryField#setTestValue(com.sldeditor.ui.detail.config.FieldId,
 * java.lang.String)}. Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigGeometryField#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    class TestFieldConfigGeometryField extends FieldConfigGeometryField {

        public TestFieldConfigGeometryField(FieldConfigCommonData commonData) {
            super(commonData);
        }

        public Expression callGenerateExpression() {
            return generateExpression();
        }
    }

    TestFieldConfigGeometryField field =
            new TestFieldConfigGeometryField(
                    new FieldConfigCommonData(
                            String.class, FieldIdEnum.NAME, "test label", false, false));
    Expression actualExpression = field.callGenerateExpression();
    assertNull(actualExpression);

    field.createUI();
    TestDataSource testDataSource = new TestDataSource();
    @SuppressWarnings("unused")
    DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);

    field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);

    String expectedValue = "";
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedValue.compareTo(actualExpression.toString()) == 0);

    // Attribute expression
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Expression expectedExpression = ff.property(testDataSource.getDefaultGeometryField());
    field.populateExpression(expectedExpression);
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedExpression.toString().compareTo(actualExpression.toString()) == 0);

    // Literal expression
    expectedExpression = ff.literal(testDataSource.getDefaultGeometryField());
    field.populateExpression(expectedExpression);
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedExpression.toString().compareTo(actualExpression.toString()) == 0);

    // Property exists
    DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();

    List<Expression> expList = new ArrayList<Expression>();
    expList.add(ff.literal(TestDataSource.GEOMETRY_FIELD));
    Function func = functionFactory.function("PropertyExists", expList, null);
    expectedExpression = func;
    field.populateExpression(func);
    actualExpression = field.callGenerateExpression();
    assertTrue(TestDataSource.GEOMETRY_FIELD.compareTo(actualExpression.toString()) == 0);

    // Set null values
    field.populateField((String) null);
    String stringValue = field.getStringValue();
    assertNull(stringValue);

    field.populateExpression((String) null);
    stringValue = field.getStringValue();
    assertNull(stringValue);
}
 
Example #18
Source File: ExtractTimeFilterVisitor.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public Object visit(final Function expression, final Object data) {
  // used force full range if the expression contains a time
  // property...which is correct?
  return new TemporalConstraints();
}
 
Example #19
Source File: ExtractGeometryFilterVisitor.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public Object visit(final Function expression, final Object data) {
  return new ExtractGeometryFilterVisitorResult(infinity(), null);
}
 
Example #20
Source File: FilterToElastic.java    From elasticgeo with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Object visit(Function function, Object extraData) {
    throw new UnsupportedOperationException("Function support not implemented");
}
 
Example #21
Source File: ExpressionNodeTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.filter.v2.expression.ExpressionNode#setExpression(org.opengis.filter.expression.Expression)}.
 */
@Test
public void testSetExpression() {
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    ExpressionNode node = new ExpressionNode();

    // Test literal expression
    String expressionString = "Literalexpression";
    Expression literal = ff.literal(expressionString);
    node.setExpression(literal);
    String expected =
            Localisation.getField(ExpressionPanelv2.class, "ExpressionPanelv2.literal")
                    + " "
                    + expressionString;
    String actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);

    // Test attribute expression
    String propertyName = "testproperty";
    Expression attribute = ff.property(propertyName);
    node.setExpression(attribute);
    expected =
            Localisation.getField(ExpressionPanelv2.class, "ExpressionPanelv2.attribute")
                    + " ["
                    + attribute
                    + "]";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);

    // Test attribute expression
    literal = ff.literal(ff.property(propertyName));
    node.setExpression(literal);
    expected =
            Localisation.getField(ExpressionPanelv2.class, "ExpressionPanelv2.attribute")
                    + " ["
                    + attribute
                    + "]";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);

    // Test math expression
    Expression maths = ff.multiply(ff.literal(6), ff.literal(7));
    node.setExpression(maths);
    expected = "*";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);

    // Test function
    FunctionImpl function = new ConcatenateFunction();
    List<Expression> params = new ArrayList<Expression>();
    params.add(ff.literal("world"));
    params.add(ff.literal("dog"));
    function.setParameters(params);
    node.setExpression(function);
    expected = "Concatenate([world], [dog])";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);

    // Test function expression
    DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
    String name = "strConcat";
    List<Expression> parameters = new ArrayList<Expression>();
    parameters.add(ff.literal("cat"));
    parameters.add(ff.literal("dog"));
    Function functionExpression = functionFactory.function(name, parameters, null);
    node.setExpression(functionExpression);
    expected = "strConcat([cat], [dog])";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);

    // Test environment function
    EnvFunction envExpression =
            (EnvFunction) ff.function("env", ff.literal("foo"), ff.literal(0));
    node.setExpression(envExpression);
    expected = "env([foo], [0])";
    actual = node.toString();
    assertTrue(actual.compareTo(expected) == 0);
}
 
Example #22
Source File: FunctionField.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Gets the expression.
 *
 * @return the expression
 */
public Expression getExpression() {
    String functionNameString = (String) functionComboBox.getSelectedItem();

    FunctionName functionName = functionNameMap.get(functionNameString);

    if (functionName == null) {
        return null;
    }

    Expression newExpression = functionNameMgr.createExpression(functionName);

    int argCount = functionName.getArgumentCount();
    if (argCount < 0) {
        argCount *= -1;
    }
    if (newExpression instanceof FunctionExpression) {
        getFunctionExpression(newExpression, argCount);
    } else if (newExpression instanceof ConcatenateFunction) {
        getConcatenate(newExpression, argCount);
    } else if (newExpression instanceof Function) {
        Function function = (Function) newExpression;

        List<Expression> params = new ArrayList<>();

        for (Parameter<?> param : functionName.getArguments()) {
            for (int index = 0; index < param.getMinOccurs(); index++) {
                params.add(null);
            }
        }
        boolean validSymbolFlag = (params.size() == argCount);
        if (validSymbolFlag) {
            Expression retValue =
                    FunctionInterfaceUtils.createNewFunction(newExpression, params);

            if (retValue != null) {
                return retValue;
            } else {
                ((FunctionExpression) function).setParameters(params);
            }
        }
    }

    return newExpression;
}
 
Example #23
Source File: ExpressionNode.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/** Sets the display string. */
public void setDisplayString() {
    StringBuilder sb = new StringBuilder();

    if (name != null) {
        sb.append(name);
        sb.append(" : ");
    }

    if (expression == null) {
        setDisplayStringNoExpression(sb);
    }

    if (expression instanceof LiteralExpressionImpl) {
        sb.append(
                Localisation.getField(ExpressionPanelv2.class, "ExpressionPanelv2.literal")
                        + " ");
        sb.append(expression.toString());
    } else if (expression instanceof AttributeExpressionImpl) {
        sb.append(
                String.format(
                        "%s : [%s]",
                        Localisation.getString(
                                ExpressionPanelv2.class, "ExpressionPanelv2.attribute"),
                        expression.toString()));
    } else if (expression instanceof FunctionExpressionImpl) {
        sb.append(FunctionExpressionUtils.toString(expression));
    } else if (expression instanceof FunctionImpl) {
        sb.append(expression.toString());
    } else if (expression instanceof Function) {
        sb.append(FunctionInterfaceUtils.toString(expression));
    } else if (expression instanceof MathExpressionImpl) {
        if (mathExpressionMap.isEmpty()) {
            mathExpressionMap.put(AddImpl.class, "+");
            mathExpressionMap.put(SubtractImpl.class, "-");
            mathExpressionMap.put(DivideImpl.class, "/");
            mathExpressionMap.put(MultiplyImpl.class, "*");
        }

        String str = mathExpressionMap.get(expression.getClass());
        sb.append(str);
    }

    displayString = sb.toString();
}
 
Example #24
Source File: ExpressionSubPanel.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Display expression.
 *
 * @param node the node
 */
@SuppressWarnings("unchecked")
private void displayExpression(ExpressionNode node) {

    if (panelLiteral.getComponentCount() == 2) {
        panelLiteral.remove(1);
    }

    if (node == null) {
        return;
    }

    List<String> enumList = null;
    Parameter<?> param = node.getParameter();
    if (param instanceof org.geotools.data.Parameter<?>) {
        org.geotools.data.Parameter<?> paramData = (org.geotools.data.Parameter<?>) param;
        Object obj = paramData.metadata.get(org.geotools.data.Parameter.OPTIONS);
        if (obj instanceof List<?>) {
            enumList = (List<String>) obj;
        }
    }

    fieldConfig =
            PanelField.getField(
                    ExpressionPanelv2.class,
                    "ExpressionSubPanel.value",
                    node.getType(),
                    enumList,
                    node.getMaxStringSize(),
                    node.isRegExpString(),
                    false);

    if (fieldConfig != null) {
        fieldConfig.createUI();
        fieldConfig.addDataChangedListener(
                new UpdateSymbolInterface() {
                    @Override
                    public void dataChanged(FieldIdEnum changedField) {
                        buttonGroup.setSelected(rdbtnLiteral.getModel(), true);
                        updateButtonState(true);
                    }
                });

        // Set the size of the panels so they all align
        FieldPanel panel = fieldConfig.getPanel();
        Dimension dimension = panel.getPreferredSize();
        panel.setMaximumSize(dimension);

        dataSourceAttributePanel.setMaximumSize(
                new Dimension(dimension.width, BasePanel.WIDGET_HEIGHT));

        if (envVarField != null) {
            envVarField.setMaximumSize(new Dimension(dimension.width, BasePanel.WIDGET_HEIGHT));
        }

        functionPanel.setMaximumSize(
                new Dimension(dimension.width, BasePanel.WIDGET_HEIGHT * 3));

        panelLiteral.add(panel);

        // Reset the fields
        dataSourceAttributePanel.setAttribute(null);
        functionPanel.setDataType(node.getType());
        functionPanel.setFunction(null, null);

        dataSourceAttributePanel.setDataType(node.getType());

        Expression expression = node.getExpression();

        if (expression instanceof AttributeExpressionImpl) {
            dataSourceAttributePanel.setAttribute(expression);
            buttonGroup.setSelected(rdbtnAttribute.getModel(), true);
        } else if (expression instanceof EnvFunction) {
            if (envVarField != null) {
                envVarField.setEnvironmentVariable(expression);
                buttonGroup.setSelected(rdbtnEnvVar.getModel(), true);
            }
        } else if ((expression instanceof FunctionExpressionImpl)
                || (expression instanceof ConcatenateFunction)
                || (expression instanceof Function)) {
            functionPanel.setFunction(expression, node);
            buttonGroup.setSelected(rdbtnFunction.getModel(), true);
        } else {
            fieldConfig.populate(expression);
            buttonGroup.setSelected(rdbtnLiteral.getModel(), true);
        }

        // Now work out whether the Remove Parameter button should be displayed
        displayRemoveParameterButton(node);
    }
    Dimension boxSize = box.getPreferredSize();
    setPreferredSize(boxSize);
    revalidate();
}