SWT TreeViewer is slow when filling with many elements
I'm new in the java world, so I'm sorry if my question is trivial.
I'm developing a Eclipse view part, and I'm filling a SWT tree view with the following data structure. All data is in memory:
Node1
Child1
Child2
Node2
Child1
...
Child2915
I think that is not a very big tree, but it is slow being drawn (10 seconds). I have manage trees in .NET with more than 10.000 elements and it loaded smoothly. I don't know if I've implemented the code, but the same problem appeared in .NET if I did not call BeginUpdate() - EndUpdate()
.
Must I call someth开发者_JS百科ing similar in Java/SWT? Any other tips about why the tree is so slow?
You could use the SWT.VIRTUAL
flag when creating the Tree to help with the performance
For more information, see this article on Virtual Trees and Tables
This can also be combined with the JFace TreeViewer. See this article on the JFace TreeViewer for more details (although this doesn't specifically mention the virtual flag)
Finally, I used setRedraw(boolean value)
after calling refresh in my TreeViewer.
public void refresh() {
try {
mTreeViewer.getControl().setRedraw(false);
mTreeViewer.refresh(true);
mTreeViewer.expandAll();
}
finally {
mTreeViewer.getControl().setRedraw(true);
}
}
精彩评论