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;
}
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);
}
}
}
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);
}
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);
}
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);
}
}
}
Aggregations