TreeViewer - selecting duplicate elements [message #526993] |
Tue, 13 April 2010 16:11 |
Raajesh B.Kashyap Messages: 7 Registered: July 2009 |
Junior Member |
|
|
We have an issue with the treeviewer where we need to programmatically select nodes in the tree, including duplicate objects (for example, the same object appearing under two different folders, and both the nodes need to be selected). When trying to do this with the available API, I find that only one of the nodes get selected and the duplicate object node is not selected.
There are two methods available to find the TreeItem widgets:
testFindItem
testFindItems
(although the API documentation says these are hooks for testing, they are public API and are the only available ones to find the tree item widget corresponding to the domain object). The "testFindItems" API internally uses findItems() which is supposed to find duplicates as well, but that still finds only one object (reason below).
Our treeviewer uses the internal map to speed up the processing (using the setUseHashlookup() API available on the treeviewer). When debugging, I find that the internal map always contains only one TreeItem corresponding to the object and not the TreeItem objects corresponding to the duplicates. This is possibly because the custom hash table that the internal map is made up of does not allow duplicates. If this is the case, how would it ever be able to find duplicate element nodes?
In StructuredViewer "testFindItems" method, the following code can be found:
// if we have an element map use it, otherwise search for the item.
if (usingElementMap()) {
Object widgetOrWidgets = elementMap.get(element);
However, this always returns only one TreeItem even if there are duplicate objects being actually displayed in the tree. Looking at the "elementMap" in the debugger, it is clear that the map contains only one TreeItem corresponding to the object. Is this a bug in the implementation, or am I missing something?
The alternative that we have is to get to the SWT tree from the treeviewer, and recursively search through the tree items, but we have had performance issues with this approach in the past since our tree can contain 5,000 to 10,000 nodes at times, which is why we use the "testFindItem" API to speed up the search.
Any suggestions on how to accomplish this without affecting performance, or any alternative mechanism to achieve this? We are using Eclipse 3.5.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03138 seconds