Search in sources :

Example 41 with FieldConfigCommonData

use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.

the class FieldConfigBaseTest method testFunctionUpdated.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBase#functionUpdated(org.opengis.filter.expression.Expression)}.
 */
@Test
public void testFunctionUpdated() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
    TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
    field.addDataChangedListener(listener);
    assertFalse(listener.hasBeenCalled());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    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.functionUpdated(testExpression);
    assertTrue(listener.hasBeenCalled());
    assertEquals(ExpressionTypeEnum.E_FUNCTION, field.getExpressionType());
    Expression expression = field.getExpression();
    assertTrue(expression.toString().startsWith(functionName.getName()));
}
Also used : FunctionName(org.opengis.filter.capability.FunctionName) DefaultFunctionFactory(org.geotools.filter.function.DefaultFunctionFactory) Expression(org.opengis.filter.expression.Expression) 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)

Example 42 with FieldConfigCommonData

use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.

the class FieldConfigBooleanTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoolean#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoolean#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigBoolean field = new FieldConfigBoolean(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    field.populateField(Boolean.TRUE);
    field.populateField(Boolean.FALSE);
    assertFalse(field.getBooleanValue());
    UndoManager.getInstance().undo();
    assertTrue(field.getBooleanValue());
    UndoManager.getInstance().redo();
    assertFalse(field.getBooleanValue());
    field.setTestValue(null, true);
    assertTrue(field.getBooleanValue());
    assertTrue(field.getStringValue().toLowerCase().compareTo("true") == 0);
    // Increase the code coverage
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigBoolean(com.sldeditor.ui.detail.config.FieldConfigBoolean) Test(org.junit.Test)

Example 43 with FieldConfigCommonData

use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.

the class FieldConfigBooleanTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoolean#generateExpression()}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    FieldConfigBoolean field = new FieldConfigBoolean(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
    field.setTestValue(null, true);
    field.populateField((Boolean) null);
    field.populateField(Boolean.TRUE);
    field.populateExpression(null);
    field.createUI();
    field.createUI();
    field.populateField(Boolean.TRUE);
    assertTrue(field.getBooleanValue());
    field.populateExpression(Boolean.FALSE);
    assertFalse(field.getBooleanValue());
    field.setTestValue(null, true);
    assertTrue(field.getBooleanValue());
    assertTrue(field.getStringValue().toLowerCase().compareTo("true") == 0);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigBoolean(com.sldeditor.ui.detail.config.FieldConfigBoolean) Test(org.junit.Test)

Example 44 with FieldConfigCommonData

use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.

the class FieldConfigBoundingBoxTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#internal_setEnabled(boolean)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#isEnabled()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBoundingBox#createUI(javax.swing.Box)}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigBoundingBox field = new FieldConfigBoundingBox(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
    // Text field will not have been created
    boolean expectedValue = true;
    field.internal_setEnabled(expectedValue);
    assertFalse(field.isEnabled());
    // Create text field
    field.createUI();
    assertEquals(expectedValue, field.isEnabled());
    expectedValue = false;
    field.internal_setEnabled(expectedValue);
    assertEquals(expectedValue, field.isEnabled());
    // Has attribute/expression dropdown
    valueOnly = false;
    FieldConfigBoundingBox field2 = new FieldConfigBoundingBox(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
    // Text field will not have been created
    expectedValue = true;
    field2.internal_setEnabled(expectedValue);
    assertFalse(field2.isEnabled());
    // Create text field
    field2.createUI();
    assertEquals(expectedValue, field2.isEnabled());
    expectedValue = false;
    field2.internal_setEnabled(expectedValue);
    // Actual value is coming from the attribute panel, not the text field
    assertEquals(!expectedValue, field2.isEnabled());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigBoundingBox(com.sldeditor.ui.detail.config.FieldConfigBoundingBox) Test(org.junit.Test)

Example 45 with FieldConfigCommonData

use of com.sldeditor.ui.detail.config.FieldConfigCommonData in project sldeditor by robward-scisys.

the class FieldConfigColourTest method testAttributeSelection.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigColour#attributeSelection(java.lang.String)}.
 */
@Test
public void testAttributeSelection() {
    boolean valueOnly = true;
    FieldConfigColour field = new FieldConfigColour(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", valueOnly));
    field.attributeSelection(null);
// Does nothing
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) Test(org.junit.Test)

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)322 Test (org.junit.Test)316 Geometry (com.vividsolutions.jts.geom.Geometry)69 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)54 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)44 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)38 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)34 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)24 StyleBuilder (org.geotools.styling.StyleBuilder)24 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)22 UndoEvent (com.sldeditor.common.undo.UndoEvent)20 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)20 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)20 Expression (org.opengis.filter.expression.Expression)20 FieldConfigWindBarbs (com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs)18 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)17 FieldConfigTTF (com.sldeditor.ui.detail.config.symboltype.ttf.FieldConfigTTF)17 FieldConfigFilename (com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename)16 FieldConfigArrow (com.sldeditor.ui.detail.vendor.geoserver.marker.arrow.FieldConfigArrow)16 FieldConfigWKT (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.FieldConfigWKT)16