This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 25963
Collapse All | Expand All

(-)src/org/openide/explorer/view/DropGlassPane.java (-1 / +36 lines)
Lines 13-24 Link Here
13
13
14
package org.openide.explorer.view;
14
package org.openide.explorer.view;
15
15
16
import java.awt.Component;
16
import java.awt.Graphics;
17
import java.awt.Graphics;
17
import java.awt.Rectangle;
18
import java.awt.Rectangle;
18
import java.awt.geom.Line2D;
19
import java.awt.geom.Line2D;
19
import java.util.HashMap;
20
import java.util.HashMap;
20
import javax.swing.JComponent;
21
import javax.swing.JComponent;
21
import javax.swing.JPanel;
22
import javax.swing.JPanel;
23
import javax.swing.JTree;
22
24
23
/**
25
/**
24
 * Glass pane which is used for paint of a drop line over <code>JComponent</code>.
26
 * Glass pane which is used for paint of a drop line over <code>JComponent</code>.
Lines 36-41 Link Here
36
    final static private int MIN_Y = 3;
38
    final static private int MIN_Y = 3;
37
    final static private int MIN_WIDTH = 10;
39
    final static private int MIN_WIDTH = 10;
38
    final static private int MIN_HEIGTH = 3;
40
    final static private int MIN_HEIGTH = 3;
41
    
42
    transient static private Component oldPane;
43
    transient static private JTree originalSource;
44
    transient static private boolean wasVisible;
39
45
40
    private DropGlassPane () {
46
    private DropGlassPane () {
41
    }
47
    }
Lines 51-57 Link Here
51
        }
57
        }
52
        return (DropGlassPane)map.get (id);
58
        return (DropGlassPane)map.get (id);
53
    }
59
    }
54
60
    
61
    /** Stores the original glass pane on given tree.
62
     * @param source the active container
63
     * @param pane the original glass
64
     * @param visible was glass pane visible
65
     */    
66
    static void setOriginalPane (JTree source, Component pane, boolean visible) {
67
        // pending, should throw an exception that original is set already
68
        oldPane = pane;
69
        originalSource = source;
70
        wasVisible = visible;
71
    }
72
    
73
    /** Is any original glass pane stored?
74
     * @return true if true; false otherwise
75
     */    
76
    static boolean isOriginalPaneStored () {
77
        return oldPane != null;
78
    }
79
    
80
    /** Sets the original glass pane to the root pane of stored container.
81
     */    
82
    static void putBackOriginal () {
83
        if (oldPane == null)
84
            // pending, should throw an exception
85
            return ;
86
        originalSource.getRootPane ().setGlassPane (oldPane);
87
        oldPane.setVisible (wasVisible);
88
        oldPane = null;
89
    }
55
    
90
    
56
    /** Unset drop line if setVisible to false.
91
    /** Unset drop line if setVisible to false.
57
     * @param boolean aFlag new state */    
92
     * @param boolean aFlag new state */    
(-)src/org/openide/explorer/view/TreeViewDragSupport.java (-1 / +10 lines)
Lines 87-92 Link Here
87
        // get the droped nodes
87
        // get the droped nodes
88
        Node[] dropedNodes = exDnD.getDraggedNodes ();
88
        Node[] dropedNodes = exDnD.getDraggedNodes ();
89
        super.dragDropEnd (dsde);
89
        super.dragDropEnd (dsde);
90
91
        // if any original glass pane was stored (the DnD was broken e.g. by Esc)
92
        if (DropGlassPane.isOriginalPaneStored ()) {
93
            // give back the orig glass pane
94
            DropGlassPane.putBackOriginal ();
95
            // DnD is not active
96
            exDnD.setDnDActive (false);
97
        }
98
        
90
        // select the droped nodes
99
        // select the droped nodes
91
        try {
100
        try {
92
            if (dropedNodes!=null) {
101
            if (dropedNodes!=null) {
Lines 99-105 Link Here
99
        } catch (Exception e) {
108
        } catch (Exception e) {
100
            // don't care
109
            // don't care
101
        }
110
        }
102
        exDnD.setDnDActive (false);
111
        
103
        // notify tree cell editor that DnD operationm is active
112
        // notify tree cell editor that DnD operationm is active
104
        // no more
113
        // no more
105
        TreeCellEditor tce = tree.getCellEditor();
114
        TreeCellEditor tce = tree.getCellEditor();
(-)src/org/openide/explorer/view/TreeViewDropSupport.java (-30 / +32 lines)
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

Return to bug 25963