Example #1
0
 protected void setUp() throws Exception {
   super.setUp();
   myTreeModel.insertNodeInto(myChildA, myRoot, 0);
   myTreeModel.insertNodeInto(myChildB, myRoot, 1);
   myTreeModel.insertNodeInto(myChild2, myChildA, 0);
   myTreeModel.insertNodeInto(new DefaultMutableTreeNode(), myChild2, 0);
   myTreeModel.insertNodeInto(new DefaultMutableTreeNode(), myChildB, 0);
   myChildAPath = TreeUtil.getPathFromRoot(myChildA);
   myChild2Path = TreeUtil.getPathFromRoot(myChild2);
   myChildBPath = TreeUtil.getPathFromRoot(myChildB);
 }
 @Override
 public boolean update(DnDEvent aEvent) {
   aEvent.setDropPossible(false);
   aEvent.hideHighlighter();
   final Object object = aEvent.getAttachedObject();
   if (object instanceof PackagingElementDraggingObject) {
     final DefaultMutableTreeNode parent =
         findParentCompositeElementNode(aEvent.getRelativePoint().getPoint(myTree));
     if (parent != null) {
       final PackagingElementDraggingObject draggingObject =
           (PackagingElementDraggingObject) object;
       final PackagingElementNode node = getNode(parent);
       if (node != null && draggingObject.canDropInto(node)) {
         final PackagingElement element = node.getFirstElement();
         if (element instanceof CompositePackagingElement) {
           draggingObject.setTargetNode(node);
           draggingObject.setTargetElement((CompositePackagingElement<?>) element);
           final Rectangle bounds = myTree.getPathBounds(TreeUtil.getPathFromRoot(parent));
           aEvent.setHighlighting(
               new RelativeRectangle(myTree, bounds),
               DnDEvent.DropTargetHighlightingType.RECTANGLE);
           aEvent.setDropPossible(true);
         }
       }
     }
   }
   return false;
 }
 protected void removeFacetNodes(@NotNull List<Facet> facets) {
   for (Facet facet : facets) {
     MyNode node = findNodeByObject(myRoot, facet);
     if (node != null) {
       removePaths(TreeUtil.getPathFromRoot(node));
     }
   }
 }