use of org.freeplane.core.io.ReadManager in project freeplane by freeplane.
the class LinkController method init.
protected void init() {
createActions();
final MapController mapController = modeController.getMapController();
final ReadManager readManager = mapController.getReadManager();
LinkBuilder linkBuilder = new LinkBuilder(this);
linkBuilder.registerBy(readManager);
// this IContentTransformer is unconditional because the outcome
// (#ID_1698830792 -> Nodename) is usually wanted
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.ReadManager 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);
}
}
});
}
Aggregations