Lines 69-75
Link Here
|
69 |
|
69 |
|
70 |
/** Glass pane for JTree which is associate with this class. */ |
70 |
/** Glass pane for JTree which is associate with this class. */ |
71 |
DropGlassPane dropPane; |
71 |
DropGlassPane dropPane; |
72 |
private Component oldGlassPane; |
|
|
73 |
|
72 |
|
74 |
final static protected int FUSSY_POINTING = 3; |
73 |
final static protected int FUSSY_POINTING = 3; |
75 |
final static private int DELAY_TIME_FOR_EXPAND = 1000; |
74 |
final static private int DELAY_TIME_FOR_EXPAND = 1000; |
Lines 105-120
Link Here
|
105 |
|
104 |
|
106 |
/** User is starting to drag over us */ |
105 |
/** User is starting to drag over us */ |
107 |
public void dragEnter (DropTargetDragEvent dtde) { |
106 |
public void dragEnter (DropTargetDragEvent dtde) { |
|
|
107 |
|
108 |
// remember current glass pane to set back at end of dragging over this compoment |
108 |
// remember current glass pane to set back at end of dragging over this compoment |
109 |
if (oldGlassPane==null) { |
109 |
if (!DropGlassPane.isOriginalPaneStored ()) { |
110 |
oldGlassPane = tree.getRootPane ().getGlassPane (); |
110 |
Component comp = tree.getRootPane ().getGlassPane (); |
|
|
111 |
DropGlassPane.setOriginalPane (tree, comp, comp.isVisible ()); |
112 |
|
113 |
// set glass pane for paint selection line |
114 |
dropPane = DropGlassPane.getDefault (tree); |
115 |
tree.getRootPane ().setGlassPane (dropPane); |
116 |
dropPane.setOpaque (false); |
117 |
dropPane.revalidate(); |
118 |
dropPane.setVisible (true); |
111 |
} |
119 |
} |
112 |
// set glass pane for paint selection line |
|
|
113 |
dropPane = DropGlassPane.getDefault (tree); |
114 |
tree.getRootPane ().setGlassPane (dropPane); |
115 |
dropPane.setOpaque (false); |
116 |
dropPane.setVisible (true); |
117 |
|
118 |
// set a status and cursor of dnd action |
120 |
// set a status and cursor of dnd action |
119 |
doDragOver (dtde); |
121 |
doDragOver (dtde); |
120 |
} |
122 |
} |
Lines 132-138
Link Here
|
132 |
TreePath tp = getTreePath(dtde); |
134 |
TreePath tp = getTreePath(dtde); |
133 |
if (tp == null) { |
135 |
if (tp == null) { |
134 |
dtde.rejectDrag(); |
136 |
dtde.rejectDrag(); |
135 |
stopDragging(); |
137 |
removeDropLine (); |
136 |
return ; |
138 |
return ; |
137 |
} |
139 |
} |
138 |
|
140 |
|
Lines 142-148
Link Here
|
142 |
// if I haven't any node for drop then reject drop |
144 |
// if I haven't any node for drop then reject drop |
143 |
if (dropNode==null) { |
145 |
if (dropNode==null) { |
144 |
dtde.rejectDrag (); |
146 |
dtde.rejectDrag (); |
145 |
stopDragging (); |
147 |
removeDropLine (); |
146 |
return ; |
148 |
return ; |
147 |
} |
149 |
} |
148 |
|
150 |
|
Lines 334-363
Link Here
|
334 |
|
336 |
|
335 |
/** User exits the dragging */ |
337 |
/** User exits the dragging */ |
336 |
public void dragExit (DropTargetEvent dte) { |
338 |
public void dragExit (DropTargetEvent dte) { |
337 |
// set back the remembered glass pane |
339 |
stopDragging (); |
338 |
if (oldGlassPane!=null) { |
|
|
339 |
// bugfix #23980, original glass pane is set back later |
340 |
final Component glassPaneForSetBack = oldGlassPane; |
341 |
SwingUtilities.invokeLater (new Runnable () { |
342 |
public void run () { |
343 |
tree.getRootPane ().setGlassPane (glassPaneForSetBack); |
344 |
} |
345 |
}); |
346 |
oldGlassPane = null; |
347 |
} |
348 |
DropGlassPane.getDefault (tree).setVisible (false); |
349 |
stopDragging(); |
350 |
} |
340 |
} |
351 |
|
341 |
|
352 |
private void stopDragging() { |
342 |
private void removeDropLine () { |
353 |
dropPane.setDropLine (null); |
343 |
dropPane.setDropLine (null); |
354 |
removeTimer (); |
|
|
355 |
if (lastNodeArea != null) { |
344 |
if (lastNodeArea != null) { |
356 |
NodeRenderer.dragExit(); |
345 |
NodeRenderer.dragExit(); |
357 |
repaint (lastNodeArea); |
346 |
repaint (lastNodeArea); |
358 |
lastNodeArea = null; |
347 |
lastNodeArea = null; |
359 |
} |
348 |
} |
360 |
} |
349 |
} |
|
|
350 |
|
351 |
private void stopDragging() { |
352 |
removeDropLine (); |
353 |
removeTimer (); |
354 |
// set back the remembered glass pane |
355 |
if (DropGlassPane.isOriginalPaneStored()) { |
356 |
DropGlassPane.putBackOriginal (); |
357 |
} |
358 |
} |
361 |
|
359 |
|
362 |
/** Get a node on given point or null if there none*/ |
360 |
/** Get a node on given point or null if there none*/ |
363 |
private Node getNodeForDrop (Point p) { |
361 |
private Node getNodeForDrop (Point p) { |
Lines 443-448
Link Here
|
443 |
// only for MOVE action |
441 |
// only for MOVE action |
444 |
if (DnDConstants.ACTION_MOVE==dropAction) { |
442 |
if (DnDConstants.ACTION_MOVE==dropAction) { |
445 |
Node[] nodes = ExplorerDnDManager.getDefault ().getDraggedNodes(); |
443 |
Node[] nodes = ExplorerDnDManager.getDefault ().getDraggedNodes(); |
|
|
444 |
if (nodes == null) |
445 |
return false; |
446 |
for (int i=0; i<nodes.length; i++) { |
446 |
for (int i=0; i<nodes.length; i++) { |
447 |
if (n.equals(nodes[i].getParentNode ())) |
447 |
if (n.equals(nodes[i].getParentNode ())) |
448 |
return false; |
448 |
return false; |
Lines 464-470
Link Here
|
464 |
* right node and target node agrees. |
464 |
* right node and target node agrees. |
465 |
*/ |
465 |
*/ |
466 |
public void drop (DropTargetDropEvent dtde) { |
466 |
public void drop (DropTargetDropEvent dtde) { |
467 |
stopDragging(); |
467 |
stopDragging (); |
468 |
|
468 |
|
469 |
// find node for the drop perform |
469 |
// find node for the drop perform |
470 |
Node dropNode = getNodeForDrop (dtde.getLocation ()); |
470 |
Node dropNode = getNodeForDrop (dtde.getLocation ()); |
Lines 477-484
Link Here
|
477 |
if (!canDrop (dropNode, dtde.getDropAction ())) { |
477 |
if (!canDrop (dropNode, dtde.getDropAction ())) { |
478 |
if (canReorder (dropNode, dragNodes)) { |
478 |
if (canReorder (dropNode, dragNodes)) { |
479 |
performReorder (dropNode, dragNodes, toIndex); |
479 |
performReorder (dropNode, dragNodes, toIndex); |
|
|
480 |
dtde.acceptDrop (dtde.getDropAction ()); |
481 |
} else { |
482 |
dtde.rejectDrop (); |
480 |
} |
483 |
} |
481 |
dtde.rejectDrop (); |
484 |
dtde.dropComplete (true); |
482 |
return; |
485 |
return; |
483 |
} |
486 |
} |
484 |
|
487 |
|
Lines 560-566
Link Here
|
560 |
|
563 |
|
561 |
// finished |
564 |
// finished |
562 |
dtde.dropComplete (true); |
565 |
dtde.dropComplete (true); |
563 |
|
|
|
564 |
} |
566 |
} |
565 |
|
567 |
|
566 |
/** Activates or deactivates Drag support on asociated JTree |
568 |
/** Activates or deactivates Drag support on asociated JTree |