Search in sources :

Example 1 with FieldConfigInlineFeature

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

the class FieldConfigInlineFeatureTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    FieldConfigInlineFeature field = new FieldConfigInlineFeature(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, null, true));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    DummyInlineSLDFile testData1 = new DummyInlineSLDFile();
    UserLayer userLayer1 = (UserLayer) testData1.getSLD().layers().get(0);
    field.populateField(userLayer1);
    String expectedValue1 = InlineFeatureUtils.getInlineFeaturesText(userLayer1);
    String actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(expectedValue1) == 0);
    DummyInlineSLDFile2 testData2 = new DummyInlineSLDFile2();
    UserLayer userLayer2 = (UserLayer) testData2.getSLD().layers().get(0);
    field.populateField(userLayer2);
    String expectedValue2 = InlineFeatureUtils.getInlineFeaturesText(userLayer2);
    actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(expectedValue2) == 0);
    UndoManager.getInstance().undo();
    actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(expectedValue1) == 0);
    UndoManager.getInstance().redo();
    actualValue = field.getStringValue();
    assertTrue(actualValue.compareTo(expectedValue2) == 0);
    // Increase the code coverage
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(42.0), Integer.valueOf(11)));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(454.0), Integer.valueOf(69)));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) UndoEvent(com.sldeditor.common.undo.UndoEvent) DummyInlineSLDFile2(com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile2) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) DummyInlineSLDFile(com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile) UserLayer(org.geotools.styling.UserLayer) FieldConfigInlineFeature(com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature) Test(org.junit.Test)

Example 2 with FieldConfigInlineFeature

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

the class FieldConfigInlineFeatureTest method testSetVisible.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#setVisible(boolean)}.
 */
@Test
public void testSetVisible() {
    FieldConfigInlineFeature field = new FieldConfigInlineFeature(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, null, true));
    boolean expectedValue = true;
    field.setVisible(expectedValue);
    field.createUI();
    field.setVisible(expectedValue);
    expectedValue = false;
    field.setVisible(expectedValue);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigInlineFeature(com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature) Test(org.junit.Test)

Example 3 with FieldConfigInlineFeature

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

the class FieldConfigInlineFeatureTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#internal_setEnabled(boolean)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature#isEnabled()}.
 */
@Test
public void testSetEnabled() {
    FieldConfigInlineFeature field = new FieldConfigInlineFeature(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, null, true));
    // Field will not have been created
    boolean expectedValue = true;
    field.internal_setEnabled(expectedValue);
    assertFalse(field.isEnabled());
    // Create text field
    field.createUI();
    field.createUI();
    assertEquals(expectedValue, field.isEnabled());
    expectedValue = false;
    field.internal_setEnabled(expectedValue);
    assertEquals(expectedValue, field.isEnabled());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigInlineFeature(com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature) Test(org.junit.Test)

Example 4 with FieldConfigInlineFeature

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

the class FieldConfigInlineFeatureTest method testCreateCopy.

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

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

        public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
            return createCopy(fieldConfigBase);
        }
    }
    TestFieldConfigInlineFeature field = new TestFieldConfigInlineFeature(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "", true));
    FieldConfigInlineFeature copy = (FieldConfigInlineFeature) field.callCreateCopy(null);
    assertNull(copy);
    copy = (FieldConfigInlineFeature) field.callCreateCopy(field);
    assertEquals(field.getFieldId(), copy.getFieldId());
    assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
    assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigInlineFeature(com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature) Test(org.junit.Test)

Example 5 with FieldConfigInlineFeature

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

the class ReadPanelConfig method addField.

/**
 * Adds the field.
 *
 * @param localisationClass the localisation class
 * @param panelId the panel id
 * @param groupConfig the group config
 * @param xmlFieldConfig the xml field config
 */
private void addField(Class<?> localisationClass, Class<?> panelId, GroupConfig groupConfig, XMLFieldConfigData xmlFieldConfig) {
    FieldIdEnum id = xmlFieldConfig.getId();
    String label = getLocalisedText(localisationClass, xmlFieldConfig.getLabel());
    boolean valueOnly = xmlFieldConfig.getValueOnly();
    String defaultValue = xmlFieldConfig.getDefault();
    boolean multipleValues = xmlFieldConfig.getMultipleValues();
    FieldConfigCommonData commonData = new FieldConfigCommonData(panelId, id, label, valueOnly, isRasterSymbol, multipleValues);
    if (xmlFieldConfig instanceof XMLFieldConfigString) {
        XMLFieldConfigString xmlStringFieldConfig = (XMLFieldConfigString) xmlFieldConfig;
        FieldConfigString stringConfig = new FieldConfigString(commonData, getLocalisedText(localisationClass, xmlStringFieldConfig.getButtonText()));
        stringConfig.setSuppressUpdatesOnSet(xmlStringFieldConfig.getSuppressUpdateOnSet());
        groupConfig.addField(stringConfig);
        String defaultValueObj = ConfigDefaultFactory.getString(defaultValue);
        if (defaultValueObj != null) {
            stringConfig.setDefaultValue(defaultValueObj);
            defaultFieldMap.put(id, defaultValueObj);
        }
    } else if (xmlFieldConfig instanceof XMLFieldConfigColourMap) {
        commonData.setValueOnly(true);
        FieldConfigColourMap colourMapConfig = new FieldConfigColourMap(commonData);
        groupConfig.addField(colourMapConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigFeatureTypeConstraint) {
        FieldConfigFeatureTypeConstraint stringConfig = new FieldConfigFeatureTypeConstraint(commonData);
        groupConfig.addField(stringConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigSortBy) {
        FieldConfigSortBy sortByConfig = new FieldConfigSortBy(commonData);
        groupConfig.addField(sortByConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigDSProperties) {
        FieldConfigDSProperties dsPropertiesConfig = new FieldConfigDSProperties(commonData);
        groupConfig.addField(dsPropertiesConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigGeometryField) {
        FieldConfigGeometryField geometryFieldConfig = new FieldConfigGeometryField(commonData);
        DataSourceInterface dataSource = DataSourceFactory.getDataSource();
        if (dataSource != null) {
            dataSource.addListener(geometryFieldConfig);
        }
        groupConfig.addField(geometryFieldConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigFont) {
        FieldConfigFont fontConfig = new FieldConfigFont(commonData);
        groupConfig.addField(fontConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigInlineFeature) {
        FieldConfigInlineFeature inlineFeatureConfig = new FieldConfigInlineFeature(commonData);
        groupConfig.addField(inlineFeatureConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigFontPreview) {
        FieldConfigFontPreview fontPreviewConfig = new FieldConfigFontPreview(commonData);
        groupConfig.addField(fontPreviewConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigTransformation) {
        XMLFieldConfigTransformation xmlTransformationFieldConfig = (XMLFieldConfigTransformation) xmlFieldConfig;
        FieldConfigTransformation transformationConfig = new FieldConfigTransformation(commonData, getLocalisedText(localisationClass, xmlTransformationFieldConfig.getEditButtonText()), getLocalisedText(localisationClass, xmlTransformationFieldConfig.getClearButtonText()));
        groupConfig.addField(transformationConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigGeometry) {
        XMLFieldConfigGeometry xmlGeometryFieldConfig = (XMLFieldConfigGeometry) xmlFieldConfig;
        FieldConfigGeometry geometryConfig = new FieldConfigGeometry(commonData, getLocalisedText(localisationClass, xmlGeometryFieldConfig.getButtonText()));
        groupConfig.addField(geometryConfig);
        String defaultValueObj = ConfigDefaultFactory.getString(defaultValue);
        if (defaultValueObj != null) {
            geometryConfig.setDefaultValue(defaultValueObj);
            defaultFieldMap.put(id, defaultValueObj);
        }
    } else if (xmlFieldConfig instanceof XMLFieldConfigBoolean) {
        FieldConfigBoolean boolConfig = new FieldConfigBoolean(commonData);
        groupConfig.addField(boolConfig);
        Boolean defaultValueObj = ConfigDefaultFactory.getBoolean(defaultValue);
        if (defaultValueObj != null) {
            boolConfig.setDefaultValue(defaultValueObj);
            defaultFieldMap.put(id, defaultValueObj);
        }
    } else if (xmlFieldConfig instanceof XMLFieldConfigDouble) {
        FieldConfigDouble doubleConfig = new FieldConfigDouble(commonData);
        XMLFieldConfigDouble xmlDouble = (XMLFieldConfigDouble) xmlFieldConfig;
        doubleConfig.setDefaultValue(xmlDouble.getDefaultValue());
        doubleConfig.setConfig((xmlDouble.getMinValue() == null) ? Double.NEGATIVE_INFINITY : xmlDouble.getMinValue().doubleValue(), (xmlDouble.getMaxValue() == null) ? Double.POSITIVE_INFINITY : xmlDouble.getMaxValue().doubleValue(), xmlDouble.getStepSize(), xmlDouble.getNoOfDecimalPlaces());
        groupConfig.addField(doubleConfig);
        Double defaultValueObj = ConfigDefaultFactory.getDouble(defaultValue);
        if (defaultValueObj != null) {
            doubleConfig.setDefaultValue(defaultValueObj);
            defaultFieldMap.put(id, defaultValueObj);
        }
    } else if (xmlFieldConfig instanceof XMLFieldConfigInteger) {
        XMLFieldConfigInteger xmlInteger = (XMLFieldConfigInteger) xmlFieldConfig;
        FieldConfigInteger integerConfig = new FieldConfigInteger(commonData);
        integerConfig.setDefaultValue(xmlInteger.getDefaultValue());
        integerConfig.setConfig(xmlInteger.getMinValue(), xmlInteger.getMaxValue(), xmlInteger.getStepSize());
        groupConfig.addField(integerConfig);
        Integer defaultValueObj = ConfigDefaultFactory.getInteger(defaultValue);
        if (defaultValueObj != null) {
            integerConfig.setDefaultValue(defaultValueObj);
            defaultFieldMap.put(id, defaultValueObj);
        }
    } else if (xmlFieldConfig instanceof XMLFieldConfigColour) {
        FieldConfigColour colourConfig = new FieldConfigColour(commonData);
        groupConfig.addField(colourConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigSlider) {
        XMLFieldConfigSlider xmlSlider = (XMLFieldConfigSlider) xmlFieldConfig;
        FieldConfigSlider sliderConfig = new FieldConfigSlider(commonData);
        sliderConfig.setDefaultValue(xmlSlider.getDefaultValue());
        groupConfig.addField(sliderConfig);
        Double defaultValueObj = ConfigDefaultFactory.getDouble(defaultValue);
        if (defaultValueObj != null) {
            sliderConfig.setDefaultValue(defaultValueObj);
            defaultFieldMap.put(id, defaultValueObj);
        }
    } else if (xmlFieldConfig instanceof XMLFieldConfigSymbolType) {
        FieldConfigSymbolType fillSymbolConfig = new FieldConfigSymbolType(commonData);
        groupConfig.addField(fillSymbolConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigEnum) {
        FieldConfigEnum valueConfig = new FieldConfigEnum(commonData);
        XMLFieldConfigEnumValueList valueList = ((XMLFieldConfigEnum) xmlFieldConfig).getValueList();
        List<SymbolTypeConfig> configList = readValueListConfig(localisationClass, panelId, valueList);
        valueConfig.addConfig(configList);
        String defaultValueObj = ConfigDefaultFactory.getString(defaultValue);
        if (defaultValueObj != null) {
            valueConfig.setDefaultValue(defaultValueObj);
            defaultFieldMap.put(id, defaultValueObj);
        }
        groupConfig.addField(valueConfig);
    } else if (xmlFieldConfig instanceof XMLFieldConfigMapUnit) {
        FieldConfigMapUnits valueConfig = new FieldConfigMapUnits(commonData);
        String defaultValueObj = ConfigDefaultFactory.getString(defaultValue);
        if (defaultValueObj != null) {
            valueConfig.setDefaultValue(defaultValueObj);
            defaultFieldMap.put(id, defaultValueObj);
        }
        groupConfig.addField(valueConfig);
    }
}
Also used : XMLFieldConfigInteger(com.sldeditor.common.xml.ui.XMLFieldConfigInteger) XMLFieldConfigFont(com.sldeditor.common.xml.ui.XMLFieldConfigFont) FieldConfigColourMap(com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap) XMLFieldConfigColourMap(com.sldeditor.common.xml.ui.XMLFieldConfigColourMap) XMLFieldConfigGeometry(com.sldeditor.common.xml.ui.XMLFieldConfigGeometry) XMLFieldConfigDouble(com.sldeditor.common.xml.ui.XMLFieldConfigDouble) XMLFieldConfigEnumValueList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList) XMLFieldConfigString(com.sldeditor.common.xml.ui.XMLFieldConfigString) XMLFieldConfigFeatureTypeConstraint(com.sldeditor.common.xml.ui.XMLFieldConfigFeatureTypeConstraint) FieldConfigFeatureTypeConstraint(com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint) XMLFieldConfigDouble(com.sldeditor.common.xml.ui.XMLFieldConfigDouble) XMLFieldConfigColourMap(com.sldeditor.common.xml.ui.XMLFieldConfigColourMap) DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) XMLFieldConfigTransformation(com.sldeditor.common.xml.ui.XMLFieldConfigTransformation) FieldConfigTransformation(com.sldeditor.ui.detail.config.transform.FieldConfigTransformation) XMLFieldConfigEnum(com.sldeditor.common.xml.ui.XMLFieldConfigEnum) XMLFieldConfigInlineFeature(com.sldeditor.common.xml.ui.XMLFieldConfigInlineFeature) XMLFieldConfigEnum(com.sldeditor.common.xml.ui.XMLFieldConfigEnum) XMLFieldConfigMapUnit(com.sldeditor.common.xml.ui.XMLFieldConfigMapUnit) XMLFieldConfigColour(com.sldeditor.common.xml.ui.XMLFieldConfigColour) List(java.util.List) ArrayList(java.util.ArrayList) FieldList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList) XMLFieldConfigEnumValueList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList) XMLFieldConfigDSProperties(com.sldeditor.common.xml.ui.XMLFieldConfigDSProperties) XMLFieldConfigBoolean(com.sldeditor.common.xml.ui.XMLFieldConfigBoolean) FieldConfigInlineFeature(com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature) XMLFieldConfigInlineFeature(com.sldeditor.common.xml.ui.XMLFieldConfigInlineFeature) XMLFieldConfigFont(com.sldeditor.common.xml.ui.XMLFieldConfigFont) FieldConfigFont(com.sldeditor.ui.detail.config.font.FieldConfigFont) XMLFieldConfigFontPreview(com.sldeditor.common.xml.ui.XMLFieldConfigFontPreview) XMLFieldConfigSlider(com.sldeditor.common.xml.ui.XMLFieldConfigSlider) XMLFieldConfigInteger(com.sldeditor.common.xml.ui.XMLFieldConfigInteger) XMLFieldConfigString(com.sldeditor.common.xml.ui.XMLFieldConfigString) XMLFieldConfigGeometry(com.sldeditor.common.xml.ui.XMLFieldConfigGeometry) XMLFieldConfigSortBy(com.sldeditor.common.xml.ui.XMLFieldConfigSortBy) XMLFieldConfigSlider(com.sldeditor.common.xml.ui.XMLFieldConfigSlider) XMLFieldConfigGeometryField(com.sldeditor.common.xml.ui.XMLFieldConfigGeometryField) XMLFieldConfigBoolean(com.sldeditor.common.xml.ui.XMLFieldConfigBoolean) XMLFieldConfigSymbolType(com.sldeditor.common.xml.ui.XMLFieldConfigSymbolType) XMLFieldConfigDouble(com.sldeditor.common.xml.ui.XMLFieldConfigDouble) XMLFieldConfigString(com.sldeditor.common.xml.ui.XMLFieldConfigString) XMLFieldConfigInteger(com.sldeditor.common.xml.ui.XMLFieldConfigInteger) XMLFieldConfigFeatureTypeConstraint(com.sldeditor.common.xml.ui.XMLFieldConfigFeatureTypeConstraint) XMLFieldConfigSortBy(com.sldeditor.common.xml.ui.XMLFieldConfigSortBy) FieldConfigSortBy(com.sldeditor.ui.detail.config.sortby.FieldConfigSortBy) XMLFieldConfigColour(com.sldeditor.common.xml.ui.XMLFieldConfigColour) XMLFieldConfigDSProperties(com.sldeditor.common.xml.ui.XMLFieldConfigDSProperties) FieldConfigFontPreview(com.sldeditor.ui.detail.config.font.FieldConfigFontPreview) XMLFieldConfigFontPreview(com.sldeditor.common.xml.ui.XMLFieldConfigFontPreview) XMLFieldConfigTransformation(com.sldeditor.common.xml.ui.XMLFieldConfigTransformation) XMLFieldConfigGeometryField(com.sldeditor.common.xml.ui.XMLFieldConfigGeometryField) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) XMLFieldConfigBoolean(com.sldeditor.common.xml.ui.XMLFieldConfigBoolean) XMLFieldConfigSymbolType(com.sldeditor.common.xml.ui.XMLFieldConfigSymbolType)

Aggregations

FieldConfigInlineFeature (com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature)8 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)7 Geometry (com.vividsolutions.jts.geom.Geometry)7 Test (org.junit.Test)7 DummyInlineSLDFile (com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile)2 UserLayer (org.geotools.styling.UserLayer)2 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