View | Details | Raw Unified | Return to bug 261854
Collapse All | Expand All

(-)Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java (-21 / +41 lines)
Lines 83-89 Link Here
83
	int columnCount;
83
	int columnCount;
84
	int sortDirection;
84
	int sortDirection;
85
	float /*double*/ levelIndent;
85
	float /*double*/ levelIndent;
86
	boolean ignoreExpand, ignoreSelect;
86
	boolean ignoreExpand, ignoreSelect, reloadPending;
87
87
88
/**
88
/**
89
 * Constructs a new instance of this class given its parent
89
 * Constructs a new instance of this class given its parent
Lines 262-267 Link Here
262
	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
262
	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
263
}
263
}
264
264
265
void checkItems () {
266
	if (!reloadPending) return;
267
	reloadPending = false;
268
	((NSOutlineView)view).reloadItem (null);
269
}
270
265
void clear (TreeItem parentItem, int index, boolean all) {
271
void clear (TreeItem parentItem, int index, boolean all) {
266
	TreeItem item = _getItem (parentItem, index, false);
272
	TreeItem item = _getItem (parentItem, index, false);
267
	if (item != null) {
273
	if (item != null) {
Lines 578-585 Link Here
578
		this.itemCount = count;
584
		this.itemCount = count;
579
	}
585
	}
580
	ignoreExpand = true;
586
	ignoreExpand = true;
581
	NSOutlineView widget = (NSOutlineView)view;
587
	reloadItem (parentItem, true);
582
	widget.reloadItem(parentItem != null ? parentItem.handle : null, true);
583
	ignoreExpand = false;
588
	ignoreExpand = false;
584
}
589
}
585
590
Lines 778-789 Link Here
778
	if (parentItem != null) {
783
	if (parentItem != null) {
779
		parentItem.itemCount = count;
784
		parentItem.itemCount = count;
780
		if (count == 0) parentItem.expanded = false;
785
		if (count == 0) parentItem.expanded = false;
781
		((NSOutlineView) view).reloadItem (parentItem.handle, true);
782
	} else {
786
	} else {
783
		this.itemCount = count;
787
		this.itemCount = count;
784
		((NSOutlineView) view).reloadItem (null);
785
	}
788
	}
786
	
789
	reloadItem (parentItem, true);
787
//	setScrollWidth (true);
790
//	setScrollWidth (true);
788
//	fixScrollBar ();
791
//	fixScrollBar ();
789
}
792
}
Lines 1281-1286 Link Here
1281
public TreeItem getItem (Point point) {
1284
public TreeItem getItem (Point point) {
1282
	checkWidget ();
1285
	checkWidget ();
1283
	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
1286
	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
1287
	checkItems ();
1284
	NSOutlineView widget = (NSOutlineView)view;
1288
	NSOutlineView widget = (NSOutlineView)view;
1285
	NSPoint pt = new NSPoint();
1289
	NSPoint pt = new NSPoint();
1286
	pt.x = point.x;
1290
	pt.x = point.x;
Lines 1511-1529 Link Here
1511
 */
1515
 */
1512
public TreeItem getTopItem () {
1516
public TreeItem getTopItem () {
1513
	checkWidget ();
1517
	checkWidget ();
1514
//	//TODO - optimize
1518
	//TODO - partial item at the top
1515
//	Rect rect = new Rect ();
1519
	NSRect rect = scrollView.documentVisibleRect ();
1516
//	int y = getBorder () + getHeaderHeight ();
1520
	NSPoint point = new NSPoint ();
1517
//	for (int i=0; i<items.length; i++) {
1521
	point.x = rect.x;
1518
//		TreeItem item = items [i];
1522
	point.y = rect.y;
1519
//		if (item != null) {
1523
	NSOutlineView outlineView = (NSOutlineView)view;
1520
//			int columnId = (columnCount == 0) ? column_id : columns [0].id;
1524
	int /*long*/ index = outlineView.rowAtPoint (point);
1521
//			if (OS.GetDataBrowserItemPartBounds (handle, item.id, columnId, OS.kDataBrowserPropertyEnclosingPart, rect) == OS.noErr) {
1525
	if (index == -1) return null; /* empty */
1522
//				if (rect.top <= y && y <= rect.bottom) return item;
1526
	id item = outlineView.itemAtRow (index);
1523
//			}
1527
	return (TreeItem)display.getWidget (item.id);
1524
//		}
1525
//	}
1526
	return null;
1527
}
1528
}
1528
1529
1529
void highlightSelectionInClipRect(int /*long*/ id, int /*long*/ sel, int /*long*/ rect) {
1530
void highlightSelectionInClipRect(int /*long*/ id, int /*long*/ sel, int /*long*/ rect) {
Lines 1880-1885 Link Here
1880
	sortColumn = null;
1881
	sortColumn = null;
1881
}
1882
}
1882
1883
1884
void reloadItem (TreeItem item, boolean recurse) {
1885
	if (drawCount == 0) {
1886
		NSOutlineView widget = (NSOutlineView)view;
1887
		if (item != null) {
1888
			widget.reloadItem (item.handle, recurse);
1889
		} else {
1890
			widget.reloadItem (null);
1891
		}
1892
	} else {
1893
		reloadPending = true;
1894
	}
1895
}
1896
1883
/**
1897
/**
1884
 * Removes all of the items from the receiver.
1898
 * Removes all of the items from the receiver.
1885
 * 
1899
 * 
Lines 1986-1991 Link Here
1986
public void selectAll () {
2000
public void selectAll () {
1987
	checkWidget ();
2001
	checkWidget ();
1988
	if ((style & SWT.SINGLE) != 0) return;
2002
	if ((style & SWT.SINGLE) != 0) return;
2003
	checkItems ();
1989
	NSOutlineView widget = (NSOutlineView) view;
2004
	NSOutlineView widget = (NSOutlineView) view;
1990
	ignoreSelect = true;
2005
	ignoreSelect = true;
1991
	widget.selectAll (null);
2006
	widget.selectAll (null);
Lines 2013-2018 Link Here
2013
	checkWidget ();
2028
	checkWidget ();
2014
	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
2029
	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
2015
	if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
2030
	if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
2031
	checkItems ();
2016
	showItem (item);
2032
	showItem (item);
2017
	NSOutlineView outlineView = (NSOutlineView) view;
2033
	NSOutlineView outlineView = (NSOutlineView) view;
2018
	int /*long*/ row = outlineView.rowForItem (item.handle);
2034
	int /*long*/ row = outlineView.rowForItem (item.handle);
Lines 2171-2181 Link Here
2171
 */
2187
 */
2172
public void setItemCount (int count) {
2188
public void setItemCount (int count) {
2173
	checkWidget ();
2189
	checkWidget ();
2190
	checkItems ();
2174
	count = Math.max (0, count);
2191
	count = Math.max (0, count);
2175
	setItemCount (null, count);
2192
	setItemCount (null, count);
2176
}
2193
}
2177
2194
2178
2179
void setItemCount (TreeItem parentItem, int count) {
2195
void setItemCount (TreeItem parentItem, int count) {
2180
	int itemCount = getItemCount (parentItem);
2196
	int itemCount = getItemCount (parentItem);
2181
	if (count == itemCount) return;
2197
	if (count == itemCount) return;
Lines 2291-2296 Link Here
2291
	checkWidget ();
2307
	checkWidget ();
2292
	super.setRedraw (redraw);
2308
	super.setRedraw (redraw);
2293
	if (redraw && drawCount == 0) {
2309
	if (redraw && drawCount == 0) {
2310
		checkItems ();
2294
		setScrollWidth ();
2311
		setScrollWidth ();
2295
	}
2312
	}
2296
}
2313
}
Lines 2384-2389 Link Here
2384
public void setSelection (TreeItem [] items) {
2401
public void setSelection (TreeItem [] items) {
2385
	checkWidget ();
2402
	checkWidget ();
2386
	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
2403
	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
2404
	checkItems ();
2387
	deselectAll ();
2405
	deselectAll ();
2388
	int length = items.length;
2406
	int length = items.length;
2389
	if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;
2407
	if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;
Lines 2500-2505 Link Here
2500
	checkWidget();
2518
	checkWidget();
2501
	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
2519
	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
2502
	if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
2520
	if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
2521
	checkItems ();
2503
	showItem (item, false);
2522
	showItem (item, false);
2504
	NSOutlineView outlineView = (NSOutlineView) view;
2523
	NSOutlineView outlineView = (NSOutlineView) view;
2505
	//FIXME
2524
	//FIXME
Lines 2557-2562 Link Here
2557
	checkWidget ();
2576
	checkWidget ();
2558
	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
2577
	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
2559
	if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
2578
	if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
2579
	checkItems ();
2560
	showItem (item, true);
2580
	showItem (item, true);
2561
}
2581
}
2562
2582
Lines 2586-2592 Link Here
2586
 */
2606
 */
2587
public void showSelection () {
2607
public void showSelection () {
2588
	checkWidget ();
2608
	checkWidget ();
2589
	//checkItems (false);
2609
	checkItems ();
2590
	//TODO - optimize
2610
	//TODO - optimize
2591
	TreeItem [] selection = getSelection ();
2611
	TreeItem [] selection = getSelection ();
2592
	if (selection.length > 0) showItem (selection [0], true);
2612
	if (selection.length > 0) showItem (selection [0], true);
(-)Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java (+4 lines)
Lines 495-500 Link Here
495
public Rectangle getBounds () {
495
public Rectangle getBounds () {
496
	checkWidget ();
496
	checkWidget ();
497
	if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
497
	if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
498
	parent.checkItems ();
498
	NSOutlineView outlineView = (NSOutlineView) parent.view;
499
	NSOutlineView outlineView = (NSOutlineView) parent.view;
499
	NSRect rect = outlineView.rectOfRow (outlineView.rowForItem (handle));
500
	NSRect rect = outlineView.rectOfRow (outlineView.rowForItem (handle));
500
	return new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height);
501
	return new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height);
Lines 519-524 Link Here
519
	if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
520
	if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
520
	if (!(0 <= index && index < Math.max (1, parent.columnCount))) return new Rectangle (0, 0, 0, 0);
521
	if (!(0 <= index && index < Math.max (1, parent.columnCount))) return new Rectangle (0, 0, 0, 0);
521
522
523
	parent.checkItems ();
522
	NSOutlineView outlineView = (NSOutlineView) parent.view;
524
	NSOutlineView outlineView = (NSOutlineView) parent.view;
523
	if (parent.columnCount == 0) {
525
	if (parent.columnCount == 0) {
524
		index = (parent.style & SWT.CHECK) != 0 ? 1 : 0;
526
		index = (parent.style & SWT.CHECK) != 0 ? 1 : 0;
Lines 720-725 Link Here
720
	if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
722
	if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
721
	if (!(0 <= index && index < Math.max (1, parent.columnCount))) return new Rectangle (0, 0, 0, 0);
723
	if (!(0 <= index && index < Math.max (1, parent.columnCount))) return new Rectangle (0, 0, 0, 0);
722
724
725
	parent.checkItems ();
723
	NSOutlineView outlineView = (NSOutlineView) parent.view;
726
	NSOutlineView outlineView = (NSOutlineView) parent.view;
724
	Image image = index == 0 ? this.image : (images != null) ? images [index] : null;
727
	Image image = index == 0 ? this.image : (images != null) ? images [index] : null;
725
	if (parent.columnCount == 0) {
728
	if (parent.columnCount == 0) {
Lines 894-899 Link Here
894
	if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
897
	if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
895
	if (!(0 <= index && index < Math.max (1, parent.columnCount))) return new Rectangle (0, 0, 0, 0);
898
	if (!(0 <= index && index < Math.max (1, parent.columnCount))) return new Rectangle (0, 0, 0, 0);
896
899
900
	parent.checkItems ();
897
	NSOutlineView outlineView = (NSOutlineView) parent.view;
901
	NSOutlineView outlineView = (NSOutlineView) parent.view;
898
	Image image = index == 0 ? this.image : (images != null) ? images [index] : null;
902
	Image image = index == 0 ? this.image : (images != null) ? images [index] : null;
899
	if (parent.columnCount == 0) {
903
	if (parent.columnCount == 0) {

Return to bug 261854