Search in sources :

Example 61 with XMLElement

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

the class WindowConfigurationStorage method unmarschall.

protected XMLElement unmarschall(final String marshalled, final JDialog dialog) {
    if (marshalled != null) {
        final IXMLParser parser = XMLLocalParserFactory.createLocalXMLParser();
        final IXMLReader xmlReader = new StdXMLReader(new StringReader(marshalled));
        parser.setReader(xmlReader);
        try {
            final XMLElement storage = (XMLElement) parser.parse();
            if (storage != null) {
                x = Integer.parseInt(storage.getAttribute("x", "-1"));
                y = Integer.parseInt(storage.getAttribute("y", "-1"));
                width = Integer.parseInt(storage.getAttribute("width", "-1"));
                height = Integer.parseInt(storage.getAttribute("height", "-1"));
                UITools.setBounds(dialog, x, y, width, height);
                return storage;
            }
        } catch (final NumberFormatException e) {
            LogUtils.severe(e);
        } catch (final XMLException e) {
            LogUtils.severe(e);
        }
    }
    UITools.setBounds(dialog, -1, -1, -1, -1);
    return null;
}
Also used : XMLException(org.freeplane.n3.nanoxml.XMLException) IXMLReader(org.freeplane.n3.nanoxml.IXMLReader) IXMLParser(org.freeplane.n3.nanoxml.IXMLParser) StringReader(java.io.StringReader) StdXMLReader(org.freeplane.n3.nanoxml.StdXMLReader) XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 62 with XMLElement

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

the class TimeWindowConfigurationStorage method decorateDialog.

public static TimeWindowConfigurationStorage decorateDialog(final String marshalled, final JDialog dialog) {
    final TimeWindowConfigurationStorage storage = new TimeWindowConfigurationStorage();
    final XMLElement xml = storage.unmarschall(marshalled, dialog);
    if (xml != null) {
        final Iterator<XMLElement> iterator = xml.getChildren().iterator();
        while (iterator.hasNext()) {
            storage.addTimeWindowColumnSetting(TimeWindowColumnSetting.create(iterator.next()));
        }
        return storage;
    }
    return null;
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 63 with XMLElement

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

the class AddOnProperties method addDeinstallationRulesAsChild.

private void addDeinstallationRulesAsChild(XMLElement parent) {
    final XMLElement xmlElement = new XMLElement("deinstall");
    for (String[] rule : deinstallationRules) {
        final XMLElement ruleElement = new XMLElement(rule[0]);
        ruleElement.setContent(rule[1]);
        xmlElement.addChild(ruleElement);
    }
    parent.addChild(xmlElement);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 64 with XMLElement

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

the class AddOnProperties method addTranslationsAsChild.

private void addTranslationsAsChild(XMLElement parent) {
    final XMLElement translationsElement = new XMLElement("translations");
    for (Entry<String, Map<String, String>> localeEntry : translations.entrySet()) {
        final XMLElement localeElement = new XMLElement("locale");
        localeElement.setAttribute("name", localeEntry.getKey());
        for (Entry<String, String> translationEntry : localeEntry.getValue().entrySet()) {
            final XMLElement translationElement = new XMLElement("entry");
            translationElement.setAttribute("key", translationEntry.getKey());
            translationElement.setContent(StringEscapeUtils.escapeJava(translationEntry.getValue()));
            localeElement.addChild(translationElement);
        }
        translationsElement.addChild(localeElement);
    }
    parent.addChild(translationsElement);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 65 with XMLElement

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

the class AddOnsController method registerPlugins.

private void registerPlugins() {
    final File addOnsDir = getAddOnsDir();
    // in applets the addOnsDir will be null
    if (addOnsDir == null)
        return;
    File[] addonXmlFiles = addOnsDir.listFiles(new FilenameFilter() {

        public boolean accept(File dir, String name) {
            return name.endsWith(".plugin.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);
            registerInstalledAddOn(new AddOnProperties(AddOnType.PLUGIN, (XMLElement) parser.parse()));
        } catch (final Exception e) {
            LogUtils.warn("error parsing " + file, e);
        } finally {
            FileUtils.silentlyClose(inputStream);
        }
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) IXMLReader(org.freeplane.n3.nanoxml.IXMLReader) BufferedInputStream(java.io.BufferedInputStream) IXMLParser(org.freeplane.n3.nanoxml.IXMLParser) StdXMLReader(org.freeplane.n3.nanoxml.StdXMLReader) XMLElement(org.freeplane.n3.nanoxml.XMLElement) File(java.io.File) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException)

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