I am new to eclipse SWT. I am trying to override the getBackground
method of ITableColorProvider
to color rows alternatively of a treeViewer. I was trying coloring with row index (index%2 == 0)
. It colors all the rows instead.
TreeViewer
colors one cell at a time, instead of rows. Any pointers on how to achieve it (alternate row color for treeviewer) or code snippet will be very helpful.
List<TreeItem> treeItems = Arrays.asList( m_viewer.getTree().getItems() );
int index = treeItems.indexOf( element );
if( index % 2 == 0 )
{
backgroundColor = Display.getDefault().getSystemColor(
SWT.COLOR_YELLOW );
}
else
{
backgroundColor = Display.getDefault().getSystemColor(
SWT.COLOR_GRAY );
}