use of org.freeplane.core.undo.IActor in project freeplane by freeplane.
the class MapStyle method setBackgroundColor.
public void setBackgroundColor(final MapStyleModel model, final Color color) {
final Color actionColor = ColorUtils.makeNonTransparent(color);
final Color oldColor = model.getBackgroundColor();
if (actionColor == oldColor || actionColor != null && actionColor.equals(oldColor)) {
return;
}
final IActor actor = new IActor() {
public void act() {
model.setBackgroundColor(actionColor);
Controller.getCurrentModeController().getMapController().fireMapChanged(new MapChangeEvent(MapStyle.this, Controller.getCurrentController().getMap(), MapStyle.RESOURCES_BACKGROUND_COLOR, oldColor, actionColor));
}
public String getDescription() {
return "MapStyle.setBackgroundColor";
}
public void undo() {
model.setBackgroundColor(oldColor);
Controller.getCurrentModeController().getMapController().fireMapChanged(new MapChangeEvent(MapStyle.this, Controller.getCurrentController().getMap(), MapStyle.RESOURCES_BACKGROUND_COLOR, actionColor, oldColor));
}
};
Controller.getCurrentModeController().execute(actor, Controller.getCurrentController().getMap());
}
use of org.freeplane.core.undo.IActor in project freeplane by freeplane.
the class MapStyle method setProperty.
public void setProperty(final MapModel model, final String key, final String newValue) {
final MapStyleModel styleModel = MapStyleModel.getExtension(model);
final String oldValue = styleModel.getProperty(key);
if (oldValue == newValue || oldValue != null && oldValue.equals(newValue)) {
return;
}
IActor actor = new IActor() {
public void undo() {
setPropertyWithoutUndo(model, key, oldValue);
}
public String getDescription() {
return "set map style property";
}
public void act() {
setPropertyWithoutUndo(model, key, newValue);
}
private void setPropertyWithoutUndo(final MapModel model, final String key, final String newValue) {
styleModel.setProperty(key, newValue);
Controller.getCurrentModeController().getMapController().fireMapChanged(new MapChangeEvent(MapStyle.this, model, key, oldValue, newValue));
}
};
Controller.getCurrentModeController().execute(actor, model);
}
use of org.freeplane.core.undo.IActor in project freeplane by freeplane.
the class UndoableNamedElementCollection method removeCurrentElement.
public void removeCurrentElement() {
final int currentElementIndex = collection.getCurrentElementIndex();
final T removedElement = collection.getCurrentElement();
IActor actor = new IActor() {
@Override
public String getDescription() {
return "removeCurrentElement";
}
@Override
public void act() {
collection.selectCurrentElement(currentElementIndex);
collection.removeCurrentElement();
}
@Override
public void undo() {
collection.selectCurrentElement(currentElementIndex - 1);
collection.add(removedElement);
}
};
controller.execute(actor, mapModel);
}
use of org.freeplane.core.undo.IActor in project freeplane by freeplane.
the class UndoableNamedElementCollection method add.
public void add(final String name) {
final int currentElementIndex = collection.getCurrentElementIndex();
IActor actor = new IActor() {
@Override
public String getDescription() {
return "add";
}
@Override
public void act() {
collection.selectCurrentElement(currentElementIndex);
collection.add(name);
}
@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 MNoteController method setNoteText.
public void setNoteText(final NodeModel node, final String newText) {
final String oldText = getNoteText(node);
if (oldText == newText || null != oldText && oldText.equals(newText)) {
return;
}
final IActor actor = new IActor() {
public void act() {
setText(newText);
}
public String getDescription() {
return "setNoteText";
}
private void setText(final String text) {
final boolean enabled = !(text == null || text.equals(""));
if (enabled) {
final NoteModel note = NoteModel.createNote(node);
note.setHtml(text);
node.addExtension(note);
} else {
if (null != node.getExtension(NoteModel.class)) {
node.removeExtension(NoteModel.class);
}
}
Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NOTE_TEXT, oldText, text);
if (noteManager != null)
noteManager.updateEditor();
}
public void undo() {
setText(oldText);
}
};
Controller.getCurrentModeController().execute(actor, node.getMap());
}
Aggregations