Transferring JGoObjects to SubGraph


#1

Hi, I’m trying to take certain JGoObjects (the selected ones) from a document, and put them into in a JGoSubGraph which is also in the said document.
So I get the selection, and iterate through it, putting the JGoObjects into the SubGraph. This does not work though, it seems I have to remove them from the Parent / Layer / View first.
Removing them causes another problem though: when I remove a JGoObject, the links connected to it dissapear from the selection.
I can’t just copy everything either, because then the links aren’t actually connected to JGoPorts of the JGoObjects any more.
Does anyone know an easy solution for this, or am I navigating uncharted territory here? Thought I’d give the forum a shot, before I start saving everything as XML, removing, and reconstructing in the SubGraph.
Cheers,
Thomas


#2

Yes, in the next release we’ll add an addCollection method that will do what you want. This will work both to add graphs into a JGoArea as well as move them out of areas into JGoLayers as top-level objects. [I.e., we’re adding two such methods, one on JGoArea and one on JGoLayer.]
The way you can do this yourself is to override JGoPort.ownerChange to be a no-op when you do the reparenting into or out of a JGoSubGraph.