[Gtk-sharp-list] NodeStore and lazy loading

Ben Maurer bmaurer at ximian.com
Thu Aug 18 10:54:30 EDT 2005


> The FileSystemModel example is a bad one. I'm very rusty wrt JTree, but
> afaics this model *only* works with a custom JTree. The example model
> doesn't return instances of TreeNode, so a standard JTree
> doesn't work with this model.

Apparently, TreeNode is a helper class that works with DefaultTreeModel. A
model like the file system one will work just fine.

I haven't tried the sample yet (seeing as a don't have eclipse on this
box. though, I really should fix that in the near-future seeing as my
classes at CMU will be in java ;-), but I'd assume it works; there is no
custom jtree.

> Using an hourglass and a "Loading..." node are really implementation
> specific. In the GnomeVfs TreeView i coded, performance was pretty good,
> negating the need for an hourglass or "Loading..." node.

Do we really make this so hard though. I asked on #gtk+ about how one
would make an async, lazy-load tree. Owen responded that all the examples
that he knew of were horrific.

Have you looked at my msdnn browser code:

http://primates.ximian.com/~bmaurer/msdnb.cs

The EnsureNoFakeLeafs is a bit confusing. It is very easy to make it buggy
(for example, I had issues where i'd get tons of blank nodes in many
cases), and honestly, it isn't something I should have to deal with as a
consumer of the tree.

> The example only works as long as JTree initially only queries for the
> root nodes and if those are leafs or not. I don't recall offhand how Gtk
> does this.

I assume that's what it does, otherwise the example would be broken.

> Anyway, is this really something worth taking the time to
> discuss/possibly implement?

I think so. It took me 1 hr to figure out how to read the msdn tree from
xml (and debug this portion of the code). I spent 2 hrs trying to figure
out how to get a lazy load treeview in the NodeStore api, and getting it
working correctly. (most of this time was spent going on a deadend
path...)

> Just lookup which
> events tells you when a row is expanded and go from there. I can try and
> see if i still have this example lying around somewhere.

I did, and it works. However, IMHO there are two issues:

1) the method I used to get this working was not obvious (Why would I hook
something up in TreeView to implement my TreeModel correctly?). It'd be
great to put this in the docs

2) The use of TreeView to implement my TreeModel is not exactly MVC style.
Also, I have to do hackery with dummmy nodes to make things work. The code
is more complex than it should be and has a fairly large risk of being
buggy. Doing a lazy load treeview is something that seems like a common
task. Why should we make it hard to do?

-- Ben




More information about the Gtk-sharp-list mailing list