Class RelinkingTool

Extends LinkingBaseTool. The RelinkingTool allows the user to reconnect an existing Link if the Link.relinkableTo and/or Link.relinkableFrom properties are true.

For a general discussion of validation, see Introduction to Validation.

By default an instance of this tool is installed as a mouse-down tool in the Diagram.toolManager as the ToolManager.relinkingTool.

This tool makes use of two Adornments, each including a relink handle (potentially one for each end of the link), shown when a link is selected.

This tool conducts a transaction while the tool is active. A successful relinking will result in a "LinkRelinked" DiagramEvent and a "Relinking" transaction.

Constructor Summary Details

Name Description
RelinkingTool()

You do not normally need to create an instance of this tool because one already exists as the ToolManager.relinkingTool, which you can modify.More...

The Tool.name of this tool is "Relinking".

Properties Summary Details

Name, Value Type Description
fromHandleArchetype

Gets or sets a small GraphObject that is copied as a relinking handle for the selected link path at the "from" end of the link.More... By default this is a Shape that is a small blue diamond. Setting this property does not raise any events.

Here is an example of changing the default handle to be larger green triangles:

myDiagram.toolManager.relinkingTool.toHandleArchetype =
  $(go.Shape, "Triangle",
    { width: 10, height: 10, fill: "limegreen", segmentIndex: 0 });
handle

This read-only property returns the GraphObject that is the tool handle being dragged by the user.More... This will be contained by an Adornment whose category is "RelinkFrom" or "RelinkTo". Its Adornment.adornedPart is the same as the originalLink.

toHandleArchetype

Gets or sets a small GraphObject that is copied as a relinking handle for the selected link path at the "to" end of the link.More... By default this is a Shape that is a small blue diamond. Setting this property does not raise any events.

Here is an example of changing the default handle to be larger orange triangles:

  myDiagram.toolManager.relinkingTool.toHandleArchetype =
  $(go.Shape, "Triangle",
    { width: 10, height: 10, fill: "orange", segmentIndex: -1 });
Properties borrowed from class LinkingBaseTool:
isForwards, isUnconnectedLinkValid, linkValidation, originalFromNode, originalFromPort, originalLink, originalToNode, originalToPort, portGravity, portTargeted, targetPort, temporaryFromNode, temporaryFromPort, temporaryLink, temporaryToNode, temporaryToPort
Properties borrowed from class Tool:
diagram, isActive, isEnabled, name, transactionResult

Method Summary Details

Name, Return Type Description
canStart()
{boolean}

This tool can run when the diagram allows relinking, the model is modifiable, and there is a relink handle at the mouse-down point.More...

This method may be overridden, but we recommend that you call this base method.

Returns:
{boolean}
copyLinkProperties(reallink, templink)
1.3

Make a temporary link look and act like the real Link being relinked.More... By default this method copies many of the routing-oriented properties from the LinkingBaseTool.originalLink to the LinkingBaseTool.temporaryLink.

This method may be overridden, but we recommend that you call this base method. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

Parameters:
{Link} reallink
{Link} templink
doActivate()

Start the relinking operation.More...

Find the relink handle by calling Tool.findToolHandleAt looking for either the "RelinkFrom" adornment or the "RelinkTo" adornment, saving the result in handle.

This starts a transaction, captures the mouse, and sets the cursor.

The value of isForwards is set depending on the category of the relink handle found. The LinkingBaseTool.originalLink property and various "Original..." port and node properties are set too. The temporary nodes and temporary link are also initialized.

This method may be overridden, but we recommend that you call this base method.

doDeactivate()

Finishing the linking operation stops the transaction, releases the mouse, and resets the cursor.More...

This method may be overridden, but we recommend that you call this base method.

doMouseUp()

A mouse-up ends the relinking operation; if there is a valid targetPort nearby, this modifies the old link to connect with the target port.More...

A successful relinking calls reconnectLink to actually change the link. The "LinkRelinked" DiagramEvent is raised.

A failure to find a valid target port results in no changes and no DiagramEvent.

This method may be overridden, but we recommend that you call this base method. You might find it easier to override reconnectLink. It is actually most common to implement a "LinkRelinked" DiagramEvent listener on the Diagram.

updateAdornments(part)

Show an Adornment for each end of the Link that the user may reconnect.More... The Adornment may have a copy of fromHandleArchetype and/or toHandleArchetype.

This method may be overridden.

Parameters:
{Part} part
Methods borrowed from class LinkingBaseTool:
copyPortProperties, doMouseMove, findTargetPort, isInSameNode, isLinked, isValidCycle, isValidFrom, isValidLink, isValidTo, setNoTargetPortProperties
Methods borrowed from class Tool:
cancelWaitAfter, canStartMultiTouch, doCancel, doKeyDown, doKeyUp, doMouseDown, doMouseWheel, doStart, doStop, doWaitAfter, findToolHandleAt, isBeyondDragSize, standardMouseClick, standardMouseOver, standardMouseSelect, standardMouseWheel, standardPinchZoomMove, standardPinchZoomStart, standardWaitAfter, startTransaction, stopTool, stopTransaction