Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TreeViewer - selecting duplicate elements
TreeViewer - selecting duplicate elements [message #526993] Tue, 13 April 2010 16:11 Go to next message
Raajesh  B.Kashyap is currently offline Raajesh B.KashyapFriend
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.

Re: TreeViewer - selecting duplicate elements [message #733734 is a reply to message #526993] Wed, 05 October 2011 14:37 Go to previous message
Santhosh Hari is currently offline Santhosh HariFriend
Messages: 21
Registered: March 2010
Junior Member
Is the problem got resolved ? I m facing the same issue.Do you have any work around for this.
Previous Topic:binding Javabeans to TreeViewer
Next Topic:Extend ElementListSeletionDialog
Goto Forum:
  


Current Time: Fri Apr 26 14:54:21 GMT 2024

Powered by FUDForum. Page generated in 0.03138 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top