Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update-tree!
  • Loading branch information
odyssomay committed Jul 28, 2011
commit 0c780ede7225925e37681e76ff3930b12d00093e
19 changes: 19 additions & 0 deletions src/seesaw/tree.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)