use of org.freeplane.core.io.WriteManager in project freeplane by freeplane.
the class LinkController method init.
protected void init(ModeController modeController) {
createActions();
final MapController mapController = modeController.getMapController();
final ReadManager readManager = mapController.getReadManager();
final WriteManager writeManager = mapController.getWriteManager();
new LinkBuilder(this).registerBy(readManager, writeManager);
final LinkTransformer textTransformer = new LinkTransformer(modeController, 10);
TextController.getController(modeController).addTextTransformer(textTransformer);
textTransformer.registerListeners(modeController);
final INodeSelectionListener listener = new INodeSelectionListener() {
public void onDeselect(final NodeModel node) {
}
public void onSelect(final NodeModel node) {
final URI link = NodeLinks.getValidLink(node);
final String linkString = (link != null ? link.toString() : null);
if (linkString != null) {
Controller.getCurrentController().getViewController().out(linkString);
}
}
};
Controller.getCurrentModeController().getMapController().addNodeSelectionListener(listener);
}
use of org.freeplane.core.io.WriteManager 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(NamedObject.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 = StyleNamedObject.toKeyString(style);
if (style instanceof StyleNamedObject) {
writer.addAttribute("LOCALIZED_STYLE_REF", value);
} else {
writer.addAttribute("STYLE_REF", value);
}
}
});
}
Aggregations