I have a TableViewer component in my RWT 2.2.0 application which represents a matrix of values over time (columns) and products (rows). The tableviewer is in virtual/lazy mode and the items are just in an ArrayList set via setInput and setItemCount.
Some cells need to be colored in case the value they contain is negative. The user has additional control to change the starting date of the view. In this case, I repopulate the table with the new data, I call refresh() and in the CellLabelProvider.update() method populates the values and if necessary, sets the color of the cell ViewerCell.setForeground(color) or ViewerCell.setForeground(null) to for the default.
Sometimes, especially under IE 9, when the above time-paging happens, cell text updates but cell color remains the same until the user scrolls away (probably far enough so the lazy loading clears it internal row cache).
If I forcibly setItemCount(0) before setItemCount(actual) instead of refresh, the effect goes away, but so does the scroll position and selection which makes the table jump back and forth.
Is this an RWT bug, do I forget to call something or I misunderstand how ViewerCell.setForeground(null) works?
This is most likely a bug in RWT. But before reporting a bug, please try to run your code with the latest version of RWT (currently 2.3.1 stable and/or 3.0 M3 development).
If you need to work around the issue in the meanwhile, you can preserve the selection while resetting the item count: