fix tree snapshot for changing sources/authors
[fanfix.git] / src / be / nikiroo / fanfix_swing / gui / utils / TreeSnapshot.java
index e202544d7627f0c30cdce2844e22a458ce8de820..ad734a1448f3e2de3c678a2b462e76b71a8dca86 100644 (file)
@@ -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);
        }