Multiple LinkingBaseTools in a diagram?


I’d like to have 2 different link behaviors in a single diagram - mostly the same except isUnconnectedLinkValid true on one and false on the other. I don’t have all the details sorted but think I’d probably have the default for the diagram be the =false version and have the =true version be dragged from a palette or maybe created via a context menu.

Is it possible to do this? I keep coming back to thinking I’ll need multiple extensions to do this but don’t understand how I would do that in a single diagram.

Any tips or pointers to examples would be much appreciated!

I think you need to decide at the time the user is starting to draw a new link or reconnect an existing link whether or not it’s OK not to connect the link with a port.

Perhaps you could have a single custom LinkingTool and a single custom RelinkingTool (the latter only if you allow the user to reconnect existing links) and override doActivate on each one to call the super method and then set LinkingBaseTool.isUnconnectedLinkValid to true or false depending on the situation, which might be dependent on which port the user is starting from or the particular link that the user is trying to relink.

1 Like

Ok, I think I understand and will give that a shot.

Thanks for the quick reply!