Lines 115-120
Link Here
|
115 |
transient TreeViewDropSupport dropSupport; |
115 |
transient TreeViewDropSupport dropSupport; |
116 |
|
116 |
|
117 |
transient boolean dropTargetPopupAllowed = true; |
117 |
transient boolean dropTargetPopupAllowed = true; |
|
|
118 |
transient private Container contentPane; |
119 |
transient private PropertyChangeListener waitListener; |
120 |
transient private Node waitingNode; |
121 |
transient private String PROP_INIT_CHILDREN_STARTED = "initChildrenStarted"; // NOI18N |
122 |
transient private String PROP_INIT_CHILDREN_FINISHED = "initChildrenFinished"; // NOI18N |
118 |
|
123 |
|
119 |
/** Constructor. |
124 |
/** Constructor. |
120 |
*/ |
125 |
*/ |
Lines 180-185
Link Here
|
180 |
// init listener & attach it to closing of |
185 |
// init listener & attach it to closing of |
181 |
managerListener = new TreePropertyListener(); |
186 |
managerListener = new TreePropertyListener(); |
182 |
tree.addTreeExpansionListener (managerListener); |
187 |
tree.addTreeExpansionListener (managerListener); |
|
|
188 |
tree.addTreeWillExpandListener (managerListener); |
183 |
|
189 |
|
184 |
// do not care about focus |
190 |
// do not care about focus |
185 |
setRequestFocusEnabled (false); |
191 |
setRequestFocusEnabled (false); |
Lines 393-398
Link Here
|
393 |
* @param n node |
399 |
* @param n node |
394 |
*/ |
400 |
*/ |
395 |
public void expandNode (Node n) { |
401 |
public void expandNode (Node n) { |
|
|
402 |
|
396 |
lookupExplorerManager (); |
403 |
lookupExplorerManager (); |
397 |
|
404 |
|
398 |
|
405 |
|
Lines 483-489
Link Here
|
483 |
public void removeNotify () { |
490 |
public void removeNotify () { |
484 |
super.removeNotify (); |
491 |
super.removeNotify (); |
485 |
|
492 |
|
486 |
//System.out.println ("Calling remove notify..."); // NOI18N |
|
|
487 |
tree.getSelectionModel().removeTreeSelectionListener(managerListener); |
493 |
tree.getSelectionModel().removeTreeSelectionListener(managerListener); |
488 |
} |
494 |
} |
489 |
|
495 |
|
Lines 660-665
Link Here
|
660 |
return tree.getSelectionModel ().getSelectionMode (); |
666 |
return tree.getSelectionModel ().getSelectionMode (); |
661 |
} |
667 |
} |
662 |
|
668 |
|
|
|
669 |
private void showWaitCursor () { |
670 |
if (contentPane == null) { |
671 |
contentPane = getRootPane ().getContentPane (); |
672 |
} |
673 |
if (SwingUtilities.isEventDispatchThread ()) { |
674 |
contentPane.setCursor (Utilities.createProgressCursor (contentPane)); |
675 |
} else { |
676 |
SwingUtilities.invokeLater (new Runnable () { |
677 |
public void run () { |
678 |
contentPane.setCursor (Utilities.createProgressCursor (contentPane)); |
679 |
} |
680 |
}); |
681 |
} |
682 |
} |
683 |
|
684 |
private void showNormalCursor () { |
685 |
if (contentPane == null) { |
686 |
contentPane = getRootPane ().getContentPane (); |
687 |
} |
688 |
if (SwingUtilities.isEventDispatchThread ()) { |
689 |
contentPane.setCursor (null); |
690 |
} else { |
691 |
SwingUtilities.invokeLater (new Runnable () { |
692 |
public void run () { |
693 |
contentPane.setCursor (null); |
694 |
} |
695 |
}); |
696 |
} |
697 |
if (waitingNode !=null) { |
698 |
removePropertyChangeListener (waitListener); |
699 |
} |
700 |
} |
701 |
|
702 |
private void prepareWaitCursor (final Node node) { |
703 |
// check type of node |
704 |
if (node == null) { |
705 |
showNormalCursor (); |
706 |
} |
707 |
waitingNode = node; |
708 |
|
709 |
// initialize wait listener |
710 |
if (waitListener == null) { |
711 |
waitListener = new PropertyChangeListener () { |
712 |
public void propertyChange (PropertyChangeEvent evt) { |
713 |
if (PROP_INIT_CHILDREN_STARTED.equals (evt.getPropertyName ())) { |
714 |
showWaitCursor (); |
715 |
} |
716 |
if (PROP_INIT_CHILDREN_FINISHED.equals (evt.getPropertyName ())) { |
717 |
showNormalCursor (); |
718 |
} |
719 |
} |
720 |
}; |
721 |
} |
722 |
|
723 |
// remove wait listener |
724 |
node.addPropertyChangeListener (waitListener); |
725 |
} |
726 |
|
663 |
/** Synchronize the selected nodes from the manager of this Explorer. |
727 |
/** Synchronize the selected nodes from the manager of this Explorer. |
664 |
* The default implementation does nothing. |
728 |
* The default implementation does nothing. |
665 |
*/ |
729 |
*/ |
Lines 691-696
Link Here
|
691 |
class TreePropertyListener implements VetoableChangeListener, |
755 |
class TreePropertyListener implements VetoableChangeListener, |
692 |
PropertyChangeListener, |
756 |
PropertyChangeListener, |
693 |
TreeExpansionListener, |
757 |
TreeExpansionListener, |
|
|
758 |
TreeWillExpandListener, |
694 |
TreeSelectionListener, Runnable { |
759 |
TreeSelectionListener, Runnable { |
695 |
|
760 |
|
696 |
private RequestProcessor.Task scheduled; |
761 |
private RequestProcessor.Task scheduled; |
Lines 721-727
Link Here
|
721 |
|
786 |
|
722 |
public synchronized void treeExpanded (TreeExpansionEvent ev) { |
787 |
public synchronized void treeExpanded (TreeExpansionEvent ev) { |
723 |
final TreePath path = ev.getPath (); |
788 |
final TreePath path = ev.getPath (); |
724 |
|
789 |
|
725 |
RequestProcessor.Task t = scheduled; |
790 |
RequestProcessor.Task t = scheduled; |
726 |
if (t != null) { |
791 |
if (t != null) { |
727 |
t.cancel (); |
792 |
t.cancel (); |
Lines 733-743
Link Here
|
733 |
public void run () { |
798 |
public void run () { |
734 |
if (!SwingUtilities.isEventDispatchThread()) { |
799 |
if (!SwingUtilities.isEventDispatchThread()) { |
735 |
SwingUtilities.invokeLater (this); |
800 |
SwingUtilities.invokeLater (this); |
|
|
801 |
|
736 |
return; |
802 |
return; |
737 |
} |
803 |
} |
738 |
|
804 |
|
739 |
if (!tree.isVisible(path)) { |
805 |
if (!tree.isVisible(path)) { |
740 |
// if the path is not visible - don't check the children |
806 |
// if the path is not visible - don't check the children |
|
|
807 |
|
741 |
return; |
808 |
return; |
742 |
} |
809 |
} |
743 |
|
810 |
|
Lines 755-760
Link Here
|
755 |
// System.out.println("different roots."); |
822 |
// System.out.println("different roots."); |
756 |
return; |
823 |
return; |
757 |
} |
824 |
} |
|
|
825 |
|
826 |
// show wait cursor |
827 |
//showWaitCursor (); |
758 |
|
828 |
|
759 |
int lastChildIndex = myNode.getChildCount()-1; |
829 |
int lastChildIndex = myNode.getChildCount()-1; |
760 |
if (lastChildIndex >= 0) { |
830 |
if (lastChildIndex >= 0) { |
Lines 775-780
Link Here
|
775 |
|
845 |
|
776 |
public synchronized void treeCollapsed (final TreeExpansionEvent ev) { |
846 |
public synchronized void treeCollapsed (final TreeExpansionEvent ev) { |
777 |
final TreePath path = ev.getPath (); |
847 |
final TreePath path = ev.getPath (); |
|
|
848 |
showNormalCursor (); |
778 |
|
849 |
|
779 |
RequestProcessor.Task t = scheduled; |
850 |
RequestProcessor.Task t = scheduled; |
780 |
if (t != null) { |
851 |
if (t != null) { |
Lines 871-876
Link Here
|
871 |
callSelectionChanged ((Node[])ll.toArray (new Node[ll.size ()])); |
942 |
callSelectionChanged ((Node[])ll.toArray (new Node[ll.size ()])); |
872 |
} |
943 |
} |
873 |
|
944 |
|
|
|
945 |
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { |
946 |
} |
947 |
|
948 |
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { |
949 |
// prepare wait cursor and optionally show it |
950 |
TreePath path = event.getPath (); |
951 |
prepareWaitCursor (DragDropUtilities.secureFindNode (path.getLastPathComponent ())); |
952 |
} |
953 |
|
874 |
} // end of TreePropertyListener |
954 |
} // end of TreePropertyListener |
875 |
|
955 |
|
876 |
|
956 |
|