int getAllowedDropActions() { return view.getAllowedDropActions(); }
/** Safe accessor to the drop target which is asociated * with the tree */ DropTarget getDropTarget () { if (dropTarget == null) { dropTarget = new DropTarget(list, view.getAllowedDropActions(), this, false); } return dropTarget; } }
/** Safe accessor to the drop target which is asociated * with the tree */ DropTarget getDropTarget () { if (dropTarget == null) { dropTarget = new DropTarget(list, view.getAllowedDropActions(), this, false); } return dropTarget; } }
/** Safe accessor to the drop target which is asociated * with the tree */ DropTarget getDropTarget() { if (dropTarget == null) { dropTarget = new DropTarget(list, view.getAllowedDropActions(), this, false); } return dropTarget; } }
/** @return The tree path to the node the cursor is above now or * null if no such node currently exists or if conditions were not * satisfied to continue with DnD operation. */ int indexWithCheck (DropTargetDragEvent dtde) { int dropAction = dtde.getDropAction(); // check actions if ((dropAction & view.getAllowedDropActions()) == 0) return -1; // check location int index = list.locationToIndex(dtde.getLocation()); Object obj = list.getModel().getElementAt(index); if( obj instanceof VisualizerNode ) obj = ((VisualizerNode) obj).node; if ( index < 0 ) return -1; if( ! ( obj instanceof Node) ) return -1; /* JST: Is necessary? Cannot be replaced by the use of special * transferable? // accept only node data flavors or multi flavor if (!dtde.isDataFlavorSupported(NodeTransfer.nodeCutFlavor) && !dtde.isDataFlavorSupported(NodeTransfer.nodeCopyFlavor) && !dtde.isDataFlavorSupported(ExTransferable.multiFlavor)) return -1; */ // succeeded return index; }
dtde.getDropAction(), view.getAllowedDropActions() ); if ((dropAction & view.getAllowedDropActions()) == 0) { return -1;
/** @return The tree path to the node the cursor is above now or * null if no such node currently exists or if conditions were not * satisfied to continue with DnD operation. */ int indexWithCheck (DropTargetDragEvent dtde) { int dropAction = dtde.getDropAction(); // check actions if ((dropAction & view.getAllowedDropActions()) == 0) return -1; // check location int index = list.locationToIndex(dtde.getLocation()); Object obj = list.getModel().getElementAt(index); if( obj instanceof VisualizerNode ) obj = ((VisualizerNode) obj).node; if ( index < 0 ) return -1; if( ! ( obj instanceof Node) ) return -1; /* JST: Is necessary? Cannot be replaced by the use of special * transferable? // accept only node data flavors or multi flavor if (!dtde.isDataFlavorSupported(NodeTransfer.nodeCutFlavor) && !dtde.isDataFlavorSupported(NodeTransfer.nodeCopyFlavor) && !dtde.isDataFlavorSupported(ExTransferable.multiFlavor)) return -1; */ // succeeded return index; }
/** User is starting to drag over us */ public void dragEnter(DropTargetDragEvent dtde) { ExplorerDnDManager.getDefault().setMaybeExternalDragAndDrop( true ); int dropAction = ExplorerDnDManager.getDefault().getAdjustedDropAction( dtde.getDropAction(), view.getAllowedDropActions() ); lastIndex = indexWithCheck(dtde); if (lastIndex < 0) { dtde.rejectDrag(); } else { dtde.acceptDrag(dropAction); NodeRenderer.dragEnter(list.getModel().getElementAt(lastIndex)); list.repaint(list.getCellBounds(lastIndex, lastIndex)); } }
/** User drags over us */ public void dragOver(DropTargetDragEvent dtde) { ExplorerDnDManager.getDefault().setMaybeExternalDragAndDrop( true ); int dropAction = ExplorerDnDManager.getDefault().getAdjustedDropAction( dtde.getDropAction(), view.getAllowedDropActions() ); int index = indexWithCheck(dtde); if (index < 0) { dtde.rejectDrag(); if (lastIndex >= 0) { NodeRenderer.dragExit(); list.repaint(list.getCellBounds(lastIndex, lastIndex)); lastIndex = -1; } } else { dtde.acceptDrag(dropAction); if (lastIndex != index) { if (lastIndex < 0) { lastIndex = index; } NodeRenderer.dragExit(); NodeRenderer.dragEnter(list.getModel().getElementAt(index)); list.repaint(list.getCellBounds(lastIndex, index)); lastIndex = index; } } }
dtde.getDropAction(), view.getAllowedDropActions() );