Search in sources :

Example 56 with IActor

use of org.freeplane.core.undo.IActor 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 (!((StyleTranslatedObject) 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 : StyleTranslatedObject(org.freeplane.features.styles.StyleTranslatedObject) 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)

Example 57 with IActor

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

the class MLinkController method setAlpha.

public void setAlpha(final ConnectorModel connector, final int alpha) {
    final int oldAlpha = connector.getAlpha();
    if (oldAlpha == alpha) {
        return;
    }
    final IActor actor = new IActor() {

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

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

        public void undo() {
            connector.setAlpha(oldAlpha);
            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 58 with IActor

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

the class MLinkController method setLink.

public void setLink(final NodeModel node, final URI argUri, final int linkType) {
    final URI uri = relativeLink(argUri, node, linkType);
    final IActor actor = new IActor() {

        private URI oldlink;

        private String oldTargetID;

        public void act() {
            NodeLinks links = NodeLinks.getLinkExtension(node);
            if (links != null) {
                oldlink = links.getHyperLink(node);
                oldTargetID = links.removeLocalHyperLink(node);
            } else {
                links = NodeLinks.createLinkExtension(node);
            }
            if (uri != null && uri.toString().startsWith("#")) {
                links.setLocalHyperlink(node, uri.toString().substring(1));
            } else
                links.setHyperLink(uri);
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeLinks.HYPERLINK_CHANGED, oldlink, uri);
        }

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

        public void undo() {
            final NodeLinks links = NodeLinks.getLinkExtension(node);
            URI undoneLink = links.getHyperLink(node);
            links.setLocalHyperlink(node, oldTargetID);
            links.setHyperLink(oldlink);
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeLinks.HYPERLINK_CHANGED, undoneLink, oldlink);
        }
    };
    Controller.getCurrentModeController().execute(actor, node.getMap());
}
Also used : NodeLinks(org.freeplane.features.link.NodeLinks) IActor(org.freeplane.core.undo.IActor) URI(java.net.URI)

Example 59 with IActor

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

the class MLinkController method setConnectorDash.

public void setConnectorDash(final ConnectorModel arrowLink, final int[] dash) {
    final int[] oldDash = arrowLink.getDash();
    if (dash == oldDash || dash != null && dash.equals(oldDash)) {
        return;
    }
    final IActor actor = new IActor() {

        public void act() {
            arrowLink.setDash(dash);
            final NodeModel node = arrowLink.getSource();
            fireNodeConnectorChange(node, arrowLink);
        }

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

        public void undo() {
            arrowLink.setDash(oldDash);
            final NodeModel node = arrowLink.getSource();
            fireNodeConnectorChange(node, arrowLink);
        }
    };
    Controller.getCurrentModeController().execute(actor, arrowLink.getSource().getMap());
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IActor(org.freeplane.core.undo.IActor)

Example 60 with IActor

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

the class MLinkController method removeArrowLink.

public void removeArrowLink(final ConnectorModel arrowLink) {
    final IActor actor = new IActor() {

        public void act() {
            final NodeModel source = arrowLink.getSource();
            final NodeLinks nodeLinks = NodeLinks.getLinkExtension(source);
            nodeLinks.removeArrowlink(arrowLink);
            fireNodeConnectorChange(source, arrowLink);
        }

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

        public void undo() {
            final NodeModel source = arrowLink.getSource();
            NodeLinks nodeLinks = NodeLinks.createLinkExtension(source);
            nodeLinks.addArrowlink(arrowLink);
            fireNodeConnectorChange(source, arrowLink);
        }
    };
    Controller.getCurrentModeController().execute(actor, arrowLink.getSource().getMap());
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeLinks(org.freeplane.features.link.NodeLinks) IActor(org.freeplane.core.undo.IActor)

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