Search in sources :

Example 91 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class TextController method install.

public static void install(final TextController textController) {
    final ModeController modeController = Controller.getCurrentModeController();
    modeController.addExtension(TextController.class, textController);
}
Also used : ModeController(org.freeplane.features.mode.ModeController)

Example 92 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class TextController method registerNodeTextTooltip.

private void registerNodeTextTooltip() {
    modeController.addToolTipProvider(NODE_TOOLTIP, new ITooltipProvider() {

        public String getTooltip(final ModeController modeController, NodeModel node, Component view) {
            if (!ShortenedTextModel.isShortened(node)) {
                return null;
            }
            final NodeStyleController style = (NodeStyleController) modeController.getExtension(NodeStyleController.class);
            final Font font = style.getFont(node);
            final StringBuilder rule = new StringBuilder();
            rule.append("font-family: " + font.getFamily() + ";");
            rule.append("font-size: " + font.getSize() + "pt;");
            rule.append("margin-top:0;");
            if (font.isItalic()) {
                rule.append("font-style: italic; ");
            }
            if (font.isBold()) {
                rule.append("font-weight: bold; ");
            }
            final Color nodeTextColor = view.getForeground();
            rule.append("color: ").append(ColorUtils.colorToString(nodeTextColor)).append(";");
            final Object data = node.getUserObject();
            String text;
            try {
                text = getTransformedText(data, node, data);
            } catch (Exception e) {
                text = TextUtils.format("MainView.errorUpdateText", data, e.getLocalizedMessage());
                rule.append("color:red;");
            }
            if (!HtmlUtils.isHtmlNode(text)) {
                text = HtmlUtils.plainToHTML(text);
            }
            final String tooltipText = text.replaceFirst("<body>", "<body><div style=\"" + rule + "\">").replaceFirst("</body>", "</div></body>");
            return tooltipText;
        }
    });
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) Color(java.awt.Color) ITooltipProvider(org.freeplane.features.map.ITooltipProvider) ModeController(org.freeplane.features.mode.ModeController) Component(java.awt.Component) Font(java.awt.Font)

Example 93 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class MLogicalStyleController method setStyle.

public void setStyle(final NodeModel node, final IStyle style) {
    final ModeController modeController = Controller.getCurrentModeController();
    final IStyle oldStyle = LogicalStyleModel.getStyle(node);
    if (oldStyle != null && oldStyle.equals(style) || oldStyle == style) {
        modeController.getMapController().nodeChanged(node, LogicalStyleModel.class, oldStyle, style);
        return;
    }
    final IActor actor = new IActor() {

        public String getDescription() {
            return "setStyle";
        }

        public void act() {
            changeStyle(modeController, node, oldStyle, style);
        }

        public void undo() {
            changeStyle(modeController, node, style, oldStyle);
        }

        private void changeStyle(final ModeController modeController, final NodeModel node, final IStyle oldStyle, final IStyle style) {
            if (style != null) {
                final LogicalStyleModel model = LogicalStyleModel.createExtension(node);
                model.setStyle(style);
            } else {
                node.removeExtension(LogicalStyleModel.class);
            }
            modeController.getMapController().nodeChanged(node, LogicalStyleModel.class, oldStyle, style);
            selectActions();
        }
    };
    modeController.execute(actor, node.getMap());
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController) LogicalStyleModel(org.freeplane.features.styles.LogicalStyleModel)

Example 94 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class FreeplaneHeadlessStarter method createFrame.

public void createFrame(final String[] args) {
    Controller controller = Controller.getCurrentController();
    ModeController modeController = controller.getModeController(MModeController.MODENAME);
    controller.selectModeForBuild(modeController);
}
Also used : ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) FilterController(org.freeplane.features.filter.FilterController) HelpController(org.freeplane.features.help.HelpController) MapController(org.freeplane.features.map.MapController) LogicalStyleFilterController(org.freeplane.features.styles.LogicalStyleFilterController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) ModeController(org.freeplane.features.mode.ModeController) FormatController(org.freeplane.features.format.FormatController) ApplicationResourceController(org.freeplane.main.application.ApplicationResourceController) ModelessAttributeController(org.freeplane.features.attribute.ModelessAttributeController) ResourceController(org.freeplane.core.resources.ResourceController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ScannerController(org.freeplane.features.format.ScannerController) LinkController(org.freeplane.features.link.LinkController) TimeController(org.freeplane.features.time.TimeController)

Example 95 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class DeleteUserStyleAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentModeController();
    final Controller controller = modeController.getController();
    final NodeModel selected = controller.getSelection().getSelected();
    if (selected.depth() < 2) {
        UITools.errorMessage(TextUtils.getText("can_not_delete_style_group"));
        return;
    }
    final MapModel map = selected.getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    final NodeModel styleNodeGroup = styleModel.getStyleNodeGroup(selected);
    if (!((StyleNamedObject) styleNodeGroup.getUserObject()).getObject().equals("styles.user-defined")) {
        UITools.errorMessage(TextUtils.getText("can_not_delete_predefined_style"));
        return;
    }
    final MMapController mapController = (MMapController) modeController.getMapController();
    mapController.deleteNode(selected);
    final IActor actor = new IActor() {

        public void undo() {
            styleModel.addStyleNode(selected);
        }

        public String getDescription() {
            return "DeleteStyle";
        }

        public void act() {
            styleModel.removeStyleNode(selected);
        }
    };
    Controller.getCurrentModeController().execute(actor, map);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) StyleNamedObject(org.freeplane.features.styles.StyleNamedObject)

Aggregations

ModeController (org.freeplane.features.mode.ModeController)222 NodeModel (org.freeplane.features.map.NodeModel)90 Controller (org.freeplane.features.mode.Controller)56 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)48 MapModel (org.freeplane.features.map.MapModel)37 IActor (org.freeplane.core.undo.IActor)31 MapController (org.freeplane.features.map.MapController)30 ResourceController (org.freeplane.core.resources.ResourceController)29 MMapController (org.freeplane.features.map.mindmapmode.MMapController)20 File (java.io.File)17 TextController (org.freeplane.features.text.TextController)17 Color (java.awt.Color)16 Point (java.awt.Point)16 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)15 MapView (org.freeplane.view.swing.map.MapView)13 NodeView (org.freeplane.view.swing.map.NodeView)13 Component (java.awt.Component)12 URL (java.net.URL)12 LinkController (org.freeplane.features.link.LinkController)12 MenuBuilder (org.freeplane.core.ui.MenuBuilder)11