This patch revives autoscrolling (the visibility check must be performed
at the end of the listed tree actions). It also fixes the old editing
bug that was by chance revived with the previous patch.
2006-07-04 Audrius Meskauskas <[EMAIL PROTECTED]>
PR 28061
* javax/swing/plaf/basic/BasicTreeUI.java (MouseHandler.mousePressed):
Always cancel the current editing session before doing anything else,
return immediately if this fails.
(TreeHomeAction): Ensure that the lead selection path is visible after
the action is performed. TreeIncrementAction: Likewise.
TreeToggleAction:
Likewise. TreeTraverseAction: Likewise.
Index: BasicTreeUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v
retrieving revision 1.146
diff -u -r1.146 BasicTreeUI.java
--- BasicTreeUI.java 4 Jul 2006 08:46:43 -0000 1.146
+++ BasicTreeUI.java 4 Jul 2006 10:02:39 -0000
@@ -2392,11 +2392,13 @@
if (tree != null && tree.isEnabled())
{
- // Maybe stop editing and return.
- if (isEditing(tree) && tree.getInvokesStopCellEditing()
- && ! stopEditing(tree))
- return;
-
+ // Always end the current editing session if clicked on the
+ // tree and outside the bounds of the editing component.
+ if (isEditing(tree))
+ if (!stopEditing(tree))
+ // Return if we have failed to cancel the editing session.
+ return;
+
int x = e.getX();
int y = e.getY();
TreePath path = getClosestPathForLocation(tree, x, y);
@@ -2911,6 +2913,9 @@
}
}
}
+
+ // Ensure that the lead path is visible after the increment action.
+ tree.scrollPathToVisible(tree.getLeadSelectionPath());
}
/**
@@ -3026,6 +3031,9 @@
tree.setAnchorSelectionPath(newPath);
tree.setLeadSelectionPath(newPath);
}
+
+ // Ensure that the lead path is visible after the increment action.
+ tree.scrollPathToVisible(tree.getLeadSelectionPath());
}
/**
@@ -3330,6 +3338,9 @@
// and anchor.
tree.setLeadSelectionPath(leadPath);
tree.setAnchorSelectionPath(anchorPath);
+
+ // Ensure that the lead path is visible after the increment action.
+ tree.scrollPathToVisible(tree.getLeadSelectionPath());
}
}
@@ -3417,6 +3428,9 @@
tree.expandPath(current);
}
}
+
+ // Ensure that the lead path is visible after the increment action.
+ tree.scrollPathToVisible(tree.getLeadSelectionPath());
}
/**