How can I update a seesaw tree model?
Asked Answered
D

1

5

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?

Drusilladrusus answered 4/4, 2012 at 23:47 Comment(0)
P
7

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 :)

Postfix answered 5/4, 2012 at 12:59 Comment(3)
I was about to ask a very similar question about JTable :) Seesaw has been much more fun than Swing so far, so I have no complaints even if this causes me a little pain.Futurism
pretty much the same story there although table has slightly better editing support if I recall correctly.Postfix
I think maybe pedestal.io 's extensive DOM-diffing mechanisms could be handy for this tree as well...Papillote

© 2022 - 2024 — McMap. All rights reserved.