public final void drop(DropTargetDropEvent event) {
    IWorkspaceView view = WorkspaceController.getCurrentModeExtension().getView();
    if (view == null) {
      return;
    }

    TreePath targetPath = view.getPathForLocation(event.getLocation().x, event.getLocation().y);
    if (targetPath != null) {
      AWorkspaceTreeNode targetNode = (AWorkspaceTreeNode) targetPath.getLastPathComponent();
      if (processDrop(targetNode, event)) {
        return;
      }
    }
    event.rejectDrop();
  }
  public final void drop(DropTargetDropEvent dtde) {
    try {
      if (drawImage) {
        clearImage();
      }
      int action = dtde.getDropAction();

      Transferable transferable = dtde.getTransferable();
      Point pt = dtde.getLocation();
      if (transferable.isDataFlavorSupported(TransferableNode.NODE_FLAVOR)
          && canPerformAction(tree, draggedPath, action, pt)) {
        TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
        TreePath node = (TreePath) transferable.getTransferData(TransferableNode.NODE_FLAVOR);
        if (executeDrop(tree, node, pathTarget, action)) {
          dtde.acceptDrop(action);
          dtde.dropComplete(true);
          return;
        }
      }
      dtde.rejectDrop();
      dtde.dropComplete(false);
    } catch (Exception e) {
      System.out.println(e);
      dtde.rejectDrop();
      dtde.dropComplete(false);
    }
  }
 public Object execute() throws NotImplementedException {
   try {
     scopeViewModel.addItem(scopeObject, eventArgs.getLocation());
   } catch (Exception e) {
     ExceptionLogger.Log(e);
   }
   return null;
 }
예제 #4
0
  private AbstractDefineComponent getSelectedNode(DropTargetDropEvent arg) {

    Point p = arg.getLocation();
    TreePath path = tree.getPathForLocation(p.x, p.y);
    AbstractDefineComponent selectedNode = (AbstractDefineComponent) path.getLastPathComponent();

    return selectedNode;
  }
  public void drop(DropTargetDropEvent dtde) {
    Point pt = dtde.getLocation();
    DropTargetContext dtc = dtde.getDropTargetContext();
    JTree tree = (JTree) dtc.getComponent();
    TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode) parentpath.getLastPathComponent();

    try {
      // Transferable tr = dtde.getTransferable(); // !!! this should work, but doesn't. after one
      // click on the draggable node, this call here will not return the TransferableTreeNode that
      // is created in dragGestureRecognized()
      Transferable tr =
          ObjectInspector
              .transferNode; // therefore, we use this hack, which just stores the current
      // transferable in a static variable

      DataFlavor[] flavors = tr.getTransferDataFlavors();
      for (int i = 0; i < flavors.length; i++) {
        if (tr.isDataFlavorSupported(flavors[i])) {
          dtde.acceptDrop(dtde.getDropAction());
          TreePath p = (TreePath) tr.getTransferData(flavors[i]);
          DefaultMutableTreeNode node = (DefaultMutableTreeNode) p.getLastPathComponent();
          DefaultTreeModel model = (DefaultTreeModel) tree.getModel();

          Object sourceObject = node.getUserObject();

          FieldWrapperObjectTree targetField = ((FieldWrapperObjectTree) parent.getUserObject());

          if (sourceObject != null) {
            if (sourceObject instanceof FieldWrapperObjectTree) {
              FieldWrapperObjectTree sourceField = (FieldWrapperObjectTree) sourceObject;

              if (sourceField.getTheField().getType().equals(targetField.getTheField().getType())) {
                targetField
                    .getTheField()
                    .set(
                        targetField.getOnObject(),
                        sourceField.getTheField().get(sourceField.getOnObject()));
              }
            } else if (sourceObject.getClass().equals(targetField.getTheField().getType())) {
              targetField.getTheField().set(targetField.getOnObject(), sourceObject);
            }

            tree.invalidate();
            tree.repaint();
          }

          dtde.dropComplete(true);
          return;
        }
      }
      dtde.rejectDrop();
    } catch (Exception e) {
      e.printStackTrace();
      // dtde.rejectDrop();
    }
  }
 protected Point getTableLocationForEvent(DropTargetDropEvent dropTargetDropEvent) {
   Point dropTargetPoint = dropTargetDropEvent.getLocation();
   int column = _underlyingTable.columnAtPoint(dropTargetPoint);
   int row = _underlyingTable.rowAtPoint(dropTargetPoint);
   if ((row < 0) || (column < 0)) {
     return null;
   }
   return new Point(row, column);
 }
 public Object execute() throws NotImplementedException {
   try {
     scopeViewModel.addVariable(
         ILanguageVariableFactory.getCopy(scopeObject), eventArgs.getLocation());
   } catch (Exception e) {
     ExceptionLogger.Log(e);
   }
   return null;
 }
예제 #8
0
  @Override
  public void drop(DropTargetDropEvent dtde) {
    Point pt = dtde.getLocation();
    DropTargetContext dtc = dtde.getDropTargetContext();
    JTree tree = (JTree) dtc.getComponent();
    TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode) parentpath.getLastPathComponent();
    if (!parent.isLeaf()) {
      dtde.rejectDrop();
      return;
    }

    try {
      Transferable tr = dtde.getTransferable();
      DataFlavor[] flavors = tr.getTransferDataFlavors();
      for (int i = 0; i < flavors.length; i++) {
        if (tr.isDataFlavorSupported(flavors[i])) {
          dtde.acceptDrop(dtde.getDropAction());
          EMedium eMedium = (EMedium) tr.getTransferData(flavors[i]);
          TreeNodeUserData userData = (TreeNodeUserData) parent.getUserObject();
          String shelfName = userData.getCaption();
          if (isLibrarySelected(dtde)
              && shelfName.equals(AppProperties.INSTANCE.RENTALS_SHELF_NAME)) {
            if (!uiDelegate.addRentalEMedium(eMedium))
              JOptionPane.showMessageDialog(
                  frame, "Cannot rent e-medium!", "Add document error", JOptionPane.ERROR_MESSAGE);
          } else if (!isLibrarySelected(dtde)
              && !shelfName.equals(AppProperties.INSTANCE.RENTALS_SHELF_NAME)) {
            if (!uiDelegate.addEMediumShelf(shelfName, eMedium))
              JOptionPane.showMessageDialog(
                  frame, "Duplicated e-medium!", "Add document error", JOptionPane.ERROR_MESSAGE);
          } else
            JOptionPane.showMessageDialog(
                frame,
                "Need to rent the e-medium first!",
                "Add document error",
                JOptionPane.ERROR_MESSAGE);
          dtde.dropComplete(true);
          return;
        }
      }
      // dtde.rejectDrop();
    } catch (OperationNotSupportedException e) {
      JOptionPane.showMessageDialog(
          frame,
          "Cannot add a document to this shelf",
          "Add document error",
          JOptionPane.ERROR_MESSAGE);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #9
0
    public boolean isDropAcceptable(final DropTargetDropEvent e) {
      // Only accept COPY or MOVE gestures (ie LINK is not supported)
      if ((e.getDropAction() & DnDConstants.ACTION_MOVE) == 0) return false;

      // Only accept this particular flavor
      if (!e.isDataFlavorSupported(JDragTree.TREEPATH_FLAVOR)) return false;

      // Do this if you want to prohibit dropping onto the drag source...
      final Point pt = e.getLocation();
      final TreePath path = getClosestPathForLocation(pt.x, pt.y);
      if ((path == null) || path.equals(_pathSource)) return false;

      return true;
    }
예제 #10
0
 @Override
 public void drop(DropTargetDropEvent dtde) {
   Point dropPoint = dtde.getLocation();
   TreePath path = getPathForLocation(dropPoint.x, dropPoint.y);
   System.out.println("drop path is " + path);
   boolean dropped = false;
   try {
     dtde.acceptDrop(DnDConstants.ACTION_MOVE);
     // Object dropObject = dtde.getTransferable().getTransferData(dataFlavor);
     // if (dropObject instanceof DefaultMutableTreeNode) {
     if (draggedNode instanceof DefaultMutableTreeNode) {
       DefaultMutableTreeNode dropNode = (DefaultMutableTreeNode) draggedNode;
       if (dropNode.getAllowsChildren()) {
         DefaultMutableTreeNode destinyNode =
             (DefaultMutableTreeNode) path.getLastPathComponent();
         if (!dropNode.isNodeDescendant(destinyNode) && !destinyNode.isNodeChild(dropNode)) {
           if (moveDirectory(dropNode, destinyNode)) {
             ((DefaultTreeModel) getModel()).removeNodeFromParent(dropNode);
             ((DefaultTreeModel) getModel())
                 .insertNodeInto(dropNode, destinyNode, destinyNode.getChildCount());
             dropped = true;
           }
         }
       } else {
         DefaultMutableTreeNode destinyNode =
             (DefaultMutableTreeNode) path.getLastPathComponent();
         DefaultMutableTreeNode selectedNode =
             (DefaultMutableTreeNode) this.getLastSelectedPathComponent();
         if (!selectedNode.getUserObject().equals(destinyNode.getUserObject())) {
           if (moveDocument(dropNode, destinyNode)) {
             setSelectionPath(path);
             dropped = true;
             dragDropEnd();
           }
         }
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   dtde.dropComplete(dropped);
 }
예제 #11
0
파일: DnDList.java 프로젝트: bvandepo/shdl
  public void drop(
      java.awt.dnd.DropTargetDropEvent evt) { // System.out.println( "DropTargetListener.drop" );
    java.awt.datatransfer.Transferable transferable = evt.getTransferable();

    // If it's our native TransferableObject, use that
    if (transferable.isDataFlavorSupported(TransferableObject.DATA_FLAVOR)) {
      evt.acceptDrop(java.awt.dnd.DnDConstants.ACTION_MOVE);
      Object obj = null;
      try {
        obj = transferable.getTransferData(TransferableObject.DATA_FLAVOR);
      } // end try
      catch (java.awt.datatransfer.UnsupportedFlavorException e) {
        e.printStackTrace();
      } // end catch
      catch (java.io.IOException e) {
        e.printStackTrace();
      } // end catch

      if (obj != null) {
        // See where in the list we dropped the element.
        int dropIndex = locationToIndex(evt.getLocation());
        javax.swing.DefaultListModel model = (javax.swing.DefaultListModel) getModel();

        if (dropIndex < 0) model.addElement(obj);

        // Else is it moving down the list?
        else if (sourceIndex >= 0 && dropIndex > sourceIndex) model.add(dropIndex - 1, obj);
        else model.add(dropIndex, obj);

      } // end if: we got the object

      // Else there was a problem getting the object
      else {
        evt.rejectDrop();
      } // end else: can't get the object
    } // end if: it's a native TransferableObject

    // Else we can't handle this
    else evt.rejectDrop();
  } // end drop
예제 #12
0
    /*
     * (non-Javadoc)
     *
     * @see java.awt.dnd.DropTargetListener#drop(java.awt.dnd.DropTargetDropEvent)
     */
    public void drop(DropTargetDropEvent e) {
      if (dragSource != null) {
        e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
        Point p = e.getLocation();
        int targetRow = rowAtPoint(p);

        Object edge =
            graph.insertEdge(
                null,
                null,
                null,
                dragSource.cell,
                JTableRenderer.this.cell,
                "sourceRow=" + sourceRow + ";targetRow=" + targetRow);
        graph.setSelectionCell(edge);

        // System.out.println("clearing drag source");
        dragSource = null;
        e.dropComplete(true);
      } else {
        e.rejectDrop();
      }
    }
  private void onTablesDroped(DropTargetDropEvent dtde) {
    try {
      Object transferData =
          dtde.getTransferable()
              .getTransferData(dtde.getTransferable().getTransferDataFlavors()[0]);

      if (transferData instanceof ObjectTreeDndTransfer) {
        ObjectTreeDndTransfer objectTreeDndTransfer = (ObjectTreeDndTransfer) transferData;

        if (false
            == objectTreeDndTransfer.getSessionIdentifier().equals(_session.getIdentifier())) {
          JOptionPane.showMessageDialog(
              SwingUtilities.windowForComponent(_desktopPane),
              s_stringMgr.getString("GraphDesktopController.tableDropedFormOtherSession"));
          return;
        }

        _listener.tablesDropped(objectTreeDndTransfer.getSelectedTables(), dtde.getLocation());
      }

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
예제 #14
0
    public void drop(final DropTargetDropEvent e) {
      _timerHover.stop(); // Prevent hover timer from doing an unwanted expandPath or collapsePath

      if (!isDropAcceptable(e)) {
        e.rejectDrop();
        return;
      }

      e.acceptDrop(e.getDropAction());

      final Transferable transferable = e.getTransferable();

      final DataFlavor[] flavors = transferable.getTransferDataFlavors();

      for (int i = 0; i < flavors.length; i++) {
        final DataFlavor flavor = flavors[i];
        if (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) {
          try {
            final Point pt = e.getLocation();
            final TreePath pathTarget = getClosestPathForLocation(pt.x, pt.y);
            final TreePath pathSource = (TreePath) transferable.getTransferData(flavor);

            if ((pathTarget == null) || (pathSource == null)) {
              e.dropComplete(false);
              return;
            }

            final MutableTreeNode sourceNode = (MutableTreeNode) pathSource.getLastPathComponent();
            final MutableTreeNode oldParent = (MutableTreeNode) sourceNode.getParent();

            final MutableTreeNode targetNode = (MutableTreeNode) pathTarget.getLastPathComponent();
            final MutableTreeNode newParent = (MutableTreeNode) targetNode.getParent();

            if (!sourceNode.isLeaf() && (targetNode.getParent() == sourceNode)) {
              // trying to drag a folder into its own childs
              e.dropComplete(false);
              return;
            }

            final DefaultTreeModel model = (DefaultTreeModel) getModel();
            final TreePath pathNewChild = null;

            if (targetNode.isLeaf() || JDragTree.this.isCollapsed(pathTarget)) {
              // collapsed tree node or leaf
              // dropped on a leaf, insert into leaf's parent AFTER leaf
              int idx = newParent.getIndex(targetNode);
              if (idx < 0) {
                JDragTree.logger.warning("child not found in parent!!!");
                e.dropComplete(false);
                return;
              } else {
                idx++; // insert AFTER targetNode

                // remove node from oldParent ...
                final Object[] removedChilds = {sourceNode};
                final int[] childIndices = {oldParent.getIndex(sourceNode)};
                sourceNode.removeFromParent();
                model.nodesWereRemoved(oldParent, childIndices, removedChilds);

                // ... and insert into newParent
                if (idx >= newParent.getChildCount()) {
                  // newParent.add( sourceNode );
                  newParent.insert(sourceNode, newParent.getChildCount());
                  final int insertedIndex[] = {newParent.getChildCount() - 1};
                  model.nodesWereInserted(newParent, insertedIndex);
                } else {
                  newParent.insert(sourceNode, idx);
                  final int insertedIndex[] = {idx};
                  model.nodesWereInserted(newParent, insertedIndex);
                }
              }
            } else {
              // expanded node, insert UNDER the node (before first child)
              // remove node from oldParent ...
              final Object[] removedChilds = {sourceNode};
              final int[] childIndices = {oldParent.getIndex(sourceNode)};
              sourceNode.removeFromParent();
              model.nodesWereRemoved(oldParent, childIndices, removedChilds);
              // ... and add to newParent
              targetNode.insert(sourceNode, 0);
              final int insertedIndex[] = {0};
              model.nodesWereInserted(targetNode, insertedIndex);
            }

            if (pathNewChild != null)
              setSelectionPath(pathNewChild); // Mark this as the selected path in the tree
            break; // No need to check remaining flavors
          } catch (final UnsupportedFlavorException ufe) {
            JDragTree.logger.log(
                Level.SEVERE, "Exception thrown in drop(DropTargetDropEvent e)", ufe);
            e.dropComplete(false);
            return;
          } catch (final IOException ioe) {
            JDragTree.logger.log(
                Level.SEVERE, "Exception thrown in drop(DropTargetDropEvent e)", ioe);
            e.dropComplete(false);
            return;
          }
        }
      }
      e.dropComplete(true);
    }
예제 #15
0
    public void drop(DropTargetDropEvent dtde) {
      if (!isAcceptable(dtde.getTransferable(), dtde.getLocation())) {
        dtde.rejectDrop();
      } else {
        try {
          Transferable transferable = dtde.getTransferable();
          Object transferData =
              transferable.getTransferData(transferable.getTransferDataFlavors()[0]);
          if (transferData instanceof PropertyModelItem) {
            dtde.acceptDrop(dtde.getDropAction());
            PropertyModelItem modelItem = (PropertyModelItem) transferData;

            String xpath = modelItem.getXPath();
            if (xpath == null && XmlUtils.seemsToBeXml(modelItem.getProperty().getValue())) {
              xpath =
                  UISupport.selectXPath(
                      "Create PropertyExpansion",
                      "Select XPath below",
                      modelItem.getProperty().getValue(),
                      null);

              if (xpath != null) {
                xpath =
                    PropertyExpansionUtils.shortenXPathForPropertyExpansion(
                        xpath, modelItem.getProperty().getValue());
              }
            }

            PropertyExpansion propertyExpansion =
                new PropertyExpansionImpl(modelItem.getProperty(), xpath);

            Point point = dtde.getLocation();
            int column = getPropertiesTable().columnAtPoint(point);
            int row = getPropertiesTable().rowAtPoint(point);

            if (row == -1) {
              if (holder instanceof MutableTestPropertyHolder) {
                MutableTestPropertyHolder mtph = (MutableTestPropertyHolder) holder;
                String name =
                    UISupport.prompt(
                        "Specify unique name of property",
                        "Add Property",
                        modelItem.getProperty().getName());
                while (name != null && mtph.hasProperty(name)) {
                  name =
                      UISupport.prompt(
                          "Specify unique name of property",
                          "Add Property",
                          modelItem.getProperty().getName());
                }

                if (name != null) {
                  mtph.addProperty(name).setValue(propertyExpansion.toString());
                }
              }
            } else {
              getPropertiesTable().setValueAt(propertyExpansion.toString(), row, column);
            }

            dtde.dropComplete(true);
          }
        } catch (Exception e) {
          SoapUI.logError(e);
        }
      }
    }
  /**
   * The drag operation has terminated with a drop on this DropTarget. Be nice to somehow
   * incorporate FigureTransferCommand here.
   */
  public void drop(java.awt.dnd.DropTargetDropEvent dtde) {
    System.out.println("DropTargetDropEvent-drop");

    if (dtde.isDataFlavorSupported(DNDFiguresTransferable.DNDFiguresFlavor) == true) {
      log("DNDFiguresFlavor");
      if ((dtde.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0) {
        log("copy or move");
        if (dtde.isLocalTransfer() == false) {
          System.err.println("Intra-JVM Transfers not implemented for figures yet.");
          dtde.rejectDrop();
          return;
        }
        dtde.acceptDrop(dtde.getDropAction());
        try {
            /* protection from a malicious dropped object */
          setTargetUndoActivity(createTargetUndoActivity(view()));
          DNDFigures ff =
              (DNDFigures)
                  DNDHelper.processReceivedData(
                      DNDFiguresTransferable.DNDFiguresFlavor, dtde.getTransferable());
          getTargetUndoActivity().setAffectedFigures(ff.getFigures());
          Point theO = ff.getOrigin();
          view().clearSelection();
          Point newP = dtde.getLocation();
          /**
           * origin is where the figure thinks it is now newP is where the mouse is now. we move the
           * figure to where the mouse is with this equation
           */
          int dx = newP.x - theO.x; /* distance the mouse has moved */
          int dy = newP.y - theO.y; /* distance the mouse has moved */
          log("mouse at " + newP);
          FigureEnumeration fe =
              view().insertFigures(getTargetUndoActivity().getAffectedFigures(), dx, dy, false);
          getTargetUndoActivity().setAffectedFigures(fe);

          if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) {
            view().addToSelectionAll(getTargetUndoActivity().getAffectedFigures());
          }

          view().checkDamage();
          editor().getUndoManager().pushUndo(getTargetUndoActivity());
          editor().getUndoManager().clearRedos();
          // update menus
          editor().figureSelectionChanged(view());
          dtde.dropComplete(true);
        } catch (NullPointerException npe) {
          npe.printStackTrace();
          dtde.dropComplete(false);
        }
      } else {
        dtde.rejectDrop();
      }
    } else if (dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
      log("String flavor dropped.");
      dtde.acceptDrop(dtde.getDropAction());
      Object o = DNDHelper.processReceivedData(DataFlavor.stringFlavor, dtde.getTransferable());
      if (o != null) {
        log("Received string flavored data.");
        dtde.getDropTargetContext().dropComplete(true);
      } else {
        dtde.getDropTargetContext().dropComplete(false);
      }
    } else if (dtde.isDataFlavorSupported(DNDHelper.ASCIIFlavor) == true) {
      log("ASCII Flavor dropped.");
      dtde.acceptDrop(DnDConstants.ACTION_COPY);
      Object o = DNDHelper.processReceivedData(DNDHelper.ASCIIFlavor, dtde.getTransferable());
      if (o != null) {
        log("Received ASCII Flavored data.");
        dtde.getDropTargetContext().dropComplete(true);
        // System.out.println(o);
      } else {
        dtde.getDropTargetContext().dropComplete(false);
      }
    } else if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
      log("Java File List Flavor dropped.");
      dtde.acceptDrop(DnDConstants.ACTION_COPY);
      File[] fList =
          (File[])
              DNDHelper.processReceivedData(DataFlavor.javaFileListFlavor, dtde.getTransferable());
      if (fList != null) {
        log("Got list of files.");
        for (int x = 0; x < fList.length; x++) {
          System.out.println(fList[x].getAbsolutePath());
        }
        dtde.getDropTargetContext().dropComplete(true);
      } else {
        dtde.getDropTargetContext().dropComplete(false);
      }
    }
    fLastX = 0;
    fLastY = 0;
  }
예제 #17
0
  @Override
  public void drop(DropTargetDropEvent dtde) {
    Point pt = dtde.getLocation();
    DropTargetContext dtc = dtde.getDropTargetContext();
    JTree tree = (JTree) dtc.getComponent();
    TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
    Object node = parentpath.getLastPathComponent();

    if (dtde.isDataFlavorSupported(TransferableUDO.UDO_CAT_FLAVOR)) {
      if (!(node instanceof UDOCategory)) {
        dtde.rejectDrop();
        return;
      }

      if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) {
        dtde.acceptDrop(dtde.getDropAction());

        Transferable tr = dtde.getTransferable();
        try {
          Object transferNode = tr.getTransferData(TransferableUDO.UDO_CAT_FLAVOR);

          UDOCategory udoCategory = (UDOCategory) transferNode;
          UDOCategory parentNode = (UDOCategory) node;

          UDOLibrary udoLibrary = (UDOLibrary) tree.getModel();

          udoLibrary.addCategory(parentNode, udoCategory);

          dtde.dropComplete(true);
        } catch (UnsupportedFlavorException | IOException e) {
          dtde.dropComplete(false);
        }
      } else {
        dtde.rejectDrop();
      }

    } else if (dtde.isDataFlavorSupported(TransferableUDO.UDO_FLAVOR)) {
      dtde.acceptDrop(dtde.getDropAction());

      try {
        Transferable tr = dtde.getTransferable();

        Object transferNode = tr.getTransferData(TransferableUDO.UDO_FLAVOR);

        UserDefinedOpcode udo = (UserDefinedOpcode) transferNode;
        UDOLibrary udoLibrary = (UDOLibrary) tree.getModel();

        // iLibrary.removeInstrument(instrument);
        if (node instanceof UDOCategory) {
          UDOCategory parentNode = (UDOCategory) node;

          udoLibrary.addUDO(parentNode, udo);
        } else if (node instanceof UserDefinedOpcode) {
          UDOCategory parentNode =
              (UDOCategory) parentpath.getPathComponent(parentpath.getPathCount() - 2);

          int index = ListUtil.indexOfByRef(parentNode.getUserDefinedOpcodes(), node);

          int closestRow = tree.getClosestRowForLocation(pt.x, pt.y);

          Rectangle bounds = tree.getRowBounds(closestRow);

          if (pt.y > bounds.y + bounds.height) {
            udoLibrary.addUDO(parentNode, udo);
          } else {
            udoLibrary.addUDO(parentNode, index, udo);
          }
        }

        dtde.dropComplete(true);
      } catch (UnsupportedFlavorException | IOException e) {
        dtde.dropComplete(false);
      }
    } else {
      dtde.rejectDrop();
    }
  }