Search in sources :

Example 6 with XMLElement

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

the class TreeXmlReader method elementAttributesProcessed.

/*
	 * (non-Javadoc)
	 * @see
	 * freeplane.persistence.xml.n3.nanoxml.IXMLBuilder#elementAttributesProcessed
	 * (java.lang.String, java.lang.String, java.lang.String)
	 */
public void elementAttributesProcessed(final String name, final String nsPrefix, final String nsURI) throws Exception {
    xmlBuilder.elementAttributesProcessed(name, nsPrefix, nsURI);
    if (saveAsXmlUntil != null || nodeCreator != null) {
        return;
    }
    final Iterator<IElementHandler> iterator = getElementHandlers().iterator(tag);
    final XMLElement lastBuiltElement = xmlBuilder.getLastBuiltElement();
    while (iterator.hasNext() && currentElement == null) {
        nodeCreator = iterator.next();
        currentElement = nodeCreator.createElement(parentElement, name, lastBuiltElement);
    }
    if (currentElement != null) {
        if (nodeCreator instanceof IElementContentHandler) {
            parser.notParseNextElementContent();
        }
        attributeHandlersForTag = getAttributeLoaders().get(tag);
        if (attributeHandlersForTag == null) {
            return;
        }
        final Enumeration<String> attributeNames = lastBuiltElement.enumerateAttributeNames();
        while (attributeNames.hasMoreElements()) {
            final String atName = (String) attributeNames.nextElement();
            if (addAttribute(atName, lastBuiltElement.getAttribute(atName, null))) {
                lastBuiltElement.removeAttribute(atName);
            }
        }
    } else {
        currentElement = null;
        nodeCreator = null;
        saveAsXmlUntil = lastBuiltElement;
    }
}
Also used : IElementContentHandler(org.freeplane.core.io.IElementContentHandler) IElementHandler(org.freeplane.core.io.IElementHandler) XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 7 with XMLElement

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

the class WindowConfigurationStorage method marshall.

private String marshall() {
    final XMLElement xml = new XMLElement();
    xml.setAttribute("x", Integer.toString(x));
    xml.setAttribute("y", Integer.toString(y));
    xml.setAttribute("width", Integer.toString(width));
    xml.setAttribute("height", Integer.toString(height));
    xml.setName(name);
    marshallSpecificElements(xml);
    final StringWriter string = new StringWriter();
    final XMLWriter writer = new XMLWriter(string);
    try {
        writer.write(xml);
        return string.toString();
    } catch (final IOException e) {
        LogUtils.severe(e);
        return null;
    }
}
Also used : StringWriter(java.io.StringWriter) IOException(java.io.IOException) XMLElement(org.freeplane.n3.nanoxml.XMLElement) XMLWriter(org.freeplane.n3.nanoxml.XMLWriter)

Example 8 with XMLElement

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

the class TreeXmlWriter method addElement.

public void addElement(final Object userObject, final String name) throws IOException {
    final XMLElement element = new XMLElement(name);
    addElement(userObject, element);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 9 with XMLElement

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

the class CloudBuilder method writeContentImpl.

private void writeContentImpl(final ITreeWriter writer, final NodeModel node, final IExtension extension) throws IOException {
    final CloudModel model = extension != null ? (CloudModel) extension : cc.getCloud(node);
    if (model == null) {
        return;
    }
    final XMLElement cloud = new XMLElement();
    cloud.setName("cloud");
    // final String style = model.getStyle();
    // if (style != null) {
    // cloud.setAttribute("STYLE", style);
    // }
    final Color color = model.getColor();
    if (color != null) {
        cloud.setAttribute("COLOR", ColorUtils.colorToString(color));
    }
    final CloudModel.Shape shape = model.getShape();
    if (shape != null) {
        cloud.setAttribute("SHAPE", shape.toString());
    }
    // final int width = model.getWidth();
    // if (width != CloudController.DEFAULT_WIDTH) {
    // cloud.setAttribute("WIDTH", Integer.toString(width));
    // }
    writer.addElement(model, cloud);
}
Also used : Color(java.awt.Color) XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 10 with XMLElement

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

the class AttributeBuilder method saveLayout.

private void saveLayout(AttributeTableLayoutModel layout, final ITreeWriter writer) throws IOException {
    if (layout != null) {
        XMLElement attributeElement = null;
        if (layout.getColumnWidth(0) != DEFAULT_COLUMN_WIDTH) {
            attributeElement = initializeNodeAttributeLayoutXMLElement(attributeElement);
            attributeElement.setAttribute("NAME_WIDTH", Integer.toString(layout.getColumnWidth(0)));
        }
        if (layout.getColumnWidth(1) != DEFAULT_COLUMN_WIDTH) {
            attributeElement = initializeNodeAttributeLayoutXMLElement(attributeElement);
            attributeElement.setAttribute("VALUE_WIDTH", Integer.toString(layout.getColumnWidth(1)));
        }
        if (attributeElement != null) {
            writer.addElement(layout, attributeElement);
        }
    }
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

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