Search in sources :

Example 66 with IActor

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

the class MLinkController method setConnectorColor.

public void setConnectorColor(final ConnectorModel arrowLink, final Color color) {
    final Color oldColor = arrowLink.getColor();
    if (color == oldColor || color != null && color.equals(oldColor)) {
        return;
    }
    final IActor actor = new IActor() {

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

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

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

Example 67 with IActor

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

the class MIconController method changeIconSize.

public void changeIconSize(final NodeModel node, final Quantity<LengthUnits> iconSize) {
    final IActor actor = new IActor() {

        private Quantity<LengthUnits> oldIconSize;

        public void act() {
            oldIconSize = node.getSharedData().getIcons().getIconSize();
            node.getSharedData().getIcons().setIconSize(iconSize);
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON_SIZE, null, iconSize);
        }

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

        public void undo() {
            node.getSharedData().getIcons().setIconSize(oldIconSize);
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON_SIZE, oldIconSize, null);
        }
    };
    Controller.getCurrentModeController().execute(actor, node.getMap());
}
Also used : IActor(org.freeplane.core.undo.IActor) Quantity(org.freeplane.core.util.Quantity)

Example 68 with IActor

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

the class MapController method nodeRefresh.

public void nodeRefresh(final NodeChangeEvent nodeChangeEvent) {
    if (mapReader.isMapLoadingInProcess()) {
        return;
    }
    final NodeModel node = nodeChangeEvent.getNode();
    if (nodeChangeEvent.setsDirtyFlag())
        setSaved(node.getMap(), false);
    if (nodeChangeEvent.updatesModificationTime() && !Controller.getCurrentModeController().isUndoAction()) {
        final HistoryInformationModel historyInformation = node.getHistoryInformation();
        if (historyInformation != null) {
            final IActor historyActor = new IActor() {

                private final Date lastModifiedAt = historyInformation.getLastModifiedAt();

                private final Date now = new Date();

                @Override
                public void undo() {
                    setDate(historyInformation, lastModifiedAt);
                }

                private void setDate(final HistoryInformationModel historyInformation, final Date lastModifiedAt) {
                    final Date oldLastModifiedAt = historyInformation.getLastModifiedAt();
                    historyInformation.setLastModifiedAt(lastModifiedAt);
                    final NodeChangeEvent nodeChangeEvent = new NodeChangeEvent(node, HistoryInformationModel.class, oldLastModifiedAt, lastModifiedAt, false, false);
                    fireNodeChanged(node, nodeChangeEvent);
                }

                @Override
                public String getDescription() {
                    return null;
                }

                @Override
                public void act() {
                    setDate(historyInformation, now);
                }
            };
            Controller.getCurrentModeController().execute(historyActor, node.getMap());
        }
    }
    fireNodeChanged(node, nodeChangeEvent);
}
Also used : IActor(org.freeplane.core.undo.IActor) Date(java.util.Date)

Example 69 with IActor

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

the class OpenMapsNodeHook method createUndoActor.

private IActor createUndoActor(final OpenMapsExtension extension, final ICoordinate newlyChoosenLocation, final ICoordinate currentlyStoredLocation, final int newlyChoosenZoom, final int currentlyStoredZoom) {
    return new IActor() {

        private final ICoordinate oldLocation = currentlyStoredLocation;

        private final int oldZoom = currentlyStoredZoom;

        public void act() {
            extension.updateLocation(newlyChoosenLocation);
            extension.updateZoom(newlyChoosenZoom);
            final MapModel map = Controller.getCurrentModeController().getController().getMap();
            Controller.getCurrentModeController().getMapController().setSaved(map, false);
        }

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

        public void undo() {
            if (oldLocation.getLat() == 500 && oldLocation.getLon() == 500) {
                removeLocationFromCurrentlySelectedNode();
            } else {
                extension.updateLocation(oldLocation);
                extension.updateZoom(oldZoom);
            }
            refreshNode(getCurrentlySelectedNode());
        }
    };
}
Also used : ICoordinate(org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel)

Example 70 with IActor

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

the class LogicalStyleController method refreshMap.

public void refreshMap(final MapModel map) {
    final IActor actor = new IActor() {

        public void undo() {
            refreshMapLater(map);
        }

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

        public void act() {
            refreshMapLater(map);
        }
    };
    Controller.getCurrentModeController().execute(actor, map);
}
Also used : 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