log.error("Exception", e);
log.error("Exception adding dropped element:", e); return DnDConstants.ACTION_NONE;
  public int addElement(Transferable t,                        DefaultMutableTreeNode target,                        DefaultMutableTreeNode before) {    DataFlavor[] flavors = t.getTransferDataFlavors();    int action = isDroppable(flavors, target);    if (action == DnDConstants.ACTION_NONE)      return DnDConstants.ACTION_NONE;    DataFlavor flavor = flavors[0];    try {      DefaultMutableTreeNode root =        (DefaultMutableTreeNode) model.getRoot();      if (target == root) {        for (int i = 0, n = root.getChildCount(); i < n; i++) {          DefaultMutableTreeNode node =            (DefaultMutableTreeNode) root.getChildAt(i);          Object o = node.getUserObject();          if (SOCIETIES.equals(o) && flavor == societyFlavor              || RECIPES.equals(o) && flavor == recipeFlavor) {            target = node;          } else {            return DnDConstants.ACTION_NONE;          }        }      }      // if we're adding a recipe that adds an agent that's      // in the experiment, then reject the recipe      Object userData = t.getTransferData(flavor);      if (userData instanceof RecipeComponent) {        if (!checkAdd((RecipeComponent)userData))          return DnDConstants.ACTION_NONE;      }      if (userData instanceof ModifiableComponent) {        ModifiableComponent mcc = (ModifiableComponent) userData;        if (!mcc.isEditable() && mcc.hasUnboundProperties())          return DnDConstants.ACTION_NONE;        // check for duplicates, if not dragging from same tree        String thisClassName = getClass().getName();        if (flavor instanceof CSMARTDataFlavor &&            !((CSMARTDataFlavor)flavor).getSourceClassName().equals(thisClassName)) {          String newName = mcc.getShortName();          int ix = target.getChildCount();          for (int i = 0; i < ix; i++) {            DefaultMutableTreeNode childNode =               (DefaultMutableTreeNode)target.getChildAt(i);            Object targetChildData = childNode.getUserObject();            if (targetChildData instanceof ModifiableComponent &&                ((ModifiableComponent)targetChildData).getShortName().equals(newName))               return DnDConstants.ACTION_NONE;          }        }      }      DefaultMutableTreeNode node =         new DefaultMutableTreeNode(userData, false);      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);    } catch (Exception e) {      if(log.isErrorEnabled()) {        log.error("Exception", e);      }      action = DnDConstants.ACTION_NONE;    }    return action;  }