Search in sources :

Example 21 with IUndoHandler

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

the class ModeController method undoableRemoveExtensions.

public void undoableRemoveExtensions(final Object key, final NodeModel from, final NodeModel which) {
    final MapModel map = from.getMap();
    if (map == null) {
        removeExtensions(key, from, which);
        return;
    }
    final IUndoHandler undoHandler = map.getExtension(IUndoHandler.class);
    if (undoHandler == null) {
        removeExtensions(key, from, which);
        return;
    }
    final NodeModel backup = new NodeModel(null);
    copyExtensions(key, from, backup);
    final IActor actor = new IActor() {

        public void undo() {
            copyExtensions(key, backup, from);
            getMapController().nodeChanged(from);
        }

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

        public void act() {
            removeExtensions(key, from, which);
            getMapController().nodeChanged(from);
        }
    };
    execute(actor, map);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IActor(org.freeplane.core.undo.IActor) IUndoHandler(org.freeplane.core.undo.IUndoHandler) MapModel(org.freeplane.features.map.MapModel)

Aggregations

IUndoHandler (org.freeplane.core.undo.IUndoHandler)21 MapModel (org.freeplane.features.map.MapModel)15 MMapModel (org.freeplane.features.map.mindmapmode.MMapModel)10 Controller (org.freeplane.features.mode.Controller)4 IActor (org.freeplane.core.undo.IActor)3 NodeModel (org.freeplane.features.map.NodeModel)3 IMapViewManager (org.freeplane.features.ui.IMapViewManager)3 ModeController (org.freeplane.features.mode.ModeController)2 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)2 ViewController (org.freeplane.features.ui.ViewController)2 Component (java.awt.Component)1 Window (java.awt.Window)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 JDialog (javax.swing.JDialog)1 WindowConfigurationStorage (org.freeplane.core.resources.WindowConfigurationStorage)1 MapStyleModel (org.freeplane.features.styles.MapStyleModel)1