/** Implementation of the runnable interface. * Notifies user in AWT thread. */ public void run() { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(this); return; } DragDropUtilities.dropNotSuccesfull(); }
/** Returns transferable of given node * @return The transferable. */ static Transferable getNodeTransferable (Node node, int dragAction) throws IOException { return getNodeTransferable(new Node[] { node }, dragAction); }
public void actionPerformed(ActionEvent e) { JMenuItem source = (JMenuItem) e.getSource(); final Iterator it = pasteTypes.iterator(); for (int i = 0; it.hasNext(); i++) { PasteType action = (PasteType) it.next(); if (items_[i].equals(source)) { DragDropUtilities.performPaste(action, null); invokePostDropRun(); break; } } } };
ptCut = DragDropUtilities.getPasteTypes( dropNode, ExplorerDnDManager.getDefault().getDraggedTransferable(true) ); ptCopy = DragDropUtilities.getPasteTypes( dropNode, ExplorerDnDManager.getDefault().getDraggedTransferable(false) ); DragDropUtilities.createDropFinishPopup(setPasteTypes).show( tree, Math.max(dtde.getLocation().x - 5, 0), Math.max(dtde.getLocation().y - 5, 0) ); final int tmpLower = lowerNodeIdx; final Node[] tempDragNodes = dragNodes; DragDropUtilities.setPostDropRun( new Runnable() { public void run() { t = dtde.getTransferable(); PasteType pt = DragDropUtilities.getDropType( dropNode, t, dropAction, dropIndex ); final Node parentNode = dropNode; Node[] diffNodes = DragDropUtilities.performPaste(pt, dropNode);
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { // prepare wait cursor and optionally show it TreePath path = event.getPath (); prepareWaitCursor (DragDropUtilities.secureFindNode (path.getLastPathComponent ())); }
DragDropUtilities.getDropType ((Node)obj, ExplorerDnDManager.getDefault ().getDraggedTransferable ((DnDConstants.ACTION_MOVE & dropAction) != 0), dropAction); if (pt == null) { DragDropUtilities.performPaste (pt, null);
PasteType pt = DragDropUtilities.getDropType (n, trans, dropAction);
DragDropUtilities.getNodeTransferable(nodes, DnDConstants.ACTION_MOVE); exDnD.setDraggedTransferable (transferable, true); DragDropUtilities.getNodeTransferable(nodes, DnDConstants.ACTION_COPY); exDnD.setDraggedTransferable (transferable, false); } else if ((possibleNodeAction & DnDConstants.ACTION_COPY) != 0) { DragDropUtilities.getNodeTransferable(nodes, DnDConstants.ACTION_COPY); exDnD.setDraggedTransferable (transferable, false); } else { exDnD.setDnDActive (true); dge.startDrag( DragDropUtilities.chooseCursor (dragAction, dragStatus), Utilities.loadImage( "org/openide/resources/cursorscopysingle.gif"), // NOI18N
public void dropActionChanged (DropTargetDragEvent dtde) { // check if the nodes are willing to do selected action Node[] nodes = ExplorerDnDManager.getDefault ().getDraggedNodes (); int dropAction = dtde.getDropAction (); for (int i = 0; i < nodes.length; i++) { if (((view.getAllowedDropActions () & dropAction) == 0) || !DragDropUtilities.checkNodeForAction (nodes[i], dropAction)) { // this action is not supported dtde.rejectDrag (); return ; } } return ; }
/** Gets right transferable of given nodes (according to given * drag action) and also converts the transferable.<br> * Can be called only with correct action constant. * @return The transferable. */ static Transferable getNodeTransferable(Node[] nodes, int dragAction) throws IOException { Transferable[] tArray = new Transferable[nodes.length]; for (int i = 0; i < nodes.length; i++) { if ((dragAction & DnDConstants.ACTION_MOVE) != 0) { tArray[i] = nodes[i].clipboardCut(); } else { tArray[i] = nodes[i].drag (); } } Transferable result; if (tArray.length == 1) { // only one node, so return regular single transferable result = tArray[0]; } else { // enclose the transferables into multi transferable result = ExternalDragAndDrop.maybeAddExternalFileDnd( new Multi(tArray) ); } Clipboard c = getClipboard(); if (c instanceof ExClipboard) { return ((ExClipboard) c).convert(result); } else { return result; } }
ptCut = DragDropUtilities.getPasteTypes (dropNode, ExplorerDnDManager.getDefault ().getDraggedTransferable (true)); ptCopy = DragDropUtilities.getPasteTypes (dropNode, ExplorerDnDManager.getDefault ().getDraggedTransferable (false)); DragDropUtilities.createDropFinishPopup (setPasteTypes).show(tree,Math.max(dtde.getLocation ().x-5,0),Math.max(dtde.getLocation ().y-5,0)); final int tmpLower = lowerNodeIdx; final Node[] tempDragNodes = dragNodes; DragDropUtilities.setPostDropRun (new Runnable () { public void run () { performReorder (tempDropNode, PasteType pt = DragDropUtilities.getDropType (dropNode, ExplorerDnDManager.getDefault ().getDraggedTransferable ((DnDConstants.ACTION_MOVE & dropAction) != 0), dropAction); Node[] diffNodes = DragDropUtilities.performPaste (pt, dropNode); ExplorerDnDManager.getDefault().setDraggedNodes(diffNodes);
/** Get a node on given point or null if there none*/ private Node getNodeForDrop (Point p) { if (p!=null) { TreePath tp = tree.getPathForLocation (p.x, p.y); if (tp!=null) { return DragDropUtilities.secureFindNode (tp.getLastPathComponent ()); } } return null; }
DragDropUtilities.getDropType ((Node)obj, ExplorerDnDManager.getDefault ().getDraggedTransferable ((DnDConstants.ACTION_MOVE & dropAction) != 0), dropAction); if (pt == null) { DragDropUtilities.performPaste (pt, null);
PasteType pt = DragDropUtilities.getDropType (n, trans, dropAction);
DragDropUtilities.getNodeTransferable(nodes, DnDConstants.ACTION_MOVE); exDnD.setDraggedTransferable (transferable, true); DragDropUtilities.getNodeTransferable(nodes, DnDConstants.ACTION_COPY); exDnD.setDraggedTransferable (transferable, false); } else if ((possibleNodeAction & DnDConstants.ACTION_COPY) != 0) { DragDropUtilities.getNodeTransferable(nodes, DnDConstants.ACTION_COPY); exDnD.setDraggedTransferable (transferable, false); } else { exDnD.setDnDActive (true); dge.startDrag( DragDropUtilities.chooseCursor (dragAction, dragStatus), Utilities.loadImage( "org/openide/resources/cursorscopysingle.gif"), // NOI18N
public void dropActionChanged (DropTargetDragEvent dtde) { // check if the nodes are willing to do selected action Node[] nodes = ExplorerDnDManager.getDefault ().getDraggedNodes (); int dropAction = dtde.getDropAction (); for (int i = 0; i < nodes.length; i++) { if (((view.getAllowedDropActions () & dropAction) == 0) || !DragDropUtilities.checkNodeForAction (nodes[i], dropAction)) { // this action is not supported dtde.rejectDrag (); return ; } } return ; }
Clipboard c = getClipboard(); if (c instanceof ExClipboard) { ExClipboard cb = (ExClipboard)c;
ptCut = DragDropUtilities.getPasteTypes (dropNode, ExplorerDnDManager.getDefault ().getDraggedTransferable (true)); ptCopy = DragDropUtilities.getPasteTypes (dropNode, ExplorerDnDManager.getDefault ().getDraggedTransferable (false)); DragDropUtilities.createDropFinishPopup (setPasteTypes).show(tree,Math.max(dtde.getLocation ().x-5,0),Math.max(dtde.getLocation ().y-5,0)); final int tmpLower = lowerNodeIdx; final Node[] tempDragNodes = dragNodes; DragDropUtilities.setPostDropRun (new Runnable () { public void run () { performReorder (tempDropNode, PasteType pt = DragDropUtilities.getDropType (dropNode, ExplorerDnDManager.getDefault ().getDraggedTransferable ((DnDConstants.ACTION_MOVE & dropAction) != 0), dropAction); Node[] diffNodes = DragDropUtilities.performPaste (pt, dropNode); ExplorerDnDManager.getDefault().setDraggedNodes(diffNodes);
@Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { // prepare wait cursor and optionally show it TreePath path = event.getPath(); prepareWaitCursor(DragDropUtilities.secureFindNode(path.getLastPathComponent())); } }
if( null == t ) t = dtde.getTransferable(); PasteType pt = DragDropUtilities.getDropType( dropNode, t, dropAction, index ); DragDropUtilities.performPaste(pt, null);