Object userData = data; boolean allowsChildren = false;  if (data instanceof DefaultMutableTreeNode) { userData = ((DefaultMutableTreeNode)data).getUserObject(); if (userData instanceof String || userData instanceof Experiment) allowsChildren = true; }  DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(userData, allowsChildren); int ix = target.getChildCount(); if (before != null) { ix = model.getIndexOfChild(target, before); } if(log.isDebugEnabled()) { log.debug("Insert into " + target + " at " + ix + " before " + before); }  model.insertNodeInto(newNode, target, ix);  if (data instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode source = (DefaultMutableTreeNode)data; int n = source.getChildCount(); DefaultMutableTreeNode[] children = new DefaultMutableTreeNode[n]; for (int i = 0; i < n; i++) children[i] = (DefaultMutableTreeNode) source.getChildAt(i); for (int i = 0; i < n; i++) model.insertNodeInto(children[i], newNode, i); } selectNode(newNode); return action; }
    public int addElement(Transferable t,                          DefaultMutableTreeNode target,                          DefaultMutableTreeNode before) {        DataFlavor[] flavors = t.getTransferDataFlavors();        int action = isDroppable(flavors, target);        if (action != DnDConstants.ACTION_NONE) {            try {                Object userData = t.getTransferData(flavors[0]);                DefaultMutableTreeNode node =                    new DefaultMutableTreeNode(userData, userData instanceof String);                int ix = target.getChildCount();                if (before != null) {                    ix = model.getIndexOfChild(target, before);                }                if(log.isDebugEnabled()) {                  log.debug("Insert into " + target + " at " + ix + " before " + before);                }                model.insertNodeInto(node, target, ix);                selectNode(node);                return action;  // Always MOVE            } catch (Exception e) {              if(log.isErrorEnabled()) {                log.error("Caught an exception", e);              }            }        }        return DnDConstants.ACTION_NONE;    }