Most of the logic for CellTree and CellTable happens in a package protected HasDataPresenter class. In that class, the CellTree/CellTable adds a handler to the SelectionModel so we can update the DOM when selection changes. CellTree is like a hierarchy of CellList, so they share a lot of code. http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/cellview/client/HasDataPresenter.java?#838
Well, the question is how to do this. I assume we install a SelectionChangeHandler. However, we don't know how many
SelectionModels there
are: one for the whole tree, or one for each parent? It's also unclear
how we
know which cells to re-render after a SelectionChangeEvent. I don't
see any
callbacks in CellTree or CellTable so I'm not sure how the DOM gets
updated
after a selection state change.
Its up to the user to decide how many SelectionModels to use. The user implements a TreeViewModel to provide a DefaultNodeInfo (which is like a child provider) to the Tree every time a tree item is expanded. In DefaultNodeInfo, you can pass a SelectionModel. If you pass the same instance for all nodes, then you have one global selection model. If you pass a new instance for each node, then each set of children will have its own selection. I just read through issue 7480, and it isn't about CellTree at all. It looks like a specific bug in CellTable related to updating the SelectionModel after editing a Cell. It could be a timing bug because CellTable accumulates changes then redraws in a deferred command to improve performance. HasDataPresenterTest has some tests to check that it is updated when the SelectionModel is modified. In general, this was a well tested feature. It could be used to keep two CellTables in sync, for example. http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/test/com/google/gwt/user/cellview/client/HasDataPresenterTest.java http://gwt-code-reviews.appspot.com/1776803/ -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
