Bug 258736 - [Viewers] [JFace] setUseHashLookUp() and multiple occurrences of same domain object in TreeViewer
Summary: [Viewers] [JFace] setUseHashLookUp() and multiple occurrences of same domain ...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4.1   Edit
Hardware: PC Windows Vista
: P3 enhancement (vote)
Target Milestone: 3.5 M5   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2008-12-13 12:35 EST by Mário Guimarães CLA
Modified: 2009-01-30 09:51 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mário Guimarães CLA 2008-12-13 12:35:08 EST
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)
Comment 1 Boris Bokowski CLA 2008-12-16 22:35:30 EST
Do you have a suggestion how the Javadoc should be changed?
Comment 2 Mário Guimarães CLA 2008-12-17 05:32:18 EST
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.
Comment 3 Boris Bokowski CLA 2009-01-21 15:12:24 EST
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)?
Comment 4 Mário Guimarães CLA 2009-01-22 04:36:13 EST
Maybe, but to be sure, this feature should also be documented in the javadoc for setUseHashLookup() and ITreePathContentProvider.
Comment 5 Oleg Besedin CLA 2009-01-30 09:51:54 EST
Verified that text from the comment 3 appears in the build  I20090129-0100 (both help and source Javadoc).