Search in sources :

Example 61 with XMLElement

use of net.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 62 with XMLElement

use of net.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 63 with XMLElement

use of net.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 64 with XMLElement

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

Example 65 with XMLElement

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

the class NodeWriter method writeAttributesGenerateContent.

private void writeAttributesGenerateContent(final ITreeWriter writer, final NodeModel node) {
    /**
     * fc, 12.6.2005: XML must not contain any zero characters.
     */
    xmlNode = new XMLElement();
    EncryptionModel encryptionModel = EncryptionModel.getModel(node);
    mayWriteChildren = true;
    final Object mode = mode(writer);
    final boolean isNodeAlreadyWritten = isAlreadyWritten(node);
    if (encryptionModel != null && !(encryptionModel.isAccessible() && Mode.EXPORT.equals(mode)) && !isNodeAlreadyWritten) {
        final String enctyptedContent = encryptionModel.calculateEncryptedContent(mapController);
        if (enctyptedContent != null) {
            writer.addAttribute(NodeBuilder.XML_NODE_ENCRYPTED_CONTENT, enctyptedContent);
            mayWriteChildren = false;
        }
    }
    if (mayWriteChildren && (writeFolded || !mode(writer).equals(Mode.FILE))) {
        if (mapController.isFolded(node) && !isNodeAlreadyWritten) {
            writer.addAttribute("FOLDED", "true");
        } else if (node.isRoot() && !Mode.STYLE.equals(mode)) {
            writer.addAttribute("FOLDED", "false");
        }
    }
    final NodeModel parentNode = node.getParentNode();
    if (parentNode != null && parentNode.isRoot()) {
        writer.addAttribute("POSITION", node.isLeft() ? "left" : "right");
    }
    final boolean saveID = !mode.equals(Mode.STYLE);
    if (saveID) {
        final String id = node.createID();
        writer.addAttribute("ID", id);
        writeReferenceNodeId(writer, node);
    }
    if (!isNodeAlreadyWritten) {
        if (!mode.equals(Mode.STYLE) && node.getHistoryInformation() != null && ResourceController.getResourceController().getBooleanProperty(NodeBuilder.RESOURCES_SAVE_MODIFICATION_TIMES)) {
            writer.addAttribute(NodeBuilder.XML_NODE_HISTORY_CREATED_AT, TreeXmlWriter.dateToString(node.getHistoryInformation().getCreatedAt()));
            writer.addAttribute(NodeBuilder.XML_NODE_HISTORY_LAST_MODIFIED_AT, TreeXmlWriter.dateToString(node.getHistoryInformation().getLastModifiedAt()));
        }
    }
    if (!isNodeAlreadyWritten || Mode.EXPORT.equals(mode)) {
        writeIconSize(writer, node);
        linkBuilder.writeAttributes(writer, node);
        writer.addExtensionAttributes(node, node.getSharedExtensions().values());
    }
    writer.addExtensionAttributes(node, node.getIndividualExtensionValues());
}
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)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 XMLException (org.freeplane.n3.nanoxml.XMLException)3 Point (java.awt.Point)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2