Search in sources :

Example 21 with XMLElement

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;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) XMLElement(org.freeplane.n3.nanoxml.XMLElement) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 22 with XMLElement

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);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 23 with 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);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 24 with 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;
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 25 with XMLElement

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);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Aggregations

XMLElement (org.freeplane.n3.nanoxml.XMLElement)65 IOException (java.io.IOException)8 IXMLParser (org.freeplane.n3.nanoxml.IXMLParser)6 IXMLReader (org.freeplane.n3.nanoxml.IXMLReader)6 StdXMLReader (org.freeplane.n3.nanoxml.StdXMLReader)6 ASelectableCondition (org.freeplane.features.filter.condition.ASelectableCondition)5 NodeModel (org.freeplane.features.map.NodeModel)5 BufferedInputStream (java.io.BufferedInputStream)4 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 XMLWriter (org.freeplane.n3.nanoxml.XMLWriter)4 Color (java.awt.Color)3 FileWriter (java.io.FileWriter)3 Writer (java.io.Writer)3 IXMLElement (net.n3.nanoxml.IXMLElement)3 XMLElement (net.n3.nanoxml.XMLElement)3 Point (java.awt.Point)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Locale (java.util.Locale)2