/** User exits the dragging */ public void dragExit(DropTargetEvent dte) { dropIndex = -1; ExplorerDnDManager.getDefault().setMaybeExternalDragAndDrop( false ); stopDragging(); }
/** User exits the dragging */ public void dragExit(DropTargetEvent dte) { ExplorerDnDManager.getDefault().setMaybeExternalDragAndDrop( false ); dropIndex = -1; stopDragging(); }
private boolean canReorderWhenMoving(Node folder, Node[] dragNodes) { if ((ExplorerDnDManager.getDefault().getNodeAllowedActions() & DnDConstants.ACTION_MOVE) == 0) { return false; } return canReorder( folder, dragNodes ); }
/** Default constructor. */ public ListView() { initializeList (); // activation of drop target if (DragDropUtilities.dragAndDropEnabled) { ExplorerDnDManager.getDefault ().addFutureDropTarget (this); // note: drag target is activated on focus gained } // no border, window system manages outer border itself setBorder (BorderFactory.createEmptyBorder()); setViewportBorder (BorderFactory.createEmptyBorder()); }
/** Default constructor. */ public ListView() { initializeList (); // activation of drop target if (DragDropUtilities.dragAndDropEnabled) { ExplorerDnDManager.getDefault ().addFutureDropTarget (this); // note: drag target is activated on focus gained } // no border, window system manages outer border itself setBorder (BorderFactory.createEmptyBorder()); setViewportBorder (BorderFactory.createEmptyBorder()); }
if (ExplorerDnDManager.getDefault ().getNodeAllowedActions () == DnDConstants.ACTION_NONE) { return false; Node[] nodes = ExplorerDnDManager.getDefault ().getDraggedNodes(); for (int i=0; i<nodes.length; i++) { if (n.equals(nodes[i].getParentNode ())) Transferable trans = ExplorerDnDManager.getDefault ().getDraggedTransferable ((DnDConstants.ACTION_MOVE & dropAction) != 0); if (trans==null) { return false;
/** User exits the dragging */ public void dragExit(DropTargetEvent dte) { ExplorerDnDManager.getDefault().setMaybeExternalDragAndDrop( false ); if (lastIndex >= 0) { NodeRenderer.dragExit(); list.repaint(list.getCellBounds(lastIndex, lastIndex)); } }
public void valueChanged(TreeSelectionEvent ev) { TreePath[] paths = tree.getSelectionPaths (); storeSelectedPaths = Arrays.asList (paths == null ? new TreePath[0] : paths); if (paths == null) { // part of bugfix #37279, if DnD is active then is useless select a nearby node if (ExplorerDnDManager.getDefault().isDnDActive()) { return ; } callSelectionChanged (new Node[0]); } else { // we need to force no changes to nodes hierarchy => // we are requesting read request, but it is not necessary // to execute the next action immediatelly, so postReadRequest // should be enough readAccessPaths = paths; Children.MUTEX.postReadRequest(this); } }
public void valueChanged(TreeSelectionEvent ev) { TreePath[] paths = tree.getSelectionPaths (); storeSelectedPaths = Arrays.asList (paths == null ? new TreePath[0] : paths); if (paths == null) { // part of bugfix #37279, if DnD is active then is useless select a nearby node if (ExplorerDnDManager.getDefault().isDnDActive()) { return ; } callSelectionChanged (new Node[0]); } else { // we need to force no changes to nodes hierarchy => // we are requesting read request, but it is not necessary // to execute the next action immediatelly, so postReadRequest // should be enough readAccessPaths = paths; Children.MUTEX.postReadRequest(this); } }
/** 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)); } }
@Override public void valueChanged(TreeSelectionEvent ev) { TreePath[] paths = tree.getSelectionPaths(); if (paths == null) { // part of bugfix #37279, if DnD is active then is useless select a nearby node if (ExplorerDnDManager.getDefault().isDnDActive()) { return; } callSelectionChanged(new Node[0]); } else { // we need to force no changes to nodes hierarchy => // we are requesting read request, but it is not necessary // to execute the next action immediatelly, so postReadRequest // should be enough readAccessPaths = paths; Children.MUTEX.postReadRequest(this); } }
public void dropActionChanged(DropTargetDragEvent dtde) { // check if the nodes are willing to do selected action Node[] nodes = ExplorerDnDManager.getDefault().getDraggedNodes(); if( null != nodes ) { int dropAction = ExplorerDnDManager.getDefault().getAdjustedDropAction( dtde.getDropAction(), view.getAllowedDropActions() ); 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; }
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 ; }
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 ; }
public void dropActionChanged(DropTargetDragEvent dtde) { // check if the nodes are willing to do selected action Node[] nodes = ExplorerDnDManager.getDefault().getDraggedNodes(); if( null == nodes ) return; int dropAction = ExplorerDnDManager.getDefault().getAdjustedDropAction( dtde.getDropAction(), view.getAllowedDropActions(dtde.getTransferable()) ); for (int i = 0; i < nodes.length; i++) { if ( ((view.getAllowedDropActions(dtde.getTransferable()) & dropAction) == 0) || !DragDropUtilities.checkNodeForAction(nodes[i], dropAction) ) { // this action is not supported dtde.rejectDrag(); return; } } return; }
private boolean canReorder (Node folder, Node[] dragNodes) { if ((ExplorerDnDManager.getDefault ().getNodeAllowedActions () & DnDConstants.ACTION_MOVE) == 0) { return false; } if (folder==null||dragNodes.length==0) { return false; } // has folder a index cookie? Index ic = (Index)folder.getCookie (Index.class); if (ic==null) { return false; } // folder has index cookie // check if all dragNodes are from same folder for (int i=0; i<dragNodes.length; i++) { // bugfix #23988, check if dragNodes[i] isn't null if (dragNodes[i]==null) { return false; } if (dragNodes[i].getParentNode ()==null) return false; if (!dragNodes[i].getParentNode ().equals (folder)) return false; } return true; }
/** 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; } } }
/** User is starting to drag over us */ public void dragEnter(DropTargetDragEvent dtde) { int dropAction = ExplorerDnDManager.getDefault().getAdjustedDropAction( dtde.getDropAction(), view.getAllowedDropActions() ); //TODO dnd // ExplorerDnDManager.getDefault().prepareCursor( // DragDropUtilities.chooseCursor( // dtde.getDropTargetContext().getComponent(), dropAction, (dropAction & view.getAllowedDropActions()) != 0 // ) // ); lastIndex = indexWithCheck(dtde); if (lastIndex < 0) { dtde.rejectDrag(); } else { dtde.acceptDrag(dropAction); // TODO // NodeRenderer.dragEnter(list.getModel().getElementAt(lastIndex)); // list.repaint(list.getCellBounds(lastIndex, lastIndex)); } }
public void treeNodesRemoved (TreeModelEvent e) { // called to removed from JTree.expandedState super.treeNodesRemoved (e); // part of bugfix #37279, if DnD is active then is useless select a nearby node if (ExplorerDnDManager.getDefault ().isDnDActive ()) { return ; } if (storeSelectedPaths == null || storeSelectedPaths.size () == tree.getSelectionCount ()) { // selection not changed => it's redundant to change selection return ; } if (tree.getSelectionCount () == 0) { TreePath path = findSiblingTreePath (e.getTreePath (), e.getChildIndices ()); // bugfix #39564, don't select again the same object if (path == null || path.equals (e.getTreePath ())) { return ; } else if (path.getPathCount () > 0) { tree.setSelectionPath (path); } } } }
@Override public void treeNodesRemoved(TreeModelEvent e) { // called to removed from JTree.expandedState super.treeNodesRemoved(e); boolean wasSelected = removedNodeWasSelected; removedNodeWasSelected = false; // part of bugfix #37279, if DnD is active then is useless select a nearby node if (ExplorerDnDManager.getDefault().isDnDActive()) { return; } if (wasSelected && tree.getSelectionCount() == 0) { TreePath path = findSiblingTreePath(e.getTreePath(), e.getChildIndices()); // bugfix #39564, don't select again the same object if ((path == null) || e.getChildIndices().length == 0) { return; } else if (path.getPathCount() > 0) { tree.setSelectionPath(path); } } } }