Browse files

update-tree!

  • Loading branch information...
1 parent 0a69927 commit 0c780ede7225925e37681e76ff3930b12d00093e @odyssomay committed Jul 28, 2011
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/seesaw/tree.clj
View
19 src/seesaw/tree.clj
@@ -25,3 +25,22 @@
(removeTreeModelListener [this listener])
(valueForPathChanged [this path newValue])))
+(defn update-tree!
+ "Update a tree.
+ The model is optional, if not supplied this function refreshes
+ the tree (useful for e.g. file trees).
+
+ Expanded nodes will still be expanded after update, given that
+ the expanded node didn't change.
+ "
+ {:arglists '([tree model?])}
+ [tree & [model]]
+ (if model
+ (let [visible_paths (doall
+ (for [row (range (.getRowCount tree))]
+ (.getPathForRow tree row)))]
+ (.setModel tree (if model model (.getModel tree)))
+ (doseq [path visible_paths]
+ (.makeVisible tree path)))
+ (.updateUI tree))
+ tree)

0 comments on commit 0c780ed

Please sign in to comment.