Bug 183801 - [Viewers] SWT Virtual Tree creates all siblings of each node in TreePath when programmatically setting selection
Summary: [Viewers] SWT Virtual Tree creates all siblings of each node in TreePath when...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2007-04-24 11:02 EDT by Joe Toomey CLA
Modified: 2019-09-06 15:35 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joe Toomey CLA 2007-04-24 11:02:24 EDT
As a side effect of the TreeViewer.setSelection() call, all of the children of each node in the tree path are created.  [This happens in AbstractTreeViewer.internalExpand(Object, boolean):1507 and then in TreeViewer.createChildren(Widget):519.]  This behavior differs from the behavior I would get if I manually expanded each node (where the tree would only create the nodes that would be visible in the viewer.)

I can envision two ways in which this could be improved:

1) In AbstractTreeViewer.setSelectionToWidget(), SWT is walking back up the specified TreePath, recursively exposing the children of each of the parent nodes.  It seems like it should be possible to optimize this traversal to stop expanding each necessary node has been found?  This would still not be perfect, since, if the node in question was at the very end of the tree traversal, we'd still end up constructing almost all of the nodes.  But in our most common cases, the user is navigating to the first element of a given type, and that element may be near the beginning of the traversal.

2) A much more efficient way would be for me to pass you the indices of the nodes in the TreePath instead of objects that you then have to search for.  I can determine the indices in question efficiently, and if I could pass you a path of indices instead of objects (or perhaps in addition to the existing TreePath), I expect you would be able to create only the necessary nodes.  This would be ideal for us.

I was able to work around this by manually forcing the creation of each node in the tree path before setting the selection (thanks for the suggestion, Boris.)
Comment 1 Grant Gayed CLA 2007-04-26 16:48:45 EDT
Moving report to UI since this appears to be a jface issue.  If I'm wrong then please return it to swt.
Comment 2 Boris Bokowski CLA 2008-05-02 14:56:40 EDT
Mass update - removing 3.4 target. This was one of the bugs I marked for investigation (and potential fixing) in 3.4 but I ran out of time. Please ping on the bug if fixing it would be really important for 3.4, and does not require API changes or feature work.
Comment 3 Boris Bokowski CLA 2009-11-26 09:55:37 EST
Hitesh is now responsible for watching bugs in the [Viewers] component area.
Comment 4 Eclipse Webmaster CLA 2019-09-06 15:35:09 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.