Search in sources :

Example 1 with AttributeSelection

use of com.sldeditor.ui.attribute.AttributeSelection in project sldeditor by robward-scisys.

the class FieldConfigBaseTest method testSetValueFieldState.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBase#setValueFieldState()}.
 */
@Test
public void testSetValueFieldState() {
    boolean valueOnly = true;
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, valueOnly));
    AttributeSelection attributeSelectionPanel = AttributeSelection.createAttributes(String.class, field, false);
    attributeSelectionPanel.setEnabled(true);
    field.testAttributeSelectionPanel(attributeSelectionPanel);
    field.testSetValueFieldState();
    assertFalse(field.isEnabled());
    assertTrue(field.getAttributeSelectionPanel().isEnabled());
    boolean fieldEnabledFlag = false;
    field.testSetValueFieldState();
    assertEquals(fieldEnabledFlag, field.isEnabled());
    field.attributeUpdated("");
    assertEquals(fieldEnabledFlag, field.isEnabled());
}
Also used : AttributeSelection(com.sldeditor.ui.attribute.AttributeSelection) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) Test(org.junit.Test)

Example 2 with AttributeSelection

use of com.sldeditor.ui.attribute.AttributeSelection in project sldeditor by robward-scisys.

the class FieldPanel method internalCreateAttrButton.

/**
 * Internal create attribute button.
 *
 * @param classType the class type
 * @param field the field
 * @param rasterSymbol the raster symbol
 * @return the attribute selection
 */
public AttributeSelection internalCreateAttrButton(Class<?> classType, FieldConfigBase field, boolean rasterSymbol) {
    AttributeSelection buttonAttrLabel = AttributeSelection.createAttributes(classType, field, rasterSymbol);
    buttonAttrLabel.setBounds(xPos + BasePanel.ATTRIBUTE_BTN_X, 0, AttributeSelection.getPanelWidth(), BasePanel.WIDGET_HEIGHT);
    add(buttonAttrLabel);
    return buttonAttrLabel;
}
Also used : AttributeSelection(com.sldeditor.ui.attribute.AttributeSelection)

Example 3 with AttributeSelection

use of com.sldeditor.ui.attribute.AttributeSelection in project sldeditor by robward-scisys.

the class FieldConfigBaseTest method testPopulateExpressionExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression)}.
 */
@Test
public void testPopulateExpressionExpression() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
    AttributeSelection attributeSelectionPanel = AttributeSelection.createAttributes(String.class, field, false);
    field.testAttributeSelectionPanel(attributeSelectionPanel);
    TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
    field.addDataChangedListener(listener);
    assertFalse(listener.hasBeenCalled());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    // Test function
    DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
    FunctionName functionName = null;
    for (FunctionName func : functionFactory.getFunctionNames()) {
        if (func.getName() == "greaterThan") {
            functionName = func;
            break;
        }
    }
    assertNotNull(functionName);
    Expression testExpression = ff.function(functionName.getFunctionName(), ff.literal(1), ff.literal(2));
    field.populate(testExpression);
    // Updated because the attribute pulldown changed
    assertTrue(listener.hasBeenCalled());
    assertEquals(ExpressionTypeEnum.E_EXPRESSION, field.getExpressionType());
    Expression expression = field.getExpression();
    assertTrue(expression.toString().startsWith(functionName.getName()));
    // Attribute expression wrapped in a literal expression
    String testAttributeName = "test attribute";
    NameImpl name = new NameImpl(testAttributeName);
    AttributeExpressionImpl attributeExpression = new AttributeExpressionImpl(name);
    Expression literalExpression = ff.literal(attributeExpression);
    field.populate(literalExpression);
    assertEquals(ExpressionTypeEnum.E_ATTRIBUTE, field.getExpressionType());
// Process Function
// ProcessFunctionFactory factory = new ProcessFunctionFactory();
// FunctionTableModel functionParameterTableModel = new FunctionTableModel();
// ProcessFunction processFunction = functionParameterTableModel.getExpression(factory);
// field.populate(processFunction);
// assertEquals(ExpressionTypeEnum.E_VALUE, field.getExpressionType());
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName) NameImpl(org.geotools.feature.NameImpl) DefaultFunctionFactory(org.geotools.filter.function.DefaultFunctionFactory) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) AttributeSelection(com.sldeditor.ui.attribute.AttributeSelection) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Aggregations

AttributeSelection (com.sldeditor.ui.attribute.AttributeSelection)3 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)2 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)2 Test (org.junit.Test)2 NameImpl (org.geotools.feature.NameImpl)1 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)1 DefaultFunctionFactory (org.geotools.filter.function.DefaultFunctionFactory)1 FilterFactory (org.opengis.filter.FilterFactory)1 FunctionName (org.opengis.filter.capability.FunctionName)1 Expression (org.opengis.filter.expression.Expression)1