Search in sources :

Example 21 with XMLElement

use of org.freeplane.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();
        try {
            currentElement = nodeCreator.createElement(parentElement, name, lastBuiltElement);
        } catch (Exception e) {
            LogUtils.severe("Can not process element" + name, e);
        }
    }
    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) XMLException(org.freeplane.n3.nanoxml.XMLException)

Example 22 with XMLElement

use of org.freeplane.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 23 with XMLElement

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

the class FilterController method loadConditions.

void loadConditions(final DefaultComboBoxModel filterConditionModel, final String pathToFilterFile, final boolean showPopupOnError) throws IOException {
    try {
        final IXMLParser parser = XMLLocalParserFactory.createLocalXMLParser();
        File filterFile = new File(pathToFilterFile);
        final IXMLReader reader = new StdXMLReader(new BufferedInputStream(new FileInputStream(filterFile)));
        parser.setReader(reader);
        reader.setSystemID(filterFile.toURL().toString());
        final XMLElement loader = (XMLElement) parser.parse();
        final Vector<XMLElement> conditions = loader.getChildren();
        for (int i = 0; i < conditions.size(); i++) {
            final ASelectableCondition condition = getConditionFactory().loadCondition(conditions.get(i));
            if (condition != null) {
                filterConditionModel.addElement(condition);
            }
        }
    } catch (final FileNotFoundException e) {
    } catch (final AccessControlException e) {
    } catch (final Exception e) {
        LogUtils.warn(e);
        if (showPopupOnError) {
            UITools.errorMessage(TextUtils.getText("filters_not_loaded"));
        }
    }
}
Also used : IXMLReader(org.freeplane.n3.nanoxml.IXMLReader) FileNotFoundException(java.io.FileNotFoundException) AccessControlException(java.security.AccessControlException) XMLElement(org.freeplane.n3.nanoxml.XMLElement) FileInputStream(java.io.FileInputStream) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition) FileNotFoundException(java.io.FileNotFoundException) AccessControlException(java.security.AccessControlException) IOException(java.io.IOException) BufferedInputStream(java.io.BufferedInputStream) IXMLParser(org.freeplane.n3.nanoxml.IXMLParser) StdXMLReader(org.freeplane.n3.nanoxml.StdXMLReader) File(java.io.File)

Example 24 with XMLElement

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

the class ExportController method createXSLTExportActions.

private void createXSLTExportActions(final String xmlDescriptorFile) {
    InputStream xmlDescriptorStream = null;
    try {
        final IXMLParser parser = XMLLocalParserFactory.createLocalXMLParser();
        final URL resource = ResourceController.getResourceController().getResource(xmlDescriptorFile);
        xmlDescriptorStream = resource.openStream();
        final IXMLReader reader = new StdXMLReader(xmlDescriptorStream);
        parser.setReader(reader);
        final XMLElement xml = (XMLElement) parser.parse();
        final Enumeration<XMLElement> actionDescriptors = xml.enumerateChildren();
        while (actionDescriptors.hasMoreElements()) {
            final XMLElement descriptor = actionDescriptors.nextElement();
            final String name = descriptor.getAttribute("name", null);
            final XMLElement xmlProperties = descriptor.getFirstChildNamed("properties");
            final Properties properties = xmlProperties.getAttributes();
            final ExportWithXSLT action = new ExportWithXSLT(name, properties);
            addExportEngine(action.getFileFilter(), action);
        }
    } catch (final Exception e) {
        LogUtils.severe(e);
    } finally {
        FileUtils.silentlyClose(xmlDescriptorStream);
    }
}
Also used : IXMLReader(org.freeplane.n3.nanoxml.IXMLReader) InputStream(java.io.InputStream) IXMLParser(org.freeplane.n3.nanoxml.IXMLParser) StdXMLReader(org.freeplane.n3.nanoxml.StdXMLReader) XMLElement(org.freeplane.n3.nanoxml.XMLElement) Properties(java.util.Properties) URL(java.net.URL)

Example 25 with XMLElement

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

the class MapStyle method saveConditionalStyles.

private void saveConditionalStyles(ConditionalStyleModel conditionalStyleModel, XMLElement parent, boolean createRoot) {
    final int styleCount = conditionalStyleModel.getStyleCount();
    if (styleCount == 0) {
        return;
    }
    final XMLElement conditionalStylesRoot;
    if (createRoot) {
        conditionalStylesRoot = parent.createElement("conditional_styles");
        parent.addChild(conditionalStylesRoot);
    } else
        conditionalStylesRoot = parent;
    for (final Item item : conditionalStyleModel) {
        item.toXml(conditionalStylesRoot);
    }
}
Also used : Item(org.freeplane.features.styles.ConditionalStyleModel.Item) 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)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