Search in sources :

Example 6 with SymbolTypeConfig

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

the class ReadMapUnits method read.

/**
 * Read configuration file and store the configuration in the object.
 *
 * @param panelId the panel id
 * @param resourceString the resource string
 * @param fieldConfigMapUnits the field config map units
 * @return true, if successful
 */
public boolean read(Class<?> panelId, String resourceString, FieldConfigMapUnits fieldConfigMapUnits) {
    MapUnits mapUnits = (MapUnits) ParseXML.parseUIFile(resourceString, SCHEMA_RESOURCE, MapUnits.class);
    if (mapUnits == null) {
        return false;
    }
    Class<?> localisationClass = ReadPanelConfig.class;
    if (mapUnits.getLocalisation() != null) {
        try {
            localisationClass = Class.forName(mapUnits.getLocalisation());
        } catch (ClassNotFoundException e) {
            ConsoleManager.getInstance().exception(ReadMapUnits.class, e);
        }
    }
    XMLFieldConfigData xmlFieldConfig = mapUnits.getFieldConfigEnum();
    if (xmlFieldConfig instanceof XMLFieldConfigEnum) {
        String defaultValue = xmlFieldConfig.getDefault();
        XMLFieldConfigEnumValueList valueList = ((XMLFieldConfigEnum) xmlFieldConfig).getValueList();
        List<SymbolTypeConfig> configList = readValueListConfig(localisationClass, panelId, valueList);
        fieldConfigMapUnits.addConfig(configList);
        String defaultValueObj = ConfigDefaultFactory.getString(defaultValue);
        if (defaultValueObj != null) {
            fieldConfigMapUnits.setDefaultValue(defaultValueObj);
        }
    }
    return true;
}
Also used : XMLFieldConfigEnum(com.sldeditor.common.xml.ui.XMLFieldConfigEnum) MapUnits(com.sldeditor.common.xml.ui.MapUnits) XMLFieldConfigData(com.sldeditor.common.xml.ui.XMLFieldConfigData) XMLFieldConfigEnumValueList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)

Example 7 with SymbolTypeConfig

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

the class ReadMapUnits 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());
        }
    }
    return config;
}
Also used : XMLFieldConfigEnumValueField(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueField) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig) XMLFieldConfigEnumValueItem(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueItem) FieldList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)

Example 8 with SymbolTypeConfig

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

the class ReadPanelConfig 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 9 with SymbolTypeConfig

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

the class BaseValue method createEnum.

/**
 * Creates the enum.
 *
 * @param commonData the common data
 * @return the field config base
 */
protected FieldConfigBase createEnum(FieldConfigCommonData commonData) {
    FieldConfigEnum fieldConfigEnum = new FieldConfigEnum(commonData);
    List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
    SymbolTypeConfig symbolTypeConfig = new SymbolTypeConfig(null);
    populateSymbolType(symbolTypeConfig);
    configList.add(symbolTypeConfig);
    fieldConfigEnum.addConfig(configList);
    return fieldConfigEnum;
}
Also used : FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) ArrayList(java.util.ArrayList) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)

Example 10 with SymbolTypeConfig

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

the class FieldConfigEnumTest method testGenerateExpression.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#generateExpression()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#populateField(java.lang.String)}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#getEnumValue()}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    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);
    List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
    configList.add(s1);
    SymbolTypeConfig s2 = new SymbolTypeConfig(null);
    s2.addOption("key4", "Value 4");
    s2.addOption("key5", "Value 5");
    s2.addOption("key6", "Value 6");
    s2.addField(FieldIdEnum.ANGLE, true);
    s2.addField(FieldIdEnum.DESCRIPTION, false);
    configList.add(s2);
    boolean valueOnly = true;
    FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.undoAction(null);
    field.redoAction(null);
    field.addConfig(null);
    assertNull(field.getStringValue());
    field.addConfig(configList);
    // Try without creating the ui
    field.populateExpression(null);
    field.populateField((String) null);
    field.setTestValue(null, (String) null);
    // Now create the ui
    field.createUI();
    field.createUI();
    String expectedValue1 = "key2";
    field.populateField(expectedValue1);
    String actualValueString = field.getStringValue();
    assertTrue(expectedValue1.compareTo(actualValueString) == 0);
    ValueComboBoxData actualValue = field.getEnumValue();
    assertTrue(expectedValue1.compareTo(actualValue.getKey()) == 0);
    // Try valid/invalid option values
    assertTrue(field.isValidOption("key1"));
    assertTrue(field.isValidOption("key4"));
    assertFalse(field.isValidOption("key24"));
    assertFalse(field.isValidOption(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) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Test(org.junit.Test)

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