final IActor actor = new IActor() {
private URI oldlink;
private String oldTargetID;
public void act() {
NodeLinks links = NodeLinks.getLinkExtension(node);
if (links != null) {
oldlink = links.getHyperLink(node);
oldTargetID = links.removeLocalHyperLink(node);
}
else {
links = NodeLinks.createLinkExtension(node);
}
if (uri != null && uri.toString().startsWith("#")) {
links.setLocalHyperlink(node, uri.toString().substring(1));
}
else
links.setHyperLink(uri);
Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeLinks.HYPERLINK_CHANGED, oldlink, uri);
}
public String getDescription() {
return "setLink";
}
public void undo() {
final NodeLinks links = NodeLinks.getLinkExtension(node);
URI undoneLink = links.getHyperLink(node);
links.setLocalHyperlink(node, oldTargetID);
links.setHyperLink(oldlink);
Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeLinks.HYPERLINK_CHANGED, undoneLink, oldlink);
}
};
Controller.getCurrentModeController().execute(actor, node.getMap());
}