Post drag drop operations

Hi,

I have an application with Drag & Drop from a Palette to a JGoView area. The drag & drop uses the copyObject to implement the specifics of object creation in the JGoView and I am experiencing two issues … I have 4 object types in the palette stacked vertically

  1. The object seems to get offset from the mouse position - the further down the palette the drag & drop object is the more offset it gets
  2. I want to do some post drag & drop processing in the objects which will require that I get the JGoDocument that I have dragged & dropped into how do I do that?
Cheers ...

PS: Here’s the drag & Drop code

public JGoObject copyObject(JGoCopyEnvironment env) {
    
    FPMultiLineNode node = new FPMultiLineNode(get_elements(), get_location(), get_title(), get_bgColor(), get_info1(), get_info2(), get_info3(), get_scaleWidth());;
    
    if (this instanceof CausalFactorNode) {
        CausalFactorNode n = (CausalFactorNode)this;
        node = new CausalFactorNode(n.get_myLocale(), n.get_myElements(), n.get_myInfo1(), n.get_myInfo2(), n.is_doubleClickEnabled());
    } else if (this instanceof ConsequenceNode) {
        ConsequenceNode n = (ConsequenceNode)this;
        node = new ConsequenceNode(n.get_myLocale(), n.get_myElements(), n.get_myInfo1(), n.get_myInfo2(), n.is_doubleClickEnabled());
    } else if (this instanceof ControlNode) {
        ControlNode n = (ControlNode)this;
        node = new ControlNode(n.get_myLocale(), n.get_myElements(), n.get_myInfo1(), n.get_myInfo2(), n.is_doubleClickEnabled());
    } else if (this instanceof MitigationNode) {
        MitigationNode n = (MitigationNode)this;
        node = new MitigationNode(n.get_myLocale(), n.get_myElements(), n.get_myInfo1(), n.get_myInfo2(), n.is_doubleClickEnabled());
    }
    
    node.set_InteractiveServletURL(get_InteractiveServletURL());
    node.set_riskId(this.get_riskId());
    node.set_doubleClickEnabled(true);
    
    return node;
}
The copyObject method is going to be invoked any time a copy of a JGoObject is made. This may or may not be associated with drag-drop operation, so there isn't any available reference to the drop target JGoView or JGoDocument from within this method. You should override this copyObject when your derived class have fields that reference objects that need to be copied (the standard implementation of copyObject does a shallow copy).
To make additional changes to an object after a drag-drop operation, you might want to handle the documentChanged event (or override the documentChanged method) for your view and look for a hint value of JGoDocumentEvent.INSERTED. You can then get the JGoObject property of the event and take whatever action you need based on the type of object that was just added to the document. The JGoObject will have been added to the JGoDocument at this point, so the JGoObject getDocument method will give you a reference to the JGoDocument the object was just added to. Of course this event will occur whenever an object is added to the JGoDocument, not just when a drag-drop occurs, but that is likely to be what you want.
I'm not sure why you're seeing different offsets from the mouse position for the different objects you drag and drop from the palette. The drop operation is simply going to call setLocation on the newly dropped object. By default, this will set the location of the top-left corner of the object. Have you overriden setLocation for your node class?