Search in sources :

Example 26 with XMLElement

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

the class ScriptingRegistration method registerScriptAddOns.

private void registerScriptAddOns() {
    File[] addonXmlFiles = AddOnsController.getController().getAddOnsDir().listFiles(new FilenameFilter() {

        @Override
        public boolean accept(File dir, String name) {
            return name.endsWith(".script.xml");
        }
    });
    final IXMLParser parser = XMLLocalParserFactory.createLocalXMLParser();
    for (File file : addonXmlFiles) {
        BufferedInputStream inputStream = null;
        try {
            inputStream = new BufferedInputStream(new FileInputStream(file));
            final IXMLReader reader = new StdXMLReader(inputStream);
            parser.setReader(reader);
            final ScriptAddOnProperties addOn = new ScriptAddOnProperties((XMLElement) parser.parse());
            addOn.setAddOnPropertiesFile(file);
            AddOnsController.getController().registerInstalledAddOn(addOn);
        } catch (final Exception e) {
            LogUtils.warn("error parsing " + file, e);
        } finally {
            FileUtils.silentlyClose(inputStream);
        }
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) ScriptAddOnProperties(org.freeplane.plugin.script.addons.ScriptAddOnProperties) IXMLReader(org.freeplane.n3.nanoxml.IXMLReader) BufferedInputStream(java.io.BufferedInputStream) IXMLParser(org.freeplane.n3.nanoxml.IXMLParser) StdXMLReader(org.freeplane.n3.nanoxml.StdXMLReader) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 27 with XMLElement

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

the class ScriptAddOnProperties method toXml.

public XMLElement toXml() {
    final XMLElement xmlElement = super.toXml();
    addScriptsAsChild(xmlElement);
    addLibAsChild(xmlElement);
    return xmlElement;
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 28 with XMLElement

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

the class ScriptAddOnProperties method addLibAsChild.

private void addLibAsChild(XMLElement parent) {
    final XMLElement xmlElement = new XMLElement("libs");
    if (lib != null) {
        for (String l : lib) {
            final XMLElement libElement = new XMLElement("lib");
            libElement.setAttribute("name", l);
            xmlElement.addChild(libElement);
        }
    }
    parent.addChild(xmlElement);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 29 with XMLElement

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

the class RenderUtils method extractTextNodes.

private static void extractTextNodes(XMLElement e) {
    for (Object o : e.getChildren()) {
        XMLElement c = ((XMLElement) o);
        if (c.getChildren().size() > 0)
            extractTextNodes(c);
        if (c.getContent() != null && c.getName() != null) {
            IXMLElement textNode = c.createElement(null);
            textNode.setContent(c.getContent());
            c.setContent(null);
            c.addChild(textNode);
        }
    }
}
Also used : XMLElement(net.n3.nanoxml.XMLElement) IXMLElement(net.n3.nanoxml.IXMLElement) IXMLElement(net.n3.nanoxml.IXMLElement)

Example 30 with XMLElement

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

the class RenderUtils method nodeValueToString.

static String nodeValueToString(XMLElement node) {
    String result = node.getContent();
    if (result == null) {
        result = "";
        for (Object o : node.getChildren()) {
            XMLElement e = (XMLElement) o;
            result += e.getContent();
        }
    }
    return result;
}
Also used : XMLElement(net.n3.nanoxml.XMLElement) IXMLElement(net.n3.nanoxml.IXMLElement)

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