Search in sources :

Example 16 with XMLElement

use of org.freeplane.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 17 with XMLElement

use of org.freeplane.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 18 with XMLElement

use of org.freeplane.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)

Example 19 with XMLElement

use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class TimeWindowColumnSetting method marschall.

void marschall(final XMLElement xml) {
    final XMLElement child = new XMLElement("time_window_column_setting");
    child.setAttribute("column_sorting", Integer.toString(columnSorting));
    child.setAttribute("column_width", Integer.toString(columnWidth));
    xml.addChild(child);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 20 with XMLElement

use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class UnknownElementWriter method writeContent.

public void writeContent(final ITreeWriter writer, final Object element, final IExtension extension) throws IOException {
    final UnknownElements elements = (UnknownElements) extension;
    final XMLElement unknownElements = elements.getUnknownElements();
    if (unknownElements != null) {
        final Enumeration<XMLElement> unknownChildren = unknownElements.enumerateChildren();
        while (unknownChildren.hasMoreElements()) {
            writer.addElement(null, unknownChildren.nextElement());
        }
    }
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Aggregations

XMLElement (org.freeplane.n3.nanoxml.XMLElement)63 IOException (java.io.IOException)8 IXMLParser (org.freeplane.n3.nanoxml.IXMLParser)7 IXMLReader (org.freeplane.n3.nanoxml.IXMLReader)7 StdXMLReader (org.freeplane.n3.nanoxml.StdXMLReader)7 BufferedInputStream (java.io.BufferedInputStream)5 File (java.io.File)5 FileInputStream (java.io.FileInputStream)5 ASelectableCondition (org.freeplane.features.filter.condition.ASelectableCondition)5 NodeModel (org.freeplane.features.map.NodeModel)5 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 XMLException (org.freeplane.n3.nanoxml.XMLException)3 Point (java.awt.Point)2 FilenameFilter (java.io.FilenameFilter)2 HashMap (java.util.HashMap)2