X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix_swing%2Fgui%2Futils%2FTreeSnapshot.java;h=ad734a1448f3e2de3c678a2b462e76b71a8dca86;hb=77e5ecd4fc25c052340fc00cc974972b2323d3d1;hp=e202544d7627f0c30cdce2844e22a458ce8de820;hpb=2a03ecc0ae449a05763db2d47935a4c256cd092f;p=fanfix.git diff --git a/src/be/nikiroo/fanfix_swing/gui/utils/TreeSnapshot.java b/src/be/nikiroo/fanfix_swing/gui/utils/TreeSnapshot.java index e202544..ad734a1 100644 --- a/src/be/nikiroo/fanfix_swing/gui/utils/TreeSnapshot.java +++ b/src/be/nikiroo/fanfix_swing/gui/utils/TreeSnapshot.java @@ -54,7 +54,7 @@ public class TreeSnapshot { TreePath newPath = nodeToPath(newNode); if (newPath != null) { for (TreePath path : selectionPaths) { - if (newPath.toString().equals(path.toString())) { + if (isSamePath(path, newPath)) { newSlectionPaths.add(newPath); if (expanded.contains(path)) { newExpanded.add(newPath); @@ -72,6 +72,11 @@ public class TreeSnapshot { tree.setSelectionPaths(newSlectionPaths.toArray(new TreePath[0])); } + // You can override this + protected boolean isSamePath(TreePath oldPath, TreePath newPath) { + return newPath.toString().equals(oldPath.toString()); + } + private void forEach(JTree tree, NodeAction action) { forEach(tree.getModel(), tree.getModel().getRoot(), action); }