Drag JGonode from palette to JGoSubgraph

<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />Hi There;

Just a simple inquiry.

Can we directly drag JGoNode from palette directly into JGoSubgrap on the view.

I make the following properties for my subgraph

JGoSubGraph subGraph = new JGoSubGraph();
subGraph.setDraggable(true);
subGraph.setSize(50,50);
subGraph.setPickableBackground( true);
subGraph.setResizable(true);
subGraph.setDragsNode(true);
subGraph.setGrabChildSelection(true);
myPalette.getDocument().getDefaultLayer().addObj ectAtHead(subGraph);

And when I dragged this subgraph on the view and try to drag a JGONode on it ,, It didn’t work .. So I really appreciate your help. How I can implement this. Is there is a direct way to do such action. Or should I go through some workarounds

Really appreciating your help
Thanks in advance

By default JGoView does not implement any particular semantics with a drop–any selected JGoObjects that are dropped are added as top-level objects to the JGoDocument.
You can override some methods in JGoView to implement this, depending on the semantics of what you want to allow the user to do.
You can override JGoView.doDrop to call the base method, decide whether the drop occurred inside one of your JGoSubGraphs, and then reparent the selection by calling JGoSubGraph.addCollection.
Alternatively you can override JGoView.drop, as some examples do, but you’ll additionally need to handle transactions. Look at the definitions of JGoView.drop and doDrop to see what you need to do.
You can also override JGoView.isDropFlavorAcceptable and computeAcceptableDrop to help control whether a drop can occur at a given point. Remember to convert the Point given by the DropTargetDropEvent from view coordinates to document coordinates by calling JGoView.viewToDocCoords.
But during the drag a flaw in the design of Java drag-and-drop doesn’t let you look at the objects being dropped, so you’ll need to implement some other method to find out what’s being dragged if you need to know about those objects to decide if a drop is OK.

Has anyone been able to get this working? If so can you share the code?

In a subclass of JGoView:
public boolean doDrop(DropTargetDropEvent e, JGoCopyEnvironment copyenv) {
Point viewCoord = e.getLocation();
Point docCoord = viewToDocCoords(viewCoord);
JGoSubGraph sg = pickSubGraph(docCoord);
boolean result = super.doDrop(e, copyenv);
if (result && sg != null) {
sg.addCollection(getSelection(), true, getDocument().getDefaultLayer());
}
return result;
}
public JGoSubGraph pickSubGraph(Point p) {
JGoObject obj = pickDocObject(p, true);
if (obj == null) return null;
if (obj instanceof JGoSubGraph) return (JGoSubGraph)obj;
if (obj.getParentNode() != null && obj.getParentNode().getParent() instanceof JGoSubGraph)
return (JGoSubGraph)obj.getParentNode().getParent();
return null;
}
Note that this code handles both the case where the JGoSubGraph.isPickableBackground() is true, as well as the case where the drop happens at some child or grandchild object of a subgraph. Of course you can customize this pickSubGraph method as you deem necessary for your application.