use of org.freeplane.core.undo.IActor in project freeplane by freeplane.
the class MLinkController method setFormatNodeAsHyperlink.
public void setFormatNodeAsHyperlink(final NodeModel node, final Boolean enabled) {
final NodeLinks links = NodeLinks.createLinkExtension(node);
IActor actor = new IActor() {
final Boolean old = links.formatNodeAsHyperlink();
public void act() {
links.setFormatNodeAsHyperlink(enabled);
modeController.getMapController().nodeChanged(node);
}
public void undo() {
links.setFormatNodeAsHyperlink(old);
modeController.getMapController().nodeChanged(node);
}
public String getDescription() {
return "setFormatNodeAsHyperlink";
}
};
modeController.execute(actor, node.getMap());
}
use of org.freeplane.core.undo.IActor in project freeplane by freeplane.
the class MLinkController method insertMapLinksForClone.
public void insertMapLinksForClone(final NodeModel model) {
final MapModel map = model.getMap();
final MapLinks mapLinks = map.getExtension(MapLinks.class);
if (mapLinks != null) {
IActor actor = new IActor() {
@Override
public void undo() {
mapLinkChanger.deleteMapLinks(mapLinks, model, model);
}
@Override
public String getDescription() {
return "deleteMapLinks";
}
@Override
public void act() {
mapLinkChanger.insertMapLinks(mapLinks, model);
}
};
modeController.execute(actor, map);
}
}
use of org.freeplane.core.undo.IActor in project freeplane by freeplane.
the class MLinkController method setLabelFontSize.
public void setLabelFontSize(final ConnectorModel connector, final int width) {
final int oldWidth = connector.getLabelFontSize();
if (oldWidth == width) {
return;
}
final IActor actor = new IActor() {
public void act() {
connector.setLabelFontSize(width);
final NodeModel node = connector.getSource();
fireNodeConnectorChange(node, connector);
}
public String getDescription() {
return "setConnectorWidth";
}
public void undo() {
connector.setLabelFontSize(oldWidth);
final NodeModel node = connector.getSource();
fireNodeConnectorChange(node, connector);
}
};
Controller.getCurrentModeController().execute(actor, connector.getSource().getMap());
}
use of org.freeplane.core.undo.IActor in project freeplane by freeplane.
the class MapStyle method copyStyle.
public void copyStyle(final URL source, final MapModel targetMap, boolean undoable) {
final MapModel styleMapContainer = new MapModel();
final IExtension oldStyleModel = targetMap.getRootNode().removeExtension(MapStyleModel.class);
final ModeController modeController = Controller.getCurrentModeController();
final UrlManager urlManager = modeController.getExtension(UrlManager.class);
if (!urlManager.loadCatchExceptions(source, styleMapContainer))
return;
onCreate(styleMapContainer);
moveStyle(styleMapContainer, targetMap, true);
modeController.getExtension(AutomaticLayoutController.class).moveExtension(modeController, styleMapContainer, targetMap);
modeController.getExtension(AutomaticEdgeColorHook.class).moveExtension(modeController, styleMapContainer, targetMap);
LogicalStyleController.getController().refreshMap(targetMap);
if (!undoable) {
return;
}
final IExtension newStyleModel = targetMap.getRootNode().getExtension(MapStyleModel.class);
IActor actor = new IActor() {
public void undo() {
targetMap.getRootNode().putExtension(oldStyleModel);
}
public String getDescription() {
return "moveStyle";
}
public void act() {
targetMap.getRootNode().putExtension(newStyleModel);
}
};
Controller.getCurrentModeController().execute(actor, targetMap);
}
use of org.freeplane.core.undo.IActor in project freeplane by freeplane.
the class MLogicalStyleController method setStyle.
public void setStyle(final NodeModel node, final IStyle style) {
final ModeController modeController = Controller.getCurrentModeController();
final IStyle oldStyle = LogicalStyleModel.getStyle(node);
if (oldStyle != null && oldStyle.equals(style) || oldStyle == style) {
modeController.getMapController().nodeChanged(node, LogicalStyleModel.class, oldStyle, style);
return;
}
final IActor actor = new IActor() {
public String getDescription() {
return "setStyle";
}
public void act() {
changeStyle(modeController, node, oldStyle, style);
}
public void undo() {
changeStyle(modeController, node, style, oldStyle);
}
private void changeStyle(final ModeController modeController, final NodeModel node, final IStyle oldStyle, final IStyle style) {
if (style != null) {
final LogicalStyleModel model = LogicalStyleModel.createExtension(node);
model.setStyle(style);
} else {
node.removeExtension(LogicalStyleModel.class);
}
modeController.getMapController().nodeChanged(node, LogicalStyleModel.class, oldStyle, style);
selectActions();
}
};
modeController.execute(actor, node.getMap());
}
Aggregations