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;
}
Aggregations