Search in sources :

Example 1 with SymbolTypeConfig

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

the class FieldConfigEnumTest method testGetFieldEnableState.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#getFieldEnableState()}.
 */
@Test
public void testGetFieldEnableState() {
    UndoManager.getInstance().setPopulationCheck(Controller.getInstance());
    SymbolTypeConfig s1 = new SymbolTypeConfig(Integer.class);
    s1.addOption("key1", "Value 1");
    s1.addOption("key2", "Value 2");
    s1.addOption("key3", "Value 3");
    s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
    s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
    List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
    configList.add(s1);
    boolean valueOnly = true;
    FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.addConfig(configList);
    // Now create the ui
    field.createUI();
    field.populateField("key3");
    Map<FieldIdEnum, Boolean> actualMap = field.getFieldEnableState();
    assertEquals(actualMap.get(FieldIdEnum.ANCHOR_POINT_H), Boolean.TRUE);
    assertEquals(actualMap.get(FieldIdEnum.ANCHOR_POINT_V), Boolean.FALSE);
    UndoManager.getInstance().setPopulationCheck(null);
}
Also used : FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) ArrayList(java.util.ArrayList) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) Test(org.junit.Test)

Example 2 with SymbolTypeConfig

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

the class FieldConfigPopulationTest method testComboBox.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateComboBoxField(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateComboBoxField(com.sldeditor.common.xml.ui.FieldIdEnum, java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getComboBox(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getComboBox(com.sldeditor.ui.detail.config.FieldId)}.
 */
@Test
public void testComboBox() {
    SymbolTypeConfig s1 = new SymbolTypeConfig(null);
    s1.addOption("key1", "Value 1");
    s1.addOption("key2", "Value 2");
    s1.addOption("key3", "Value 3");
    s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
    s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
    configList.add(s1);
    FieldConfigEnum enumField = new FieldConfigEnum(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    enumField.addConfig(configList);
    enumField.createUI();
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    fieldConfigManager.add(fieldId, enumField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    String expectedValue = "key2";
    obj.populateComboBoxField(fieldId, expectedValue);
    assertTrue(expectedValue.compareTo(obj.getComboBox(fieldId).getKey()) == 0);
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    assertNull(obj.getComboBox(wrongFieldEnum));
    // Try with null - should revert to default value (first enum item)
    obj.populateComboBoxField(fieldId, null);
    expectedValue = "key1";
    assertTrue(expectedValue.compareTo(obj.getComboBox(fieldId).getKey()) == 0);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) ArrayList(java.util.ArrayList) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 3 with SymbolTypeConfig

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

the class ReadMapUnits method readValueListConfig.

/**
 * Read value list configuration.
 *
 * @param localisationClass the localisation class
 * @param panelId the panel id
 * @param valueList the xml value obj
 * @return the list
 */
private List<SymbolTypeConfig> readValueListConfig(Class<?> localisationClass, Class<?> panelId, XMLFieldConfigEnumValueList valueList) {
    List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
    for (XMLFieldConfigEnumValue valueObj : valueList.getValue()) {
        SymbolTypeConfig config = parseSymbolTypeConfig(localisationClass, panelId, valueObj);
        configList.add(config);
    }
    return configList;
}
Also used : XMLFieldConfigEnumValue(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue) ArrayList(java.util.ArrayList) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)

Example 4 with SymbolTypeConfig

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

the class ReadPanelConfig method parseSymbolTypeConfig.

/**
 * Parses the symbol type configuration.
 *
 * @param localisationClass the localisation class
 * @param panelId the panel id
 * @param valueObj the value obj
 * @return the symbol type config
 */
public static SymbolTypeConfig parseSymbolTypeConfig(Class<?> localisationClass, Class<?> panelId, XMLFieldConfigEnumValue valueObj) {
    SymbolTypeConfig config = new SymbolTypeConfig(panelId);
    String groupName = valueObj.getGroupName();
    boolean isSeparateGroup = valueObj.getSeparateGroup();
    if (groupName != null) {
        config.setGroupName(groupName);
    }
    config.setSeparateGroup(isSeparateGroup);
    for (XMLFieldConfigEnumValueItem itemObj : valueObj.getItem()) {
        config.addOption(itemObj.getId(), getLocalisedText(localisationClass, itemObj.getLabel()));
    }
    FieldList fieldList = valueObj.getFieldList();
    if (fieldList != null) {
        for (XMLFieldConfigEnumValueField field : fieldList.getField()) {
            config.addField(field.getId(), field.getEnabled());
        }
        for (XMLFieldConfigEnumValueGroup group : fieldList.getGroup()) {
            config.addGroup(group.getId(), group.getEnabled());
        }
    }
    return config;
}
Also used : XMLFieldConfigEnumValueField(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueField) XMLFieldConfigString(com.sldeditor.common.xml.ui.XMLFieldConfigString) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig) XMLFieldConfigEnumValueItem(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueItem) XMLFieldConfigEnumValueGroup(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueGroup) FieldList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)

Example 5 with SymbolTypeConfig

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

the class FieldConfigEnum method addConfig.

/**
 * Adds the config.
 *
 * @param configList the config list
 */
public void addConfig(List<SymbolTypeConfig> configList) {
    if (configList != null) {
        for (SymbolTypeConfig config : configList) {
            if (config != null) {
                fieldMap.putAll(config.getFieldMap());
                Map<String, String> optionMap = config.getOptionMap();
                for (String key : optionMap.keySet()) {
                    addValue(key, optionMap.get(key));
                }
            }
        }
    }
}
Also used : SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)

Aggregations

SymbolTypeConfig (com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)12 ArrayList (java.util.ArrayList)8 FieldConfigEnum (com.sldeditor.ui.detail.config.FieldConfigEnum)6 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)5 Test (org.junit.Test)5 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 XMLFieldConfigEnumValue (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue)2 FieldList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)2 XMLFieldConfigEnumValueField (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueField)2 XMLFieldConfigEnumValueItem (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueItem)2 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 MapUnits (com.sldeditor.common.xml.ui.MapUnits)1 XMLFieldConfigData (com.sldeditor.common.xml.ui.XMLFieldConfigData)1 XMLFieldConfigEnum (com.sldeditor.common.xml.ui.XMLFieldConfigEnum)1 XMLFieldConfigEnumValueGroup (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueGroup)1 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)1 XMLFieldConfigString (com.sldeditor.common.xml.ui.XMLFieldConfigString)1 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)1 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)1