Last weeks I played for the first time with JFace’s viewers (
TreeViewer). It was really easy to integrate my first viewers inside my own Eclipse views.
All was working fine when I started to encounter performances problems when setting inputs containing thousands of entries (several seconds for ~50.000 rows in a
A quick look on Google pointed me to
LAZY content providers and
SWT.VIRTUAL in order to improve performances. Before going further with these content providers we have to identify bottle necks. When working with JFace’s viewers there is potentially 2 bottle necks:
- The retrieval of all the model objects from the viewer’s input (it’s the content provider’s job).
- The creation of UI elements.
As Tom Schindl said here (Snippet 29): “The bottle neck is often the UI and not the model“.
I checked the time consumed in my content provider to retrieve viewer’s entries. Only few milliseconds. My bottle neck is the UI !!
To solve this performances problem I just added the
SWT.VIRTUAL style when creating my
TableViewer. Creating the viewer this way tells JFace to create the SWT
's TableItem objects on an on demand basis.
TableItem objects are created only when they become visible (when the user scroll for example). As a conclusion, all I had to do to solve my performances problem is to set this magic style:
SWT.VIRTUAL. It’s so easy to work with Eclipse !!!!! Isn’t it ??
Next i tried the same solution with
TreeViewer. Unfortunately it didn’t worked. I had to use the
SWT.VIRTUAL style WITH an
ILazyTreeContentProvider in order to increase my performances as in
TableViewer. It’s fine but this solution has one drawback: Sorting and Filtering are no longer available when using
Someone told me on the Eclipse Platform newsgroup that the request to support
SWT.VIRTUAL style and sorting and filtering for
TreeViewer is already in the “pipe” but i can’t find such a request on Eclipse bugzilla. If someone can tell me more on that …