Question on LinkRelinked event

Hi,

When the user dragged an existing link to connect to another node, event “LinkRelinked” was fired. My use case is to ask the user if he really wants to do it. If he chooses to cancel the operation, I need to restore the original link.


My question is how to restore the original link since the link has been modified? I can’t use Undo Manager, is there other way to do it?


Thanks.

As a general principal it is better to prevent users from doing “bad” things than it is to check afterwards. So I recommend implementing link validation.

But if you really want to do what you say, all of the relinking operation state is in the RelinkingTool: myDiagram.toolManager.relinkingTool.

I checked “originalToNode” in RelinkingTool, but it returned null. In “LinkRelinked” event dispatcher, DiagramEvent.parameter was the port that the link was originally connected to, not the original node. Is there a way to get node object from its port?

The GraphObject.part property.

What you say is odd, because I just tried it, and at the time of a “LinkRelinked” DiagramEvent, the value of RelinkingTool.originalToNode is in fact a Node, not null.

I found the problem. I displayed a confirmation dialog(our own UI component) before checking diagram.toolManager.relinkingTool.originalToNode. I believe it was set to null after the dialog was displayed.

Thanks.