Search in sources :

Example 1 with UpdateSymbolInterface

use of com.sldeditor.ui.iface.UpdateSymbolInterface in project sldeditor by robward-scisys.

the class ExpressionSubPanel method displayExpression.

/**
 * Display expression.
 *
 * @param node the node
 */
private void displayExpression(ExpressionNode node) {
    if (panelLiteral.getComponentCount() == 2) {
        panelLiteral.remove(1);
    }
    if (node == null) {
        return;
    }
    fieldConfig = PanelField.getField(ExpressionPanelv2.class, "ExpressionSubPanel.value", node.getType());
    if (fieldConfig != null) {
        fieldConfig.createUI();
        fieldConfig.addDataChangedListener(new UpdateSymbolInterface() {

            @Override
            public void dataChanged(FieldIdEnum changedField) {
                buttonGroup.setSelected(rdbtnLiteral.getModel(), true);
                updateButtonState(true);
            }
        });
        panelLiteral.add(fieldConfig.getPanel());
        // Reset the fields
        dataSourceAttributePanel.setAttribute(null);
        functionPanel.setFunction(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) {
            envVarField.setEnvironmentVariable(expression);
            buttonGroup.setSelected(rdbtnEnvVar.getModel(), true);
        } else if (expression instanceof FunctionExpressionImpl) {
            functionPanel.setFunction(expression);
            buttonGroup.setSelected(rdbtnFunction.getModel(), true);
        } else {
            fieldConfig.populate(expression);
            buttonGroup.setSelected(rdbtnLiteral.getModel(), true);
        }
    }
    Dimension boxSize = box.getPreferredSize();
    setPreferredSize(boxSize);
    revalidate();
}
Also used : EnvFunction(org.geotools.filter.function.EnvFunction) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) UpdateSymbolInterface(com.sldeditor.ui.iface.UpdateSymbolInterface) Dimension(java.awt.Dimension) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 2 with UpdateSymbolInterface

use of com.sldeditor.ui.iface.UpdateSymbolInterface in project sldeditor by robward-scisys.

the class LiteralPanel method displayLiteral.

/**
 * Display literal value.
 *
 * @param node the node
 */
private void displayLiteral(ExpressionNode node) {
    if (node == null) {
        return;
    }
    if (fieldConfig != null) {
        remove(fieldConfig.getPanel());
    }
    fieldConfig = PanelField.getField(ExpressionPanelv2.class, "LiteralPanel.value", node.getType());
    if (fieldConfig != null) {
        fieldConfig.createUI();
        fieldConfig.addDataChangedListener(new UpdateSymbolInterface() {

            @Override
            public void dataChanged(FieldIdEnum changedField) {
                updateButtonState(true);
            }
        });
        add(fieldConfig.getPanel(), BorderLayout.NORTH);
        fieldConfig.populate(node.getExpression());
    }
    revalidate();
}
Also used : UpdateSymbolInterface(com.sldeditor.ui.iface.UpdateSymbolInterface) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum)

Aggregations

FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 UpdateSymbolInterface (com.sldeditor.ui.iface.UpdateSymbolInterface)2 Dimension (java.awt.Dimension)1 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)1 FunctionExpressionImpl (org.geotools.filter.FunctionExpressionImpl)1 EnvFunction (org.geotools.filter.function.EnvFunction)1 Expression (org.opengis.filter.expression.Expression)1