Search in sources :

Example 6 with FieldConfigSortBy

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

the class FieldConfigSortByTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSortBy#generateExpression()}. Test method
 * for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSortBy#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    class TestFieldConfigSortBy extends FieldConfigSortBy {

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

        public Expression callGenerateExpression() {
            return generateExpression();
        }
    }
    TestFieldConfigSortBy field = new TestFieldConfigSortBy(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
    Expression actualExpression = field.callGenerateExpression();
    assertNull(actualExpression);
    field.createUI();
    String expectedValue = "test A, test2 D";
    field.setTestValue(null, expectedValue);
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedValue.compareTo(actualExpression.toString()) == 0);
    expectedValue = "test A, test3 A";
    field.populateExpression("test, test3 A");
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedValue.compareTo(actualExpression.toString()) == 0);
    expectedValue = "test A, test2 D, test3 D";
    field.populateField(expectedValue);
    field.sortByUpdated(expectedValue);
    actualExpression = field.callGenerateExpression();
    assertTrue(expectedValue.compareTo(actualExpression.toString()) == 0);
}
Also used : FieldConfigSortBy(com.sldeditor.ui.detail.config.sortby.FieldConfigSortBy) Expression(org.opengis.filter.expression.Expression) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 7 with FieldConfigSortBy

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

the class FieldConfigSortByTest method testAttributeSelection.

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

Example 8 with FieldConfigSortBy

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

the class FieldConfigSortByTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSortBy#internal_setEnabled(boolean)}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigSortBy#isEnabled()}. Test method
 * for {@link com.sldeditor.ui.detail.config.FieldConfigSortBy#createUI(javax.swing.Box)}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigSortBy field = new FieldConfigSortBy(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test 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;
    FieldConfigSortBy field2 = new FieldConfigSortBy(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test 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 = true;
    field2.internal_setEnabled(expectedValue);
    // Actual value is coming from the attribute panel, not the text field
    assertEquals(expectedValue, field2.isEnabled());
}
Also used : FieldConfigSortBy(com.sldeditor.ui.detail.config.sortby.FieldConfigSortBy) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Aggregations

FieldConfigSortBy (com.sldeditor.ui.detail.config.sortby.FieldConfigSortBy)8 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)7 Test (org.junit.Test)7 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 XMLFieldConfigBoolean (com.sldeditor.common.xml.ui.XMLFieldConfigBoolean)1 XMLFieldConfigColour (com.sldeditor.common.xml.ui.XMLFieldConfigColour)1 XMLFieldConfigColourMap (com.sldeditor.common.xml.ui.XMLFieldConfigColourMap)1 XMLFieldConfigDSProperties (com.sldeditor.common.xml.ui.XMLFieldConfigDSProperties)1 XMLFieldConfigDouble (com.sldeditor.common.xml.ui.XMLFieldConfigDouble)1 XMLFieldConfigEnum (com.sldeditor.common.xml.ui.XMLFieldConfigEnum)1 FieldList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)1 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)1 XMLFieldConfigFeatureTypeConstraint (com.sldeditor.common.xml.ui.XMLFieldConfigFeatureTypeConstraint)1 XMLFieldConfigFont (com.sldeditor.common.xml.ui.XMLFieldConfigFont)1 XMLFieldConfigFontPreview (com.sldeditor.common.xml.ui.XMLFieldConfigFontPreview)1 XMLFieldConfigGeometry (com.sldeditor.common.xml.ui.XMLFieldConfigGeometry)1 XMLFieldConfigGeometryField (com.sldeditor.common.xml.ui.XMLFieldConfigGeometryField)1 XMLFieldConfigInlineFeature (com.sldeditor.common.xml.ui.XMLFieldConfigInlineFeature)1 XMLFieldConfigInteger (com.sldeditor.common.xml.ui.XMLFieldConfigInteger)1