Search in sources :

Example 41 with XMLElement

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

the class TreeXmlReader method endElement.

/*
	 * (non-Javadoc)
	 * @see
	 * freeplane.persistence.xml.n3.nanoxml.IXMLBuilder#endElement(java.lang
	 * .String, java.lang.String, java.lang.String)
	 */
public void endElement(final String name, final String nsPrefix, final String nsURI) throws Exception {
    final XMLElement lastBuiltElement = xmlBuilder.getParentElement();
    xmlBuilder.endElement(name, nsPrefix, nsURI);
    if (saveAsXmlUntil == lastBuiltElement) {
        saveAsXmlUntil = null;
    }
    if (saveAsXmlUntil != null) {
        return;
    }
    tag = null;
    if (0 == elementStack.size()) {
        return;
    }
    final Object element = currentElement;
    currentElement = elementStack.removeLast();
    if (nodeCreator instanceof IElementContentHandler) {
        ((IElementContentHandler) nodeCreator).endElement(currentElement, name, element, lastBuiltElement, elementContentAsString);
    } else if (nodeCreator instanceof IElementDOMHandler) {
        ((IElementDOMHandler) nodeCreator).endElement(currentElement, name, element, lastBuiltElement);
    }
    final XMLElement top = lastBuiltElement.getParent();
    if (nodeCreator != null && top != null && top.hasChildren()) {
        final int lastChildIndex = top.getChildrenCount() - 1;
        top.removeChildAtIndex(lastChildIndex);
    }
    nodeCreator = (IElementHandler) nodeCreatorStack.removeLast();
    elementContentAsString = null;
}
Also used : IElementContentHandler(org.freeplane.core.io.IElementContentHandler) IElementDOMHandler(org.freeplane.core.io.IElementDOMHandler) XMLElement(org.freeplane.n3.nanoxml.XMLElement) Point(java.awt.Point)

Example 42 with XMLElement

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

the class EdgeBuilder method writeContent.

private void writeContent(final ITreeWriter writer, final NodeModel node, final EdgeModel model, final boolean forceFormatting) throws IOException {
    final EdgeStyle styleObj = forceFormatting ? ec.getStyle(node) : model.getStyle();
    final String style = EdgeStyle.toString(styleObj);
    final Color color = forceFormatting ? ec.getColor(node) : model.getColor();
    final int width = forceFormatting ? ec.getWidth(node) : model.getWidth();
    if (forceFormatting || style != null || color != null || width != EdgeModel.DEFAULT_WIDTH) {
        final XMLElement edge = new XMLElement();
        edge.setName("edge");
        boolean relevant = false;
        if (style != null) {
            if (style.equals(EdgeStyle.EDGESTYLE_HIDDEN)) {
                edge.setAttribute("HIDE", "true");
                relevant = true;
            }
            edge.setAttribute("STYLE", style);
            relevant = true;
        }
        if (color != null) {
            edge.setAttribute("COLOR", ColorUtils.colorToString(color));
            relevant = true;
        }
        if (width != EdgeModel.WIDTH_PARENT) {
            if (width == EdgeModel.WIDTH_THIN) {
                edge.setAttribute("WIDTH", EdgeModel.EDGEWIDTH_THIN);
            } else {
                edge.setAttribute("WIDTH", Integer.toString(width));
            }
            relevant = true;
        }
        if (relevant) {
            writer.addElement(model, edge);
        }
    }
}
Also used : Color(java.awt.Color) XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 43 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 44 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 45 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 = XMLParserFactory.createDefaultXMLParser();
    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)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