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