Line 776
Link Here
|
776 |
final TreePath path = ev.getPath (); |
|
|
Lines 782-785
Link Here
|
782 |
|
781 |
|
783 |
// It is OK to use multithreaded shared RP as the requests |
782 |
|
784 |
// will be serialized in event queue later |
783 |
class Request implements Runnable { |
785 |
scheduled = RequestProcessor.getDefault().post (new Runnable () { |
784 |
|
786 |
-- |
785 |
private TreePath path; |
|
|
786 |
|
787 |
public Request (TreePath path) { |
788 |
this.path = path; |
789 |
} |
790 |
|
Lines 787-825
Link Here
|
787 |
if (!SwingUtilities.isEventDispatchThread()) { |
792 |
try { |
788 |
SwingUtilities.invokeLater (this); |
793 |
if (!SwingUtilities.isEventDispatchThread()) { |
789 |
|
794 |
SwingUtilities.invokeLater (this); |
790 |
return; |
795 |
|
791 |
} |
796 |
return; |
792 |
|
797 |
} |
793 |
if (!tree.isVisible(path)) { |
798 |
|
794 |
// if the path is not visible - don't check the children |
799 |
if (!tree.isVisible(path)) { |
795 |
|
800 |
// if the path is not visible - don't check the children |
796 |
return; |
801 |
|
797 |
} |
802 |
return; |
798 |
|
803 |
} |
799 |
if (treeModel == null) { |
804 |
|
800 |
// no model, no action, no problem |
805 |
if (treeModel == null) { |
801 |
return; |
806 |
// no model, no action, no problem |
802 |
} |
807 |
return; |
803 |
|
808 |
} |
804 |
TreeNode myNode = (TreeNode)path.getLastPathComponent(); |
809 |
|
805 |
|
810 |
TreeNode myNode = (TreeNode)path.getLastPathComponent(); |
806 |
if (treeModel.getPathToRoot(myNode)[0] != treeModel.getRoot()) { |
811 |
|
807 |
// the way from the path no longer |
812 |
if (treeModel.getPathToRoot(myNode)[0] != treeModel.getRoot()) { |
808 |
// goes to the root, probably someone |
813 |
// the way from the path no longer |
809 |
// has removed the node on the way up |
814 |
// goes to the root, probably someone |
810 |
// System.out.println("different roots."); |
815 |
// has removed the node on the way up |
811 |
return; |
816 |
// System.out.println("different roots."); |
812 |
} |
817 |
return; |
813 |
|
|
|
814 |
// show wait cursor |
815 |
//showWaitCursor (); |
816 |
|
817 |
int lastChildIndex = myNode.getChildCount()-1; |
818 |
if (lastChildIndex >= 0) { |
819 |
TreeNode lastChild = myNode.getChildAt(lastChildIndex); |
820 |
|
821 |
Rectangle base = tree.getVisibleRect(); |
822 |
Rectangle b1 = tree.getPathBounds(path); |
823 |
Rectangle b2 = tree.getPathBounds(new TreePath(treeModel.getPathToRoot(lastChild))); |
824 |
if (base != null && b1 != null && b2 != null) { |
825 |
tree.scrollRectToVisible(new Rectangle(base.x, b1.y, 1, b2.y - b1.y + b2.height)); |
826 |
-- |
Line 828
Link Here
|
|
|
820 |
// show wait cursor |
821 |
//showWaitCursor (); |
822 |
|
823 |
int lastChildIndex = myNode.getChildCount()-1; |
824 |
if (lastChildIndex >= 0) { |
825 |
TreeNode lastChild = myNode.getChildAt(lastChildIndex); |
826 |
|
827 |
Rectangle base = tree.getVisibleRect(); |
828 |
Rectangle b1 = tree.getPathBounds(path); |
829 |
Rectangle b2 = tree.getPathBounds(new TreePath(treeModel.getPathToRoot(lastChild))); |
830 |
if (base != null && b1 != null && b2 != null) { |
831 |
tree.scrollRectToVisible(new Rectangle(base.x, b1.y, 1, b2.y - b1.y + b2.height)); |
832 |
} |
833 |
|
Line 829
Link Here
|
|
|
835 |
} |
836 |
} finally { |
837 |
path = null; |
Line 831
Link Here
|
831 |
}, 250); // hope that all children are there after this time |
840 |
} |
832 |
-- |
841 |
|
|
|
842 |
// It is OK to use multithreaded shared RP as the requests |
843 |
// will be serialized in event queue later |
844 |
scheduled = RequestProcessor.getDefault().post (new Request (ev.getPath ()), 250); // hope that all children are there after this time |
Line 835
Link Here
|
835 |
final TreePath path = ev.getPath (); |
|
|
Line 837
Link Here
|
837 |
|
849 |
|
838 |
-- |
|
|
Lines 842-845
Link Here
|
842 |
|
854 |
|
843 |
// It is OK to use multithreaded shared RP as the requests |
855 |
class Request implements Runnable { |
844 |
// will be serialized in event queue later |
856 |
|
845 |
scheduled = RequestProcessor.getDefault().post (new Runnable () { |
857 |
private TreePath path; |
846 |
-- |
858 |
|
|
|
859 |
public Request (TreePath path) { |
860 |
this.path = path; |
861 |
} |
862 |
|
Lines 847-856
Link Here
|
847 |
if (!SwingUtilities.isEventDispatchThread()) { |
864 |
try { |
848 |
SwingUtilities.invokeLater (this); |
865 |
if (!SwingUtilities.isEventDispatchThread()) { |
849 |
return; |
866 |
SwingUtilities.invokeLater (this); |
850 |
} |
867 |
return; |
851 |
|
868 |
} |
852 |
if (tree.isExpanded(path)) { |
|
|
853 |
// the tree shows the path - do not collapse |
854 |
// the tree |
855 |
return; |
856 |
} |
857 |
-- |
Lines 858-862
Link Here
|
858 |
if (!tree.isVisible(path)) { |
870 |
if (tree.isExpanded(path)) { |
859 |
// if the path is not visible do not collapse |
871 |
// the tree shows the path - do not collapse |
860 |
// the tree |
872 |
// the tree |
861 |
return; |
873 |
return; |
862 |
} |
874 |
} |
863 |
-- |
|
|
Lines 864-867
Link Here
|
864 |
if (treeModel == null) { |
876 |
if (!tree.isVisible(path)) { |
865 |
// no model, no action, no problem |
877 |
// if the path is not visible do not collapse |
866 |
return; |
878 |
// the tree |
867 |
} |
879 |
return; |
868 |
-- |
880 |
} |
Line 869
Link Here
|
869 |
TreeNode myNode = (TreeNode)path.getLastPathComponent(); |
882 |
if (treeModel == null) { |
870 |
-- |
883 |
// no model, no action, no problem |
|
|
884 |
return; |
885 |
} |
Lines 871-878
Link Here
|
871 |
if (treeModel.getPathToRoot(myNode)[0] |
887 |
TreeNode myNode = (TreeNode)path.getLastPathComponent(); |
872 |
!= treeModel.getRoot()) { |
888 |
|
873 |
// the way from the path no longer |
889 |
if (treeModel.getPathToRoot(myNode)[0] |
874 |
// goes to the root, probably someone |
890 |
!= treeModel.getRoot()) { |
875 |
// has removed the node on the way up |
891 |
// the way from the path no longer |
876 |
// System.out.println("different roots."); |
892 |
// goes to the root, probably someone |
877 |
return; |
893 |
// has removed the node on the way up |
878 |
} |
894 |
// System.out.println("different roots."); |
879 |
-- |
895 |
return; |
|
|
896 |
} |
Line 880
Link Here
|
880 |
treeModel.nodeStructureChanged(myNode); |
898 |
treeModel.nodeStructureChanged(myNode); |
881 |
-- |
899 |
} finally { |
|
|
900 |
this.path = null; |
901 |
} |
Line 882
Link Here
|
882 |
}, TIME_TO_COLLAPSE); |
903 |
} |
883 |
-- |
904 |
|
|
|
905 |
// It is OK to use multithreaded shared RP as the requests |
906 |
// will be serialized in event queue later |
907 |
scheduled = RequestProcessor.getDefault().post (new Request(ev.getPath ()), TIME_TO_COLLAPSE); |