Hmmm, this isn’t trivial because at some point internally, a relinking operation is indistinguishable from a linking operation. However, a relinking operation takes place within a transaction and therefore is undoable, so one possibility is to detect the case where a relinking operation has resulted in the deletion of the link, and perform an undo operation.Relinking starts with the JGoView.startReLink method and ends with the JGoView.reLink method. if a link is deleted between these 2 methods, try performing the undo operation.
It’s easiest to override JGoView.noReLink to just call JGoView.doCancelMouse().
I have tried calling doCancelMouse() within noReLink() yesterday while waiting for a reply, it does indeed restore the link between the two original ports (as it is in fact the ‘cancel’ operation which is executed), but it recalculates the stroke and all the points on it. I want the link to be exactly the same - including all the original stroke points and positioning.
Currently my application does not support undo/redo. I tried the undo suggestion, but I was too lazy to override all the copyOldValueForUndo, copyNewValueForRedo and changeValue for all of my custom JGoObjects. Alternatively I override JGoView.startReLink() so that it stores the link’s strokepoints and then within JGoView.noReLink() I call doCancelMouse(), which ends the transaction and restores the link’s orginal ports after which I restore the link’s stroke points with the JGoStroke.setPoints(Vector) method. So far this is working nicely for me