use of org.freeplane.core.io.IAttributeWriter in project freeplane by freeplane.
the class LogicalStyleController method createBuilder.
private void createBuilder() {
ModeController modeController = Controller.getCurrentModeController();
final MapController mapController = modeController.getMapController();
final ReadManager readManager = mapController.getReadManager();
readManager.addAttributeHandler(NodeBuilder.XML_NODE, "STYLE_REF", new IAttributeHandler() {
public void setAttribute(final Object node, final String value) {
final LogicalStyleModel extension = LogicalStyleModel.createExtension((NodeModel) node);
extension.setStyle(StyleFactory.create(value));
}
});
readManager.addAttributeHandler(NodeBuilder.XML_NODE, "LOCALIZED_STYLE_REF", new IAttributeHandler() {
public void setAttribute(final Object node, final String value) {
final LogicalStyleModel extension = LogicalStyleModel.createExtension((NodeModel) node);
extension.setStyle(StyleFactory.create(TranslatedObject.format(value)));
}
});
final WriteManager writeManager = mapController.getWriteManager();
writeManager.addAttributeWriter(NodeBuilder.XML_NODE, new IAttributeWriter() {
public void writeAttributes(final ITreeWriter writer, final Object node, final String tag) {
if (!NodeWriter.shouldWriteSharedContent(writer))
return;
final LogicalStyleModel extension = LogicalStyleModel.getExtension((NodeModel) node);
if (extension == null) {
return;
}
final IStyle style = extension.getStyle();
if (style == null) {
return;
}
final String value = StyleTranslatedObject.toKeyString(style);
if (style instanceof StyleTranslatedObject) {
writer.addAttribute("LOCALIZED_STYLE_REF", value);
} else {
writer.addAttribute("STYLE_REF", value);
}
}
});
}
use of org.freeplane.core.io.IAttributeWriter in project freeplane by freeplane.
the class TreeXmlWriter method addElement.
@SuppressWarnings("unchecked")
public void addElement(final Object userObject, final XMLElement element) throws IOException {
final boolean isString = userObject instanceof String;
if (elementStarted == false && xmlElement != null) {
xmlwriter.write(xmlElement, !isString, 0, true, false);
}
final String name = element.getName();
xmlElement = element;
elementStarted = false;
{
final Iterator<IAttributeWriter> iterator = getAttributeWriters().iterator(name);
while (iterator.hasNext()) {
final IAttributeWriter as = iterator.next();
as.writeAttributes(this, userObject, name);
}
if (userObject instanceof List<?>) {
addExtensionAttributes(userObject, (List<IExtension>) userObject);
}
}
if (isString) {
addElementContent((String) userObject);
} else {
final Iterator<IElementWriter> iterator = getNodeWriters().iterator(name);
while (iterator.hasNext()) {
final IElementWriter nw = iterator.next();
nw.writeContent(this, userObject, name);
}
if (userObject instanceof List<?>) {
addExtensionNodes(userObject, (List<IExtension>) userObject);
}
}
if (elementStarted == false) {
xmlwriter.write(xmlElement, true, 0, true, true);
elementStarted = true;
} else {
xmlwriter.endElement(name, true);
}
}
Aggregations