Search in sources :

Example 1 with XMLFieldConfigData

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;
}
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 2 with XMLFieldConfigData

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;
}
Also used : XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) XMLFieldConfigVendorOption(com.sldeditor.common.xml.ui.XMLFieldConfigVendorOption) XMLFieldConfigString(com.sldeditor.common.xml.ui.XMLFieldConfigString) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) XMLFieldConfigVendorOption(com.sldeditor.common.xml.ui.XMLFieldConfigVendorOption) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) XMLFieldConfigData(com.sldeditor.common.xml.ui.XMLFieldConfigData) List(java.util.List) ArrayList(java.util.ArrayList) FieldList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList) XMLFieldConfigEnumValueList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList) XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum)

Aggregations

XMLFieldConfigData (com.sldeditor.common.xml.ui.XMLFieldConfigData)2 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)2 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 MapUnits (com.sldeditor.common.xml.ui.MapUnits)1 XMLFieldConfigEnum (com.sldeditor.common.xml.ui.XMLFieldConfigEnum)1 FieldList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)1 XMLFieldConfigString (com.sldeditor.common.xml.ui.XMLFieldConfigString)1 XMLFieldConfigVendorOption (com.sldeditor.common.xml.ui.XMLFieldConfigVendorOption)1 XMLGroupConfig (com.sldeditor.common.xml.ui.XMLGroupConfig)1 XMLMultiOptionGroup (com.sldeditor.common.xml.ui.XMLMultiOptionGroup)1 GroupConfig (com.sldeditor.ui.detail.config.base.GroupConfig)1 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)1 SymbolTypeConfig (com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1