Search in sources :

Example 1 with ReadManager

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);
}
Also used : INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) ReadManager(org.freeplane.core.io.ReadManager) URI(java.net.URI) MapController(org.freeplane.features.map.MapController)

Example 2 with ReadManager

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);
            }
        }
    });
}
Also used : IAttributeWriter(org.freeplane.core.io.IAttributeWriter) IAttributeHandler(org.freeplane.core.io.IAttributeHandler) ModeController(org.freeplane.features.mode.ModeController) MapController(org.freeplane.features.map.MapController) NodeModel(org.freeplane.features.map.NodeModel) ReadManager(org.freeplane.core.io.ReadManager) ITreeWriter(org.freeplane.core.io.ITreeWriter) TranslatedObject(org.freeplane.core.resources.TranslatedObject) WriteManager(org.freeplane.core.io.WriteManager)

Aggregations

ReadManager (org.freeplane.core.io.ReadManager)2 MapController (org.freeplane.features.map.MapController)2 NodeModel (org.freeplane.features.map.NodeModel)2 URI (java.net.URI)1 IAttributeHandler (org.freeplane.core.io.IAttributeHandler)1 IAttributeWriter (org.freeplane.core.io.IAttributeWriter)1 ITreeWriter (org.freeplane.core.io.ITreeWriter)1 WriteManager (org.freeplane.core.io.WriteManager)1 TranslatedObject (org.freeplane.core.resources.TranslatedObject)1 INodeSelectionListener (org.freeplane.features.map.INodeSelectionListener)1 ModeController (org.freeplane.features.mode.ModeController)1