Bug 546333 - [Win32] test_disposeItemNotTriggerSelection JUnit test
failing. Windows notifies the parent Widget (the Tree) about the deleted
item. This event is dispatched to the last control with the last event
type, which causes an SelectionEvent for a TreeItem. This case was
already covered for trees with the SWT.MULTI flag, but obviously also
happens for trees with SWT.SINGLE flag.

Change-Id: I66dfbf40041824cb15c40f2d6d26f08069e60751
Signed-off-by: Conrad Groth <info@conrad-groth.de>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
index bb4f2c1..456e338 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -2589,9 +2589,7 @@
 		*/
 //		OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
 	}
-	if ((style & SWT.MULTI) != 0) {
-		ignoreDeselect = ignoreSelect = lockSelection = true;
-	}
+	ignoreDeselect = ignoreSelect = lockSelection = true;
 
 	/*
 	* Feature in Windows.  When an item is deleted and a tool tip
@@ -2609,9 +2607,11 @@
 	shrink = ignoreShrink = true;
 	OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, hItem);
 	ignoreShrink = false;
-	if ((style & SWT.MULTI) != 0) {
-		ignoreDeselect = ignoreSelect = lockSelection = false;
-	}
+	/*
+	 * Bug 546333: When TVGN_CARET item is deleted, Windows automatically
+	 * sets selection to some other item. We do not want that.
+	 */
+	ignoreDeselect = ignoreSelect = lockSelection = false;
 	if (fixRedraw) {
 		OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
 		OS.ValidateRect (handle, null);
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
index 3485390..48bfb9d 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java
@@ -845,14 +845,6 @@
 
 @Test
 public void test_disposeItemNotTriggerSelection() {
-	if (SwtTestUtil.isWindows) {
-		// TODO Fix Windows failure.
-		if (SwtTestUtil.verbose) {
-			System.out
-					.println("Excluded test_disposeItemNotTriggerSelection(org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Tree).");
-		}
-		return;
-	}
 	Display display = shell.getDisplay();
 	shell.setLayout(new FillLayout());
 	Tree tree = new Tree (shell, SWT.BORDER);