Here are the complete implementations of LinkingTool.doActivate and LinkingTool.doDeactivate. Pardon me if there are any references to internal properties or methods.
LinkingTool.prototype.doActivate = function() {
var diagram = this.diagram;
if (diagram === null) return;
var startPort = this.findLinkablePort();
if (startPort === null) return;
this.startTransaction(this.name);
diagram.isMouseCaptured = true;
diagram.currentCursor = 'pointer';
if (this.isForwards) {
if (this.temporaryToNode !== null && !this.temporaryToNode.location.isReal()) {
this.temporaryToNode.location = diagram.lastInput.documentPoint;
}
this.originalFromPort = startPort;
var node = this.originalFromPort.part;
if (node instanceof Node) this.originalFromNode = /** @type {Node} */ (node);
this.copyPortProperties(this.originalFromNode, this.originalFromPort, this.temporaryFromNode, this.temporaryFromPort, false);
} else {
if (this.temporaryFromNode !== null && !this.temporaryFromNode.location.isReal()) {
this.temporaryFromNode.location = diagram.lastInput.documentPoint;
}
this.originalToPort = startPort;
var node = this.originalToPort.part;
if (node instanceof Node) this.originalToNode = /** @type {Node} */ (node);
this.copyPortProperties(this.originalToNode, this.originalToPort, this.temporaryToNode, this.temporaryToPort, true);
}
diagram.add(this.temporaryFromNode);
diagram.add(this.temporaryToNode);
if (this.temporaryLink !== null) {
if (this.temporaryFromNode !== null) {
this.temporaryLink.fromNode = this.temporaryFromNode;
}
if (this.temporaryToNode !== null) {
this.temporaryLink.toNode = this.temporaryToNode;
}
this.temporaryLink.invalidateRoute();
diagram.add(this.temporaryLink);
}
this.isActive = true;
};
LinkingTool.prototype.doDeactivate = function() {
this.isActive = false;
var diagram = this.diagram;
if (diagram === null) return;
diagram.remove(this.temporaryLink);
diagram.remove(this.temporaryFromNode);
diagram.remove(this.temporaryToNode);
diagram.isMouseCaptured = false;
diagram.currentCursor = '';
this.stopTransaction();
};