### Eclipse Workspace Patch 1.0 #P org.eclipse.swt Index: Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java,v retrieving revision 1.98 diff -u -r1.98 Tree.java --- Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java 15 Jan 2009 17:30:11 -0000 1.98 +++ Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java 21 Jan 2009 16:33:58 -0000 @@ -83,7 +83,7 @@ int columnCount; int sortDirection; float /*double*/ levelIndent; - boolean ignoreExpand, ignoreSelect; + boolean ignoreExpand, ignoreSelect, reloadPending; /** * Constructs a new instance of this class given its parent @@ -262,6 +262,12 @@ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } +void checkItems () { + if (!reloadPending) return; + reloadPending = false; + ((NSOutlineView)view).reloadItem (null); +} + void clear (TreeItem parentItem, int index, boolean all) { TreeItem item = _getItem (parentItem, index, false); if (item != null) { @@ -578,8 +584,7 @@ this.itemCount = count; } ignoreExpand = true; - NSOutlineView widget = (NSOutlineView)view; - widget.reloadItem(parentItem != null ? parentItem.handle : null, true); + reloadItem (parentItem, true); ignoreExpand = false; } @@ -778,12 +783,10 @@ if (parentItem != null) { parentItem.itemCount = count; if (count == 0) parentItem.expanded = false; - ((NSOutlineView) view).reloadItem (parentItem.handle, true); } else { this.itemCount = count; - ((NSOutlineView) view).reloadItem (null); } - + reloadItem (parentItem, true); // setScrollWidth (true); // fixScrollBar (); } @@ -1281,6 +1284,7 @@ public TreeItem getItem (Point point) { checkWidget (); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); + checkItems (); NSOutlineView widget = (NSOutlineView)view; NSPoint pt = new NSPoint(); pt.x = point.x; @@ -1511,19 +1515,16 @@ */ public TreeItem getTopItem () { checkWidget (); -// //TODO - optimize -// Rect rect = new Rect (); -// int y = getBorder () + getHeaderHeight (); -// for (int i=0; i 1)) return; @@ -2500,6 +2518,7 @@ checkWidget(); if (item == null) error (SWT.ERROR_NULL_ARGUMENT); if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + checkItems (); showItem (item, false); NSOutlineView outlineView = (NSOutlineView) view; //FIXME @@ -2557,6 +2576,7 @@ checkWidget (); if (item == null) error (SWT.ERROR_NULL_ARGUMENT); if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + checkItems (); showItem (item, true); } @@ -2586,7 +2606,7 @@ */ public void showSelection () { checkWidget (); - //checkItems (false); + checkItems (); //TODO - optimize TreeItem [] selection = getSelection (); if (selection.length > 0) showItem (selection [0], true); Index: Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java,v retrieving revision 1.38 diff -u -r1.38 TreeItem.java --- Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java 15 Jan 2009 17:04:55 -0000 1.38 +++ Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java 21 Jan 2009 16:33:58 -0000 @@ -495,6 +495,7 @@ public Rectangle getBounds () { checkWidget (); if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED); + parent.checkItems (); NSOutlineView outlineView = (NSOutlineView) parent.view; NSRect rect = outlineView.rectOfRow (outlineView.rowForItem (handle)); return new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height); @@ -519,6 +520,7 @@ if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED); if (!(0 <= index && index < Math.max (1, parent.columnCount))) return new Rectangle (0, 0, 0, 0); + parent.checkItems (); NSOutlineView outlineView = (NSOutlineView) parent.view; if (parent.columnCount == 0) { index = (parent.style & SWT.CHECK) != 0 ? 1 : 0; @@ -720,6 +722,7 @@ if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED); if (!(0 <= index && index < Math.max (1, parent.columnCount))) return new Rectangle (0, 0, 0, 0); + parent.checkItems (); NSOutlineView outlineView = (NSOutlineView) parent.view; Image image = index == 0 ? this.image : (images != null) ? images [index] : null; if (parent.columnCount == 0) { @@ -894,6 +897,7 @@ if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED); if (!(0 <= index && index < Math.max (1, parent.columnCount))) return new Rectangle (0, 0, 0, 0); + parent.checkItems (); NSOutlineView outlineView = (NSOutlineView) parent.view; Image image = index == 0 ? this.image : (images != null) ? images [index] : null; if (parent.columnCount == 0) {