• Post Reply Bookmark Topic Watch Topic
  • New Topic

TreeTable - How to update?

 
Ingo Olbrich
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm experimenting with a TreeTable Component. I've tried the "classical" approach published on the sun webpage as an article to create an TreeTable and I've also tried the netbeans Outline component. In both cases I managed to build up a nice, working tree with data from an database.

What I'm trying now is to find the best way to update the data displayed in the tree. And here I'm stuck:

I'm able to update the view only by providing a new model or by repainting the gui - in both cases all expanded trees are collapsed again, though the data in the model is fresh.

Or other way round, the tree is still expanded, the data in the model is fresh, but the view is stale.

I think I'm missing the conceptual point of how to update a tree table... Where can I get more information of how it is supposed to work? I have googed around, but most information found stops with simple building up the structures...

Or does anyone have an idea where my error might be located?

Best regards,
Ingo
 
Suraj Chandran
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Violet's tree table code from Sun, then maybe you should look in to the following methods:

and also

The above methods must be ther somewhere in AbstractTreeTableModel or somewhere, I don't really remeber.
 
Ingo Olbrich
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thanks for the fast reply!

I did fire the fireTreeStructureChanged() after rebuilding the model - but it didn't cause the view to be update. To update the model I tried an approach by actually navigating through the tree and I tried just to inject a new root into the model and then fireing the event.

Do I have to implment code in Violet's methods?
 
Suraj Chandran
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somehow its working for me, though all the nodes collapse, its working nonetheless.
But I dont remember what all I have modified in Violet's code since then.
And I can't give the code...policies
 
Ingo Olbrich
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

hmm, same with my code. I can refresh tree including model, but the tree collapses. Which is my problem, it's quite frustrating when you finally managed to find your detail in hundred nodes and the my timer fires, tress is refreshed and all details are collapsed again :-(
 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ingo Olbrich wrote:

hmm, same with my code. I can refresh tree including model, but the tree collapses. Which is my problem


Well this is what fireTreeStructureChanged() does. It is a bazooka that declares that the entire tree may have changed.

Your alternatives are (A) don't call fireTreeStructureChanged() but call only the other fireXXX() methods, or (B) take a snapshot of the expanded paths before calling fireTreeStructureChanged() and restore them afterwards.
 
Ingo Olbrich
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian,

thanks for the explanation! Should have thought about that, there is a slight hint in the name of the Event

Where can I find more about taking a snapshot? Sounds like the way to go for me, cause I just want to keep the one or two first level Folders open, that the user has already selected....

Any hints?

Best regards,
Ingo
 
Suraj Chandran
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
say "renTree" is the tree you areusing to render the tree part in the TreeTable, then
to take snapshot(funny term ):


then later to restore snapshot, use the above enum with the following api:


 
Ingo Olbrich
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

thanks for the help! Managed to get it working, easiest way to work for me was using the http://swinglabs.org/index.jsp JXTreeTable, using the described snapshot...

Best regards,
Ingo
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!