Search in sources :

Example 1 with XMLMultiOptionGroup

use of com.sldeditor.common.xml.ui.XMLMultiOptionGroup in project sldeditor by robward-scisys.

the class ReadPanelConfig method read.

/**
 * Read configuration file and store the configuration in the object.
 *
 * @param panelId the panel id
 * @param resourceString the resource string
 * @return true, if successful
 */
public boolean read(Class<?> panelId, String resourceString) {
    groupList = new ArrayList<GroupConfigInterface>();
    PanelConfig panelConfig = (PanelConfig) ParseXML.parseUIFile(resourceString, SCHEMA_RESOURCE, PanelConfig.class);
    if (panelConfig == null) {
        return false;
    }
    Class<?> localisationClass = ReadPanelConfig.class;
    if (panelConfig.getLocalisation() != null) {
        try {
            localisationClass = Class.forName(panelConfig.getLocalisation());
        } catch (ClassNotFoundException e) {
            ConsoleManager.getInstance().exception(ReadPanelConfig.class, e);
        }
    }
    panelTitle = getLocalisedText(localisationClass, panelConfig.getPanelTitle());
    vendorOptionVersion = getVendorOptionVersion(panelConfig);
    for (Object groupObj : panelConfig.getGroupOrMultiOptionGroup()) {
        if (groupObj instanceof XMLGroupConfig) {
            GroupConfig groupConfig = parseGroup(localisationClass, panelId, (XMLGroupConfig) groupObj);
            groupList.add(groupConfig);
        } else if (groupObj instanceof XMLMultiOptionGroup) {
            MultiOptionGroup groupConfig = parseMultiOptionGroup(localisationClass, panelId, (XMLMultiOptionGroup) groupObj);
            groupList.add(groupConfig);
        }
    }
    return true;
}
Also used : XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) PanelConfig(com.sldeditor.common.xml.ui.PanelConfig) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 2 with XMLMultiOptionGroup

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

Example 3 with XMLMultiOptionGroup

use of com.sldeditor.common.xml.ui.XMLMultiOptionGroup in project sldeditor by robward-scisys.

the class ReadPanelConfig method parseMultiOptionGroup.

/**
 * Parses the multi option group.
 *
 * @param localisationClass the localisation class
 * @param panelId the panel id
 * @param xmlMultiGroupObj the xml multi group obj
 * @return the multi option group
 */
private MultiOptionGroup parseMultiOptionGroup(Class<?> localisationClass, Class<?> panelId, XMLMultiOptionGroup xmlMultiGroupObj) {
    MultiOptionGroup multiOptionGroupConfig = new MultiOptionGroup();
    multiOptionGroupConfig.setId(xmlMultiGroupObj.getId());
    multiOptionGroupConfig.setLabel(getLocalisedText(localisationClass, xmlMultiGroupObj.getLabel()));
    multiOptionGroupConfig.setShowLabel(xmlMultiGroupObj.getShowLabel());
    multiOptionGroupConfig.setOptional(xmlMultiGroupObj.getOption());
    List<XMLOptionGroup> optionGroupList = xmlMultiGroupObj.getOptionGroup();
    for (XMLOptionGroup xmlOptionGroup : optionGroupList) {
        OptionGroup optionGroup = new OptionGroup();
        optionGroup.setId(xmlOptionGroup.getId());
        optionGroup.setLabel(getLocalisedText(localisationClass, xmlOptionGroup.getLabel()));
        optionGroup.setShowLabel(xmlOptionGroup.getShowLabel());
        List<XMLGroupConfig> xmlGroupConfigList = xmlOptionGroup.getGroup();
        if (xmlGroupConfigList != null) {
            for (XMLGroupConfig xmlGroupConfig : xmlGroupConfigList) {
                GroupConfig groupConfig = parseGroup(localisationClass, panelId, xmlGroupConfig);
                optionGroup.addGroup(groupConfig);
            }
        }
        multiOptionGroupConfig.addGroup(optionGroup);
    }
    return multiOptionGroupConfig;
}
Also used : XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) XMLOptionGroup(com.sldeditor.common.xml.ui.XMLOptionGroup) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) XMLOptionGroup(com.sldeditor.common.xml.ui.XMLOptionGroup)

Aggregations

XMLGroupConfig (com.sldeditor.common.xml.ui.XMLGroupConfig)3 XMLMultiOptionGroup (com.sldeditor.common.xml.ui.XMLMultiOptionGroup)3 GroupConfig (com.sldeditor.ui.detail.config.base.GroupConfig)3 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)3 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 PanelConfig (com.sldeditor.common.xml.ui.PanelConfig)1 XMLFieldConfigData (com.sldeditor.common.xml.ui.XMLFieldConfigData)1 FieldList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)1 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)1 XMLFieldConfigString (com.sldeditor.common.xml.ui.XMLFieldConfigString)1 XMLFieldConfigVendorOption (com.sldeditor.common.xml.ui.XMLFieldConfigVendorOption)1 XMLOptionGroup (com.sldeditor.common.xml.ui.XMLOptionGroup)1 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)1 OptionGroup (com.sldeditor.ui.detail.config.base.OptionGroup)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1