We have a case where, if a user has a node linked to another node, selects only the second node, and then does a copy/paste operation, we would like the link to also be duplicated, such as this:
Only the second node is selected:
After the copy/paste operation, the link is duplicated:
We have a custom command handler and I’ve been working with copyToClipboard and pasteFromClipboard in there. In copyToClipboard, I find the link that I want included in the copy/paste operation and add it to the set that’s passed into the function, then call super.copyToClipboard with the updated set. In pasteFromClipboard, I first call:
and the coll variable returned by that call contains the link I added in copyToClipboard. However, its fromNode has been set to null. Without a valid from node, the link isn’t created in the diagram and we also can’t build the client side model we use to track node connections. Any ideas on why the fromNode is being nulled out, and is there a better way to approach the problem I’m trying to solve?
If you are using TreeModel, and Beta is a tree child of Alpha, then if you set CommandHandler.copiesParentKey to true, I think you’ll get the behavior that you are asking for in this case.
But if you are using GraphLinksModel, then in your override of CommandHandler.copyToClipboard you’ll need to include enough information in order to be able to add a new Link in CommandHandler.pasteFromClipboard.
The reason that the link that was copied into the clipboard didn’t have a “from” Node is because that Node wasn’t included in the clipboard collection, so the link’s reference had to be removed when it was in the clipboard. And so the paste wouldn’t have that information either.