Search in sources :

Example 1 with MapUnits

use of com.sldeditor.common.xml.ui.MapUnits 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)

Aggregations

MapUnits (com.sldeditor.common.xml.ui.MapUnits)1 XMLFieldConfigData (com.sldeditor.common.xml.ui.XMLFieldConfigData)1 XMLFieldConfigEnum (com.sldeditor.common.xml.ui.XMLFieldConfigEnum)1 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)1 SymbolTypeConfig (com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)1