Search in sources :

Example 6 with FieldConfigTimePeriod

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

the class FieldConfigTimePeriodTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#internal_setEnabled(boolean)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#isEnabled()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#createUI(javax.swing.Box)}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigTimePeriod field = new FieldConfigTimePeriod(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, null, 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;
    FieldConfigTimePeriod field2 = new FieldConfigTimePeriod(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, null, 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 : FieldConfigTimePeriod(com.sldeditor.ui.detail.config.FieldConfigTimePeriod) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 7 with FieldConfigTimePeriod

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

the class FieldConfigTimePeriodTest method testRevertToDefaultValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#revertToDefaultValue()}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigTimePeriod#getStringValue()}.
 */
@Test
public void testRevertToDefaultValue() {
    boolean valueOnly = true;
    FieldConfigTimePeriod field = new FieldConfigTimePeriod(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, null, valueOnly));
    field.revertToDefaultValue();
    assertNotNull(field.getStringValue());
    field.createUI();
    field.revertToDefaultValue();
    String expectedDefaultValue = "default value";
    assertTrue(expectedDefaultValue.compareTo(field.getStringValue()) != 0);
}
Also used : FieldConfigTimePeriod(com.sldeditor.ui.detail.config.FieldConfigTimePeriod) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)7 FieldConfigTimePeriod (com.sldeditor.ui.detail.config.FieldConfigTimePeriod)7 Test (org.junit.Test)7 TimePeriod (com.sldeditor.filter.v2.function.temporal.TimePeriod)2 Duration (com.sldeditor.filter.v2.function.temporal.Duration)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 DefaultInstant (org.geotools.temporal.object.DefaultInstant)1 DefaultPeriod (org.geotools.temporal.object.DefaultPeriod)1 DefaultPosition (org.geotools.temporal.object.DefaultPosition)1 Expression (org.opengis.filter.expression.Expression)1