use of com.sldeditor.common.xml.ui.XMLFieldConfigData 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;
}
use of com.sldeditor.common.xml.ui.XMLFieldConfigData in project sldeditor by robward-scisys.
the class ReadPanelConfig method parseGroup.
/**
* Parses the group if fields.
*
* @param localisationClass the localisation class
* @param panelId the panel id
* @param xmlGroupObj the xml group object
* @return the group config
*/
private GroupConfig parseGroup(Class<?> localisationClass, Class<?> panelId, XMLGroupConfig xmlGroupObj) {
GroupConfig groupConfig = new GroupConfig();
groupConfig.setId(xmlGroupObj.getId());
groupConfig.setLabel(groupTitle(getLocalisedText(localisationClass, xmlGroupObj.getLabel())));
groupConfig.setShowLabel(xmlGroupObj.getShowLabel());
groupConfig.setOptional(xmlGroupObj.getOption());
for (Object obj : xmlGroupObj.getFieldList()) {
if (obj instanceof XMLFieldConfigData) {
addField(localisationClass, panelId, groupConfig, (XMLFieldConfigData) obj);
} else if (obj instanceof XMLGroupConfig) {
GroupConfig subGroup = parseGroup(localisationClass, panelId, (XMLGroupConfig) obj);
groupConfig.addGroup(subGroup);
} else if (obj instanceof XMLMultiOptionGroup) {
MultiOptionGroup subGroup = parseMultiOptionGroup(localisationClass, panelId, (XMLMultiOptionGroup) obj);
groupConfig.addGroup(subGroup);
} else if (obj instanceof XMLFieldConfigVendorOption) {
XMLFieldConfigVendorOption vendorOption = (XMLFieldConfigVendorOption) obj;
FieldIdEnum id = vendorOption.getId();
String label = null;
boolean valueOnly = true;
FieldConfigCommonData commonData = new FieldConfigCommonData(panelId, id, label, valueOnly);
List<VendorOptionInterface> veList = null;
veList = vendorOptionFactory.getVendorOptionList(vendorOption.getClazz());
if ((veList == null) || veList.isEmpty()) {
ConsoleManager.getInstance().error(this, Localisation.getField(FieldConfigBase.class, "FieldConfigVendorOption.missingVendorOptionClass") + vendorOption.getClazz());
}
FieldConfigVendorOption placeHolder = new FieldConfigVendorOption(commonData, veList);
groupConfig.addField(placeHolder);
}
}
return groupConfig;
}
Aggregations