Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Smooth updating treeviewer with DeferredTreeContentManager
Smooth updating treeviewer with DeferredTreeContentManager [message #740182] Tue, 18 October 2011 08:38 Go to next message
gary.stoneman is currently offline gary.stonemanFriend
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 Go to previous messageGo to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 217
Registered: July 2009
Senior Member
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 #747714 is a reply to message #742527] Mon, 24 October 2011 08:37 Go to previous messageGo to next message
gary.stoneman is currently offline gary.stonemanFriend
Messages: 5
Registered: October 2011
Junior Member
When I edit my code to this:
List<LocalDirInfo> dirs = filesystem.GetChildDirectories(parent.getFULL_NAME(), parent);
List<LocalDirInfo> files = filesystem.GetChildFiles(parent.getFULL_NAME(), parent);
dirs.addAll(files);
Object[] a = dirs.toArray();
collector.add(a, monitor);

This is getting all my directories, then all my files and adding them to the same ArrayList. I then turn this into an array and pass this to the collector.

Below is a link to a video which shows my problem. When the "System32" folder is expanded there is a pause while the data is collected (whilst we fetch the directories and files). Then we start to populate the tree. However, there is a horrible 'tearing' effect which you can clearly see in the video.

www.youtube.com/watch?v=Mc5miJvW-eY

The SysWOW64 directory just under the System32 directory remains in place but the rest of the directories get torn out of view whilst the treeview is populated. This looks pretty terrible. Is there anything I can do to avoid this?

Thanks
Re: Smooth updating treeviewer with DeferredTreeContentManager [message #748791 is a reply to message #747714] Mon, 24 October 2011 22:32 Go to previous messageGo to next message
Craig Foote is currently offline Craig FooteFriend
Messages: 217
Registered: July 2009
Senior Member
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
Re: Smooth updating treeviewer with DeferredTreeContentManager [message #749440 is a reply to message #748791] Tue, 25 October 2011 08:14 Go to previous message
gary.stoneman is currently offline gary.stonemanFriend
Messages: 5
Registered: October 2011
Junior Member
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.
Previous Topic:2 different Celleditors
Next Topic:Menumanager setVisible doesn't work as expected
Goto Forum:
  


Current Time: Fri Mar 29 05:51:58 GMT 2024

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

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

Back to the top