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());
}
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());
}
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();
}
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);
}
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);
}
Aggregations