From 83777343b465fb3feb87d3bbfe636aefcc21f4c6 Mon Sep 17 00:00:00 2001 From: Audrius Meskauskas Date: Tue, 4 Jul 2006 10:07:47 +0000 Subject: 2006-07-04 Audrius Meskauskas 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. --- ChangeLog | 10 ++++++++++ javax/swing/plaf/basic/BasicTreeUI.java | 24 +++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index e39548a5b..54bed67ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-07-04 Audrius Meskauskas + + 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. + 2006-07-04 Audrius Meskauskas PR 28061 diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java index 221bc2557..ac3e9b719 100644 --- a/javax/swing/plaf/basic/BasicTreeUI.java +++ b/javax/swing/plaf/basic/BasicTreeUI.java @@ -2392,11 +2392,13 @@ public class BasicTreeUI 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 @@ public class BasicTreeUI } } } + + // Ensure that the lead path is visible after the increment action. + tree.scrollPathToVisible(tree.getLeadSelectionPath()); } /** @@ -3026,6 +3031,9 @@ public class BasicTreeUI 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 @@ public class BasicTreeUI // 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 @@ public class BasicTreeUI tree.expandPath(current); } } + + // Ensure that the lead path is visible after the increment action. + tree.scrollPathToVisible(tree.getLeadSelectionPath()); } /** -- cgit v1.2.1