Animated GIF in TableViewer

I‘m quite attached to TableViewer and the nice separation between UI and data so I tend to use it pretty much every time I can. However when faced with having to indicate progress in a table row I got into trouble. If the table was implemented just in SWT it would not be much of a problem as you get pretty much full control. It’s not that easy when using a JFace. I decided to hook into the label provider and use an animated image to indicate progress. It proved to be a nice solution so I’ve exemplified it for your enjoyment. Note that the housekeeping is very much left out in order to keep the code short.

The pretty GIF was lifted off

First we have the data class. It’s simply represent a person and whether or not that person is busy.

We use the SWT.VIRTUAL flag on the table in order to make sure we’re notified whenever new data is added to the viewer. When this happens we store the table item to a list. The GIF is loaded from a file and we store the information in two arrays. One for the images and another for the delays between images. The job is done by a thread that will update the image of each table item that represents a busy person.


  1. It's not really needed to use SWT.Virtual. If you'd use the new CellLabelProvider-Infrastructure you get access to ViewerCell which has access to a ViewerRow which abstracts TableItem/TreeItem/GridItem/…

  2. When your GUI thread is busy all your spinners will be frozen. Unfortunately there is no solution for that. Only to create a separate thread without access to UI(I mean widgets) where you will be updating the progress. But for example it works nice 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.