Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 156537

Summary: [Viewers] Virtual tree viewer does not populate with initial children
Product: [Eclipse Project] Platform Reporter: Darin Wright <darin.eclipse>
Component: UIAssignee: Boris Bokowski <bokowski>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bokowski, ivo.abadjiev, tom.schindl
Version: 3.3   
Target Milestone: 3.3 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
sample project
none
modified sample project none

Description Darin Wright CLA 2006-09-07 11:43:19 EDT
I20060830-1650

When a tree viewer is created with the SWT.Vitrual flag and uses an ILazyTreeContentProvider, the viewew does not populate with the initial children in the model. The method TreeViewer.createChildren(Widget) only updates existing items if the parent (root)element has been mapped to data, and does not query the content provider for the number of children it has.

Attached is a sample plug-in showing the problem. The tree "model" looks like this:

root
   one
   two
   three

When the input is set to the viewer ("root") a call is made to "createChildren", but the content provider is never used.
Comment 1 Darin Wright CLA 2006-09-07 11:45:15 EDT
Created attachment 49626 [details]
sample project

Open the "Sample View" to see the problem.
Comment 2 Darin Wright CLA 2006-09-07 11:50:53 EDT
Workaround: If I add a call to "refresh()" the view after setting the input, then the initial children are displayed.
Comment 3 Boris Bokowski CLA 2006-09-11 23:40:15 EDT
Fixed >20060911.
Comment 4 Boris Bokowski CLA 2006-09-11 23:40:34 EDT
Forgot to mark as fixed.
Comment 5 Darin Wright CLA 2006-09-12 10:57:40 EDT
Immediate children of the root appear, but initial children at the second level do not appear. Modified example to populate the model with:

root
   one
     a
     b
     c
   two
   three

When I create the viewer and set the input, only "one, two, three" appear and there is no "+" sign beside "one" as there should be.
Comment 6 Darin Wright CLA 2006-09-12 10:58:11 EDT
Created attachment 49939 [details]
modified sample project
Comment 7 Darin Wright CLA 2006-09-12 11:00:06 EDT
Note: you can  use the context menu to "Refresh 'one'", which makes the "+" appear - but the children are already in the model.
Comment 8 Boris Bokowski CLA 2006-09-12 11:56:30 EDT
I noticed that your content provider does not call TreeViewer.setChildCount().  I believe this is working as designed, but please reopen if I'm wrong. Marking as fixed again.
Comment 9 Ivailo Abadjiev CLA 2006-10-08 11:00:26 EDT
The same behavior with M20060921-0945 (3.2.1)

TreeViewer created with SWT.VIRTUAL flag and set to use ILazyTreeContentProvider does not populate root/input children if "TreeViewer.setChildCount" or "TreeViewer.refresh" is not called after "TreeViewersetInput" is called. The right behavior would be TreeView to call "updateChildCount" of ILazyTreeContentProvider as it is documented for ILazyTreeContentProvider#updateChildCount method.