Smooth updating treeviewer with DeferredTreeContentManager [message #740182] |
Tue, 18 October 2011 08:38 |
gary.stoneman Messages: 5 Registered: October 2011 |
Junior Member |
|
|
I'm currently making what is essentially a local file system browser. It is a treeviewer using a content provider that uses a DeferredTreeContentManager.
It currently is all working, with directories that have a lot of files (c:\windows\system32 for example) slowly drawing.
The problem I have is with the way the treeviewer update the view to the user. Currently when you open a directory with a lot of files it shows this:
Windows
System32
Pending...
Whilst we defer the work to get the contents. But as the contents is returned the directory tree in the gui is populated one by one like this:
Windows
System32
Pending...
AdvancedInstallers
What I really want to happen is for the treeviewer to show Pending... until all items have been loaded, then show them all at once and not to slowly grow the contents.
My code for getting the file system looks like this:
List<LocalDirInfo> dirs = filesystem.GetChildDirectories(parent.getFULL_NAME(), parent);
List<LocalDirInfo> files = filesystem.GetChildFiles(parent.getFULL_NAME(), parent);
for (LocalDirInfo file : dirs) {
collector.add(file, monitor);
monitor.worked(1);
}
for (LocalDirInfo file : files) {
collector.add(file, monitor);
monitor.worked(1);
}
So I understand that this will return one directory (or file) at a time and cause the tree to update. This is why I see the tree slowly populate in the GUI.
However if I change it to this:
dirs.addAll(files);
Object[] a = dirs.toArray();
collector.add(a, monitor);
so that all the directories and files are added to one array, then pass this to the collector it should tell the treeview to update the GUI in one go. This causes horrible tearing in the GUI as it tries to populate all the members at once.
How do I get my treeviewer to display a large directory smoothly like windows explorer does. If I open c:\windows\system32 there is a slight pause after click expand, then all the items are populate at once with no tearing.
Does anyone have any experience with this and DeferredTreeContentManager?
Thanks
|
|
|
Re: Smooth updating treeviewer with DeferredTreeContentManager [message #742527 is a reply to message #740182] |
Thu, 20 October 2011 15:17 |
|
If you're fetching children in DeferredWorkbenchAdapter#fetchDeferredChildren, fetch all the children first then pass them all to the collector. The collector will insert nodes into the tree as it receives them so if you fetch an item one at a time and pass each to the collector as you get them, they appear one by one. The "Pending..." node will disappear after your call to monitor#done at the end of #fetchDeferredChildren. Passing the collector the whole list at once should cause them to appear all at once and the "Pending..." node then removed.
|
|
|
|
Re: Smooth updating treeviewer with DeferredTreeContentManager [message #748791 is a reply to message #747714] |
Mon, 24 October 2011 22:32 |
|
I see now what you mean. I believe the display would look better if the child nodes were passed to the collector one at a time rather than the whole list. It seems their sheer number is taking a long time to add to the tree, all on the drawing thread. Adding them one at a time would populate the subtree more smoothly. Adding them all at once might be better if there were just a few children. We populate our tree one at a time because certain children may take longer than others to fetch and our users can interact with the nodes as soon as they become visible, even as other children are added.
Craig
|
|
|
|
Powered by
FUDForum. Page generated in 0.03521 seconds