Search in sources :

Example 6 with FieldConfigGeometryField

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

the class FieldConfigGeometryFieldTest method testCreateCopy.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
 */
@Test
public void testCreateCopy() {
    class TestFieldConfigGeometryField extends FieldConfigGeometryField {

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

        public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
            return createCopy(fieldConfigBase);
        }
    }
    TestFieldConfigGeometryField field = new TestFieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", true));
    FieldConfigGeometryField copy = (FieldConfigGeometryField) field.callCreateCopy(null);
    assertNull(copy);
    copy = (FieldConfigGeometryField) field.callCreateCopy(field);
    assertEquals(field.getFieldId(), copy.getFieldId());
    assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
    assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigGeometryField(com.sldeditor.ui.detail.config.FieldConfigGeometryField) Test(org.junit.Test)

Example 7 with FieldConfigGeometryField

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

the class FieldConfigGeometryFieldTest method testRevertToDefaultValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#revertToDefaultValue()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigGeometryField#setDefaultValue(java.lang.String)}.
 */
@Test
public void testRevertToDefaultValue() {
    FieldConfigGeometryField field = new FieldConfigGeometryField(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", true));
    TestDataSource testDataSource = new TestDataSource();
    String expectedDefaultValue = testDataSource.getDefaultGeometryField();
    field.setDefaultValue(expectedDefaultValue);
    field.revertToDefaultValue();
    field.createUI();
    field.revertToDefaultValue();
    assertNull(field.getStringValue());
    field.createUI();
    @SuppressWarnings("unused") DataSourceInterface dataSource = DataSourceFactory.createDataSource(testDataSource);
    field.createUI();
    field.dataSourceLoaded(GeometryTypeEnum.POLYGON, false);
    field.revertToDefaultValue();
    assertTrue(expectedDefaultValue.compareTo(field.getStringValue()) == 0);
}
Also used : DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) CreateDataSourceInterface(com.sldeditor.datasource.impl.CreateDataSourceInterface) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigGeometryField(com.sldeditor.ui.detail.config.FieldConfigGeometryField) Test(org.junit.Test)

Aggregations

FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)7 FieldConfigGeometryField (com.sldeditor.ui.detail.config.FieldConfigGeometryField)7 Test (org.junit.Test)7 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)3 CreateDataSourceInterface (com.sldeditor.datasource.impl.CreateDataSourceInterface)3 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 FilterFactory (org.opengis.filter.FilterFactory)1 Expression (org.opengis.filter.expression.Expression)1