Community
Participate
Working Groups
Build ID: I20080617-2000 Steps To Reproduce: If a domain object appears twice or more in a TreeViewer, client code must call viewer.setUseHashLookUp(true) so that viewer.update(domain_object, null) refreshes all occurrences, instead of only the first found. This behavior is not documented in the javadoc for either setUseHashLookUp() or update() ! More information: Using setUseHashLookUp(true) seems to be a side effect since this method's javadoc only refers its use for speed optimization. Otherwise, the javadoc should be updated to reflect this important feature. As such, I think there should be update() and refresh() methods accepting elements or treepaths, in the same way there is add(Object parentElementOrTreePath, ...) and remove(Object[] elementsOrTreePaths). Also, having an update(Object[] elementsOrTreePaths) would improve the speed of finding the right internal widget when TreePaths are given. Having these new methods (or revising the current ones) would also make the API more consistent than it is now. (this issue was recently discussed in news://news.eclipse.org:119/ghokuc$hal$1@build.eclipse.org)
Do you have a suggestion how the Javadoc should be changed?
I suggest the following javadoc: --------------- Configures whether this structured viewer uses an internal hash table to speed up the mapping between elements and SWT items. This must be called before the viewer is given an input (via setInput). Note: when using an ITreePathContentProvider with a TreeViewer, the internal hash table should be enabled to support the update and refresh of multiple occurrences of the same domain objects in the viewer. --------------- Regard that I'm not aware of other uses of an internal hash table. However, if they exist, they should be documented too.
I decided to instead copy the following paragraph from AbstractTreeViewer into the JavaDoc for TreeViewer as well: * <p> * As of 3.2, TreeViewer supports multiple equal elements (each with a * different parent chain) in the tree. This support requires that clients * enable the element map by calling <code>setUseHashLookup(true)</code>. * </p> Would you have found this if it had been on TreeViewer (and not just the superclass)?
Maybe, but to be sure, this feature should also be documented in the javadoc for setUseHashLookup() and ITreePathContentProvider.
Verified that text from the comment 3 appears in the build I20090129-0100 (both help and source Javadoc).