Search in sources :

Example 46 with IActor

use of org.freeplane.core.undo.IActor in project freeplane by freeplane.

the class MLinkController method setFormatNodeAsHyperlink.

public void setFormatNodeAsHyperlink(final NodeModel node, final Boolean enabled) {
    final NodeLinks links = NodeLinks.createLinkExtension(node);
    IActor actor = new IActor() {

        final Boolean old = links.formatNodeAsHyperlink();

        public void act() {
            links.setFormatNodeAsHyperlink(enabled);
            modeController.getMapController().nodeChanged(node);
        }

        public void undo() {
            links.setFormatNodeAsHyperlink(old);
            modeController.getMapController().nodeChanged(node);
        }

        public String getDescription() {
            return "setFormatNodeAsHyperlink";
        }
    };
    modeController.execute(actor, node.getMap());
}
Also used : NodeLinks(org.freeplane.features.link.NodeLinks) IActor(org.freeplane.core.undo.IActor)

Example 47 with IActor

use of org.freeplane.core.undo.IActor in project freeplane by freeplane.

the class MLinkController method insertMapLinksForClone.

public void insertMapLinksForClone(final NodeModel model) {
    final MapModel map = model.getMap();
    final MapLinks mapLinks = map.getExtension(MapLinks.class);
    if (mapLinks != null) {
        IActor actor = new IActor() {

            @Override
            public void undo() {
                mapLinkChanger.deleteMapLinks(mapLinks, model, model);
            }

            @Override
            public String getDescription() {
                return "deleteMapLinks";
            }

            @Override
            public void act() {
                mapLinkChanger.insertMapLinks(mapLinks, model);
            }
        };
        modeController.execute(actor, map);
    }
}
Also used : IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel) MapLinks(org.freeplane.features.link.MapLinks)

Example 48 with IActor

use of org.freeplane.core.undo.IActor in project freeplane by freeplane.

the class MLinkController method setLabelFontSize.

public void setLabelFontSize(final ConnectorModel connector, final int width) {
    final int oldWidth = connector.getLabelFontSize();
    if (oldWidth == width) {
        return;
    }
    final IActor actor = new IActor() {

        public void act() {
            connector.setLabelFontSize(width);
            final NodeModel node = connector.getSource();
            fireNodeConnectorChange(node, connector);
        }

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

        public void undo() {
            connector.setLabelFontSize(oldWidth);
            final NodeModel node = connector.getSource();
            fireNodeConnectorChange(node, connector);
        }
    };
    Controller.getCurrentModeController().execute(actor, connector.getSource().getMap());
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IActor(org.freeplane.core.undo.IActor) Point(java.awt.Point)

Example 49 with IActor

use of org.freeplane.core.undo.IActor in project freeplane by freeplane.

the class MapStyle method copyStyle.

public void copyStyle(final URL source, final MapModel targetMap, boolean undoable) {
    final MapModel styleMapContainer = new MapModel();
    final IExtension oldStyleModel = targetMap.getRootNode().removeExtension(MapStyleModel.class);
    final ModeController modeController = Controller.getCurrentModeController();
    final UrlManager urlManager = modeController.getExtension(UrlManager.class);
    if (!urlManager.loadCatchExceptions(source, styleMapContainer))
        return;
    onCreate(styleMapContainer);
    moveStyle(styleMapContainer, targetMap, true);
    modeController.getExtension(AutomaticLayoutController.class).moveExtension(modeController, styleMapContainer, targetMap);
    modeController.getExtension(AutomaticEdgeColorHook.class).moveExtension(modeController, styleMapContainer, targetMap);
    LogicalStyleController.getController().refreshMap(targetMap);
    if (!undoable) {
        return;
    }
    final IExtension newStyleModel = targetMap.getRootNode().getExtension(MapStyleModel.class);
    IActor actor = new IActor() {

        public void undo() {
            targetMap.getRootNode().putExtension(oldStyleModel);
        }

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

        public void act() {
            targetMap.getRootNode().putExtension(newStyleModel);
        }
    };
    Controller.getCurrentModeController().execute(actor, targetMap);
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) AutomaticEdgeColorHook(org.freeplane.features.edge.AutomaticEdgeColorHook) IExtension(org.freeplane.core.extension.IExtension) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController)

Example 50 with IActor

use of org.freeplane.core.undo.IActor 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)

Aggregations

IActor (org.freeplane.core.undo.IActor)123 NodeModel (org.freeplane.features.map.NodeModel)30 ModeController (org.freeplane.features.mode.ModeController)28 MapModel (org.freeplane.features.map.MapModel)27 MapController (org.freeplane.features.map.MapController)11 AttributeRegistry (org.freeplane.features.attribute.AttributeRegistry)10 Color (java.awt.Color)8 Point (java.awt.Point)6 MMapController (org.freeplane.features.map.mindmapmode.MMapController)6 NodeStyleModel (org.freeplane.features.nodestyle.NodeStyleModel)6 Controller (org.freeplane.features.mode.Controller)5 IStyle (org.freeplane.features.styles.IStyle)5 MapStyleModel (org.freeplane.features.styles.MapStyleModel)5 NoSuchElementException (java.util.NoSuchElementException)4 LengthUnits (org.freeplane.core.ui.LengthUnits)4 AttributeRegistryElement (org.freeplane.features.attribute.AttributeRegistryElement)4 Date (java.util.Date)3 IExtension (org.freeplane.core.extension.IExtension)3 IUndoHandler (org.freeplane.core.undo.IUndoHandler)3 EdgeModel (org.freeplane.features.edge.EdgeModel)3