Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-ui-dev] JFace Tree hackery

The way JFace's AbstractTreeViewer uses Tree wrt to nodes that have
children but the children's contents is not read is less than optimal on
GTK2 (and perhaps other platforms though I have no specific knowledge).
Currently it adds a blank item to the tree at that point. When you
expand the node, it appears to *first* delete the phantom node, and then
read the real children from the model and add them. The problem is that
this necessitates somehow "freezing" the Tree for an undefined period of
time (unless I am missing some calls here, which I could be). 

GTK2's TreeView can't be frozen because it is model driven. Hence when
you expand an item, JFace removes the phantom node which GtkTreeView
detects and consequently removes the expander and collapses the node,
then JFace adds the new elements which go into an unexpanded tree. The
second expansion, of course, works fine. The user visible effect is that
you have to click twice to expand a row :-)

I see two better ways to handle this:

1) The cleanest IMO is to add "setHasChildren" or something like that to
the TreeItem API. So rather than JFace managing phantom nodes, platforms
without a tree that can display an expander without knowing the contents
will manage it. And of course platforms without this ability can
implement a phantom-node hack.

2) The no-API-change method is to not remove the phantom node until at
least one of the real child nodes has been added.

-Seth



Back to the top