Bug 159918 [Viewers] TreeViewer.setChildCount(...) should preserve selection
Since changing the child count of an element in a tree can effectively remove children, the #setChildCount(...) method should preserve selection. This way if a selected item is disposed, the selection change will fire with the new <empty selection>.
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java
Widget[] items = findItems(element);
		for (int i = 0; i < items.length; i++) {
			TreeItem treeItem = (TreeItem) items[i];
			treeItem.setItemCount(count);
		}
	}
	/**
	 * For a TreeViewer with a tree with the VIRTUAL style bit set, replace the
	 * given parent's child at index with the given element. If the given parent
	 * is this viewer's input, this will replace the root element at the given
	 * index.
	 * <p>
	 * This method should be called by implementers of ILazyTreeContentProvider
	 * to populate this viewer.
	 * </p>
	 * 
	 * @param parent
	 *            the parent of the element that should be updated
	 * @param index
	 *            the index in the parent's children
	 * @param element
	 *            the new element
	 * 
	 * @see #setChildCount(Object, int)
	 * @see ILazyTreeContentProvider
	 * 
	 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
	 * part of a work in progress. There is no guarantee that this API will
	 * remain unchanged during the 3.2 release cycle. Please do not use this API
	 * without consulting with the Platform/UI team.