use of org.csstudio.opibuilder.persistence.LineAwareXMLParser.LineAwareElement in project yamcs-studio by yamcs.
the class XMLUtil method setPropertiesFromXML.
@SuppressWarnings("rawtypes")
private static void setPropertiesFromXML(Element element, AbstractWidgetModel model) {
if (model == null || element == null)
return;
String versionOnFile = element.getAttributeValue(XMLATTR_VERSION);
model.setVersionOnFile(Version.parseVersion(versionOnFile));
if (element instanceof LineAwareElement) {
model.setLineNumber(((LineAwareElement) element).getLineNumber());
}
List children = element.getChildren();
Iterator iterator = children.iterator();
Set<String> propIdSet = model.getAllPropertyIDs();
while (iterator.hasNext()) {
Element subElement = (Element) iterator.next();
// handle property
if (propIdSet.contains(subElement.getName())) {
String propId = subElement.getName();
try {
model.setPropertyValue(propId, model.getProperty(propId).readValueFromXML(subElement));
} catch (Exception e) {
String errorMessage = "Failed to read the " + propId + " property for " + model.getName() + ". " + "The default property value will be setted instead. \n" + e;
// MessageDialog.openError(null, "OPI File format error", errorMessage + "\n" + e.getMessage());
OPIBuilderPlugin.getLogger().log(Level.WARNING, errorMessage, e);
ConsoleService.getInstance().writeWarning(errorMessage);
}
}
}
}
Aggregations