Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I update a seesaw tree model?

I've been using seesaw.tree/simple-tree-model to create my TreeModels, the docs say that this is read only. Originally I didn't need to edit the tree structure however now I do!

There is a pull request in seesaw for adding update-tree!. Though this is 8 months old.

What is the best way to create and edit JTrees with seesaw / clojure?

like image 916
AnnanFay Avatar asked Apr 04 '12 23:04

AnnanFay


1 Answers

Unfortunately, Seesaw's tree support is pretty lame. JTree (and it's just-as-nasty cousin JTable) is extremely complicated so coming up with a clean wrapper that covers a lot of use cases has proven difficult.

Anyway, if you want an editable tree model, you're going to have to either create your own implementation of TreeModel, or build off of DefaultTreeModel, tutorial here. The key with DefaultTreeModel is to always make modifications (adding/removing children, etc) through the DefaultTreeModel object rather than the nodes directly. This ensure that events are fired correctly and the tree is repainted, etc. If you find yourself manually calling updateUI or anything like that on the tree, you're doing something wrong.

Hope this helps. Sorry about the inconvenience. It just makes me sick to think of someone using Seesaw having to do interop :)

like image 139
Dave Ray Avatar answered Nov 02 '22 23:11

Dave Ray