} int [] property = new int [1]; OS.GetDataBrowserSortProperty (handle, property); if (property [0] != 0) { for (int i = 0; i < columnCount; i++) { TreeColumn column = columns [i]; if (property [0] == column.id) { column.postEvent (clickCount [0] == 2 ? SWT.DefaultSelection : SWT.Selection); break; } } OS.SetDataBrowserSortProperty (handle, 0);
int itemNotificationProc (int browser, int id, int message) {	if (message == OS.kDataBrowserUserStateChanged) {		short [] width = new short [1];		TreeColumn [] newColumns = getColumns ();		for (int i = 0; i < columnCount; i++) {			TreeColumn column = newColumns [i];			if (!column.isDisposed ()) {				OS.GetDataBrowserTableViewNamedColumnWidth (handle, column.id, width);				if (width [0] != column.lastWidth) {					column.resized (width [0]);					return OS.noErr;				}			}		}		return OS.noErr;	}	int index = id - 1;	if (!(0 <= index && index < items.length)) return OS.noErr;	TreeItem item = items [index];	switch (message) {		case OS.kDataBrowserItemSelected:		case OS.kDataBrowserItemDeselected: {			wasSelected = true;			if (ignoreSelect) break;			int [] first = new int [1], last = new int [1];			OS.GetDataBrowserSelectionAnchor (handle, first, last);			boolean selected = false;			if ((style & SWT.MULTI) != 0) {				int modifiers = OS.GetCurrentEventKeyModifiers ();				if ((modifiers & OS.shiftKey) != 0) {					if (message == OS.kDataBrowserItemSelected) {						selected = first [0] == id || last [0] == id;					} else {						selected = id == anchorFirst || id == anchorLast;					}				} else {					if ((modifiers & OS.cmdKey) != 0) {						selected = true;					} else {						selected = first [0] == last [0];					}				}			} else {				selected = message == OS.kDataBrowserItemSelected;			}			if (selected) {				anchorFirst = first [0];				anchorLast = last [0];				Event event = new Event ();				event.item = item;				postEvent (SWT.Selection, event);			}			break;		}			case OS.kDataBrowserItemDoubleClicked: {			wasSelected = true;			Event event = new Event ();			event.item = item;			postEvent (SWT.DefaultSelection, event);			break;		}		case OS.kDataBrowserContainerClosing: {			/*			* Bug in the Macintosh.  For some reason, if the selected sub items of an item			* get a kDataBrowserItemDeselected notificaton when the item is collapsed, a			* call to GetDataBrowserSelectionAnchor () will cause a segment fault.  The			* fix is to deselect these items ignoring kDataBrowserItemDeselected and then			* issue a selection event.			*/			int ptr = OS.NewHandle (0);			if (OS.GetDataBrowserItems (handle, item.id, true, OS.kDataBrowserItemIsSelected, ptr) == OS.noErr) {				int count = OS.GetHandleSize (ptr) / 4;				if (count > 0) {					int [] ids = new int [count];					OS.HLock (ptr);					int [] start = new int [1];					OS.memcpy (start, ptr, 4);					OS.memcpy (ids, start [0], count * 4);					OS.HUnlock (ptr);					ignoreSelect = true;					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, ids.length, ids, OS.kDataBrowserItemsRemove);					if ((style & SWT.SINGLE) != 0) {						OS.SetDataBrowserSelectionFlags (handle, selectionFlags [0]);					}					ignoreSelect = false;					Event event = new Event ();					event.item = item;					sendEvent (SWT.Selection, event);				}			}			OS.DisposeHandle (ptr);			break;		}		case OS.kDataBrowserContainerClosed: {			wasExpanded = true;			if (!ignoreExpand) {				Event event = new Event ();				event.item = item;				sendEvent (SWT.Collapse, event);			}			setScrollWidth ();			break;		}		case OS.kDataBrowserContainerOpened: {			wasExpanded = true;			if (!ignoreExpand) {				Event event = new Event ();				event.item = item;				try {					item.state |= EXPANDING;					sendEvent (SWT.Expand, event);				} finally {					item.state &= ~EXPANDING;				}			}			int count = 0;			for (int i=0; i<items.length; i++) {				if (items [i] != null && items [i].parentItem == item) count++;			}			TreeItem [] newItems = new TreeItem [count];			int [] ids = new int [count];			for (int i=0; i<items.length; i++) {				if (items [i] != null && items [i].parentItem == item) {					ids [items [i].index] = items [i].id;					newItems [items [i].index] = items [i];				}			}			OS.AddDataBrowserItems (handle, id, ids.length, ids, OS.kDataBrowserItemNoProperty);			setScrollWidth (newItems, false);			break;		}	}	return OS.noErr;}