Smooth updating treeviewer with DeferredTreeContentManager [message #740182] |
Tue, 18 October 2011 04:38  |
Eclipse User |
|
|
|
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 #749440 is a reply to message #748791] |
Tue, 25 October 2011 04:14  |
Eclipse User |
|
|
|
I am currently passing objects back to the collector one by one, so that it slowly updates the tree. This works but I'm somewhat concerned that a user might get confused. If you open a large directory as before you get the "pending..." file and then the contents slowly appears. If you scroll down the treeview so that the "pending..." is no longer visible the user doesn't really know that the directory hasn't finished expanding.
The only visual clue that it has finished is when the "pending..." item disappears.
I'm somewhat surprised this hasn't been noticed before.
Looking around at some examples and I have noticed this:
wiki.eclipse.org/JFaceSnippets#Snippet047VirtualLazyTreeViewer
If I add 15000 nodes to it and expand an item it briefly pauses and renders all items without trearing the view. I don't yet know why, but I suspect it's because of the use of a virtual tree. I will try this and see how it works out.
The only other thing I think it could be would be the custom icons, but I will try removing those after attempting the virtual tree.
|
|
|
Powered by
FUDForum. Page generated in 0.05204 seconds