if (length > 0 && items [0] != null) showItem (items [0], true);
if (length > 0) { int index = -1; for (int i=0; i<items.length; i++) { if (items [i] != null) { index = i; break; } } if (index != -1) showItem (items [index], true); }
public void setSelection (TreeItem [] items) {	checkWidget ();	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);	deselectAll ();	int length = items.length;	if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;	int count = 0;	int[] ids = new int [length];	for (int i=0; i<length; i++) {		if (items [i] != null) {			if (items [i].isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);			ids [count++] = items [i].id;			showItem (items [i], false);		}	}	ignoreSelect = true;	/*	* Bug in the Macintosh.  When the DataBroswer selection flags includes	* both kDataBrowserNeverEmptySelectionSet and kDataBrowserSelectOnlyOne,    * two items are selected when SetDataBrowserSelectedItems() is called    * with kDataBrowserItemsAssign to assign a new seletion despite the fact	* that kDataBrowserSelectOnlyOne was specified.  The fix is to save and	* restore kDataBrowserNeverEmptySelectionSet around each call to	* SetDataBrowserSelectedItems().	*/	int [] selectionFlags = null;	if ((style & SWT.SINGLE) != 0) {		selectionFlags = new int [1];		OS.GetDataBrowserSelectionFlags (handle, selectionFlags);		OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0] & ~OS.kDataBrowserNeverEmptySelectionSet);	}	OS.SetDataBrowserSelectedItems (handle, count, ids, OS.kDataBrowserItemsAssign);	if ((style & SWT.SINGLE) != 0) {		OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0]);	}	ignoreSelect = false;	if (length > 0 && items [0] != null) showItem (items [0], true);}