Project: SWT
Bug 129745 Tree displays selected lines in wrong color
Reported: 2006-02-28 04:56:34 | Status: resolved fixed

sun sdk 1.5.0_05, swt from eclipse 3.2M5. In Tree, select several multiple rows (blue color), press another control (button in my example), tree loses focus and rows are painted in gray color. Further, try to add rows to selection (as I do, press Ctrl + mouse key on tree). Only the last one selected row and newly selected row will be repainted in green, other rows will remain in gray. Using: org.eclipse.equinox.common_1.0.0.v20060215a.jar org.eclipse.jface_3.2.0I20060216-1600.jar org.eclipse.swt_3.2.0.v3224m.jar org.eclipse.swt.win32.win32.x86_3.2.0.v3224.jar org.eclipse.core.commands_3.2.0.v3224m.jar Example attached: import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; public class TestTreeProvider implements ITreeContentProvider, IStructuredContentProvider { Integer[] level1 = new Integer[] { 1, 2 }; String[] level2 = new String[] { "a", "b", "c", "d", "e" }; public Object[] getElements(Object inputElement) { return level1; } public Object[] getChildren(Object parentElement) { if (parentElement instanceof Integer) { return level2; } else return null; } public Object getParent(Object element) { return null; } public boolean hasChildren(Object element) { return (element instanceof Integer); } public void dispose() {} public void inputChanged(Viewer v, Object a, Object b) {} } import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class Test { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); TreeViewer tv = new TreeViewer(shell, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL); TestTreeProvider ttp = new TestTreeProvider(); tv.setContentProvider(ttp); tv.setInput(""); Button b = new Button(shell, SWT.PUSH); b.setText("simply press"); shell.pack(); shell.setSize(400, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java