use of com.sldeditor.common.xml.ui.XMLGroupConfig 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;
}
use of com.sldeditor.common.xml.ui.XMLGroupConfig 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;
}
use of com.sldeditor.common.xml.ui.XMLGroupConfig 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;
}
Aggregations