Search code examples
swteclipse-rcpjfacetableviewer

How to refresh a TableViewer in Eclipse RCP Application


I’m using JFace viewer Framework in my eclipse rcp application, I’ve created a Table Viewer, which populates some data .My view has a refresh button below tableviewer, when I select a row in tableviewer and trigger refresh button the selected row still appears in gray color.
Scenario is depicted below
Before selecting a row
Before selecting row
After selecting a row
After selecting a row
After refresh
After refresh
In what way can i remove the gray background as in the above figure and make it as 1st image. My refresh button listener code is simple which has

viewer.refresh();

as a workaround i tried implementing methods like

viewer.getTable().redraw();
viewer.getTable().setRedraw(true); 

which doesn't work, is there a solution to refresh it or should I refresh the view totally
Note: My Execution environment is windows xp


Solution

  • That gray line is current, not previous selection. It's gray because table is not in focus. Use setSelection(StructuredSelection.EMPTY).