use of net.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class AddOnProperties method parseTranslations.
private Map<String, Map<String, String>> parseTranslations(Vector<XMLElement> xmlElements) {
final Map<String, Map<String, String>> result = new HashMap<String, Map<String, String>>();
if (xmlElements != null && !xmlElements.isEmpty()) {
for (XMLElement xmlElement : xmlElements.get(0).getChildren()) {
Map<String, String> properties = new LinkedHashMap<String, String>();
result.put(xmlElement.getAttribute("name", null), properties);
for (XMLElement entryXmlElement : xmlElement.getChildren()) {
properties.put(entryXmlElement.getAttribute("key", null), entryXmlElement.getContent());
}
}
}
return result;
}
use of net.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class AddOnProperties method addDefaultPropertiesAsChild.
private void addDefaultPropertiesAsChild(XMLElement parent) {
final XMLElement xmlElement = new XMLElement("default.properties");
for (Entry<String, String> entry : defaultProperties.entrySet()) {
xmlElement.setAttribute(entry.getKey(), entry.getValue());
}
parent.addChild(xmlElement);
}
use of net.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class AddOnProperties method addImagesAsChild.
private void addImagesAsChild(XMLElement parent) {
final XMLElement xmlElement = new XMLElement("images");
if (images != null) {
for (String image : images) {
final XMLElement imageElement = new XMLElement("image");
imageElement.setAttribute("name", image);
xmlElement.addChild(imageElement);
}
}
parent.addChild(xmlElement);
}
use of net.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class AddOnProperties method toXml.
// // this is the Groovy equivalent for all this below - removed from the script to avoid redundancies
// writer.write('<?xml version="1.0" encoding="UTF-8"?>' + System.getProperty("line.separator"))
// new MarkupBuilder(writer).addon( configMap['properties'] ) {
// description('') {
// writer.write('<![CDATA[' + configMap['description'] + ']]>')
// }
// permissions( configMap['permissions'] )
// translations {
// configMap['translations'].collect{ loc, translationMap ->
// locale( name:loc ) {
// translationMap.collect{ k,v ->
// entry(key:k, v)
// }
// }
// }
// }
// 'preferences.xml'('') {
// writer.write('<![CDATA[' + configMap['preferences.xml'] + ']]>')
// }
// 'default.properties'( configMap['default.properties'] )
// deinstall {
// configMap['deinstall'].collect { pair ->
// "${pair[0]}"(pair[1])
// }
// }
// }
// writer.close()
public XMLElement toXml() {
final XMLElement addonElement = new XMLElement("addon");
addonElement.setAttribute("name", name);
addonElement.setAttribute("version", version);
addonElement.setAttribute("latestVersion", latestVersion == null ? "" : latestVersion);
addonElement.setAttribute("freeplaneVersionFrom", freeplaneVersionFrom.toString());
if (freeplaneVersionTo != null)
addonElement.setAttribute("freeplaneVersionTo", freeplaneVersionTo.toString());
if (homepage != null)
addonElement.setAttribute("homepage", homepage.toString());
if (updateUrl != null)
addonElement.setAttribute("updateUrl", updateUrl.toString());
if (author != null)
addonElement.setAttribute("author", author);
addonElement.setAttribute("active", Boolean.toString(active));
addAsChildWithContent(addonElement, "description", description);
addAsChildWithContent(addonElement, "license", license);
addAsChildWithContent(addonElement, "preferences.xml", preferencesXml);
addTranslationsAsChild(addonElement);
addDefaultPropertiesAsChild(addonElement);
addImagesAsChild(addonElement);
addDeinstallationRulesAsChild(addonElement);
return addonElement;
}
use of net.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class ReminderHook method saveExtension.
@Override
protected void saveExtension(final IExtension extension, final XMLElement element) {
super.saveExtension(extension, element);
final ReminderExtension reminderExtension = (ReminderExtension) extension;
final XMLElement parameters = element.createElement("Parameters");
parameters.setAttribute(REMINDUSERAT, Long.toString(reminderExtension.getRemindUserAt()));
parameters.setAttribute(PERIOD, Integer.toString(reminderExtension.getPeriod()));
parameters.setAttribute(UNIT, reminderExtension.getPeriodUnit().toString());
final String script = reminderExtension.getScript();
if (script != null) {
parameters.setAttribute(SCRIPT, script);
}
element.addChild(parameters);
}
Aggregations