Search in sources :

Example 11 with IActor

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

the class MIconController method addIcon.

public void addIcon(final NodeModel node, final MindIcon icon) {
    final IActor actor = new IActor() {

        public void act() {
            node.addIcon(icon);
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON, null, icon);
        }

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

        public void undo() {
            node.removeIcon();
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON, icon, null);
        }
    };
    Controller.getCurrentModeController().execute(actor, node.getMap());
}
Also used : IActor(org.freeplane.core.undo.IActor)

Example 12 with IActor

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

the class MIconController method addIcon.

public void addIcon(final NodeModel node, final MindIcon icon, final int position) {
    final IActor actor = new IActor() {

        public void act() {
            node.addIcon(icon, position);
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON, null, icon);
        }

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

        public void undo() {
            node.removeIcon(position);
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON, icon, null);
        }
    };
    Controller.getCurrentModeController().execute(actor, node.getMap());
}
Also used : IActor(org.freeplane.core.undo.IActor)

Example 13 with IActor

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

the class MIconController method removeIcon.

public int removeIcon(final NodeModel node, final int position) {
    final int size = node.getIcons().size();
    final int index = position >= 0 ? position : size + position;
    if (size == 0 || size <= index) {
        return size;
    }
    final IActor actor = new IActor() {

        private final MindIcon icon = node.getIcon(index);

        public void act() {
            node.removeIcon(index);
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON, icon, null);
        }

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

        public void undo() {
            node.addIcon(icon, index);
            Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON, null, icon);
        }
    };
    Controller.getCurrentModeController().execute(actor, node.getMap());
    return node.getIcons().size();
}
Also used : IActor(org.freeplane.core.undo.IActor) MindIcon(org.freeplane.features.icon.MindIcon) Point(java.awt.Point)

Example 14 with IActor

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

the class UndoableNamedElementCollection method copyCurrentElement.

public void copyCurrentElement() {
    final int currentElementIndex = collection.getCurrentElementIndex();
    IActor actor = new IActor() {

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

        @Override
        public void act() {
            collection.selectCurrentElement(currentElementIndex);
            collection.copyCurrentElement();
        }

        @Override
        public void undo() {
            collection.selectCurrentElement(currentElementIndex + 1);
            collection.removeCurrentElement();
            collection.selectCurrentElement(currentElementIndex);
        }
    };
    controller.execute(actor, mapModel);
}
Also used : IActor(org.freeplane.core.undo.IActor)

Example 15 with IActor

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

the class UndoableNamedElementCollection method moveCurrentElementTo.

public void moveCurrentElementTo(final int newElementIndex) {
    if (!collection.canMoveCurrentElementTo(newElementIndex))
        return;
    final int oldElementIndex = collection.getCurrentElementIndex();
    IActor actor = new IActor() {

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

        @Override
        public void act() {
            collection.selectCurrentElement(oldElementIndex);
            collection.moveCurrentElementTo(newElementIndex);
        }

        @Override
        public void undo() {
            collection.selectCurrentElement(newElementIndex);
            collection.moveCurrentElementTo(oldElementIndex);
        }
    };
    controller.execute(actor, mapModel);
}
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