Blinking background rows of TableViewer or TreeViewer in SWT
eclipse-rcp, java, swt
Solution
I would do something similar to this. Update the elements that you need to change the colors for at a regular interval. At each update toggle the colors depending on how you want them to flash.
void scheduleColorChange(final Color colors[], final int startIndex, final int changeInterval)
{
getDisplay().timerExec(changeInterval, new Runnable()
{
public void run()
{
Object[] elements = getColorChangingElements();
setColorsForFlashingElements(elements, colors[index%colors.length]);
getViewer().update(elements);
scheduleColorChange(colors, startIndex+1, changeInterval)
}
});
}
and the have you label provider implement IColorProvider.
Problem
I need the ability to have a blinking (red, maybe more colors) background for rows in a TableViewer/TreeViewer. What are the best options? There may be more than one row blinking, the blinking MUST be synchron and I need two blinking modes, fast and slow.