diff dwtx/jface/viewers/TreeViewer.d @ 70:46a6e0e6ccd4

Merge with d-fied sources of 3.4M7
author Frank Benoit <benoit@tionex.de>
date Thu, 22 May 2008 01:36:46 +0200
parents a6683645b0d7
children 7ffeace6c47f
line wrap: on
line diff
--- a/dwtx/jface/viewers/TreeViewer.d	Mon May 19 13:41:06 2008 +0200
+++ b/dwtx/jface/viewers/TreeViewer.d	Thu May 22 01:36:46 2008 +0200
@@ -8,7 +8,8 @@
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *     Tom Schindl <tom.schindl@bestsolution.at> - concept of ViewerRow,
- *                                                 refactoring (bug 153993), bug 167323, 191468
+ *                                                 refactoring (bug 153993), bug 167323, 191468, 205419
+ *     Matthew Hall - bug 221988
  * Port to the D programming language:
  *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
@@ -70,8 +71,13 @@
  * {@link ILazyTreePathContentProvider}. If the content provider is an
  * <code>ILazyTreeContentProvider</code> or an
  * <code>ILazyTreePathContentProvider</code>, the underlying Tree must be
- * created using the {@link DWT#VIRTUAL} style bit, and the tree viewer will not
- * support sorting or filtering.
+ * created using the {@link DWT#VIRTUAL} style bit, the tree viewer will not
+ * support sorting or filtering, and hash lookup must be enabled by calling
+ * {@link #setUseHashlookup(bool)}.
+ * </p>
+ * <p>
+ * Users setting up an editable tree with more than 1 column <b>have</b> to pass the
+ * DWT.FULL_SELECTION style bit
  * </p>
  */
 public class TreeViewer : AbstractTreeViewer {
@@ -431,7 +437,7 @@
      * @since 3.2
      */
     public void setChildCount(Object elementOrTreePath, int count) {
-        if (isBusy())
+        if (checkBusy())
             return;
         preservingSelection(new class(elementOrTreePath,count) Runnable {
             Object elementOrTreePath_;
@@ -480,7 +486,7 @@
      */
     public void replace(Object parentElementOrTreePath, int index,
             Object element) {
-        if (isBusy())
+        if (checkBusy())
             return;
         Item[] selectedItems = getSelection(getControl());
         TreeSelection selection = cast(TreeSelection) getSelection();
@@ -605,8 +611,8 @@
     }
 
     protected override Object getParentElement(Object element) {
-        bool oldBusy = busy;
-        busy = true;
+        bool oldBusy = isBusy();
+        setBusy(true);
         try {
             if (contentProviderIsLazy && !contentProviderIsTreeBased && !(cast(TreePath)element )) {
                 ILazyTreeContentProvider lazyTreeContentProvider = cast(ILazyTreeContentProvider) getContentProvider();
@@ -622,7 +628,7 @@
             }
             return super.getParentElement(element);
         } finally {
-            busy = oldBusy;
+            setBusy(oldBusy);
         }
     }
 
@@ -773,7 +779,7 @@
             // only add a dispose listener if item hasn't already on assigned
             // because it is reused
             if (item.getData(VIRTUAL_DISPOSE_KEY) is null) {
-                item.setData(VIRTUAL_DISPOSE_KEY, new ValueWrapperBool(true));
+                item.setData(VIRTUAL_DISPOSE_KEY, Boolean.TRUE);
                 item.addDisposeListener(new class(item) DisposeListener {
                     Widget item_;
                     this(Widget a){
@@ -875,7 +881,7 @@
      * @since 3.3
      */
     public void remove(Object parentOrTreePath_, int index_) {
-        if (isBusy())
+        if (checkBusy())
             return;
         preservingSelection(new class((cast(TreeSelection) getSelection()).getPaths(),parentOrTreePath_,index_) Runnable {
             Seq!(TreePath) oldSelection;
@@ -905,6 +911,8 @@
                     Widget[] parentItems = internalFindItems(parentOrTreePath);
                     for (int i = 0; i < parentItems.length; i++) {
                         TreeItem parentItem = cast(TreeItem) parentItems[i];
+                        if (parentItem.isDisposed())
+                            continue;
                         if (index < parentItem.getItemCount()) {
                             TreeItem item = parentItem.getItem(index);
                             if (item.getData() !is null) {
@@ -978,7 +986,7 @@
      * @since 3.3
      */
     public void setHasChildren(Object elementOrTreePath_, bool hasChildren_) {
-        if (isBusy())
+        if (checkBusy())
             return;
         preservingSelection(new class(elementOrTreePath_,hasChildren_) Runnable {
             Object elementOrTreePath;
@@ -1025,8 +1033,8 @@
      * @param index
      */
     private void virtualLazyUpdateWidget(Widget widget, int index) {
-        bool oldBusy = busy;
-        busy = false;
+        bool oldBusy = isBusy();
+        setBusy(false);
         try {
             if (contentProviderIsTreeBased) {
                 TreePath treePath;
@@ -1051,7 +1059,7 @@
                         widget.getData(), index);
             }
         } finally {
-            busy = oldBusy;
+            setBusy(oldBusy);
         }
     }
 
@@ -1061,8 +1069,8 @@
      * @param currentChildCount
      */
     private void virtualLazyUpdateChildCount(Widget widget, int currentChildCount) {
-        bool oldBusy = busy;
-        busy = false;
+        bool oldBusy = isBusy();
+        setBusy(false);
         try {
             if (contentProviderIsTreeBased) {
                 TreePath treePath;
@@ -1077,7 +1085,7 @@
                 (cast(ILazyTreeContentProvider) getContentProvider()).updateChildCount(widget.getData(), currentChildCount);
             }
         } finally {
-            busy = oldBusy;
+            setBusy(oldBusy);
         }
     }
 
@@ -1087,8 +1095,8 @@
      * @param currentChildCount
      */
     private void virtualLazyUpdateHasChildren(Item item, int currentChildCount) {
-        bool oldBusy = busy;
-        busy = false;
+        bool oldBusy = isBusy();
+        setBusy(false);
         try {
             if (contentProviderIsTreeBased) {
                 TreePath treePath;
@@ -1105,7 +1113,7 @@
                 (cast(ILazyTreeContentProvider) getContentProvider()).updateChildCount(item.getData(), currentChildCount);
             }
         } finally {
-            busy = oldBusy;
+            setBusy(oldBusy);
         }
     }
 
@@ -1141,26 +1149,27 @@
 
     public override void editElement(Object element, int column) {
         if( cast(TreePath)element ) {
-            setSelection(new TreeSelection(cast(TreePath) element));
-            TreeItem[] items = tree.getSelection();
-
-            if( items.length is 1 ) {
-                ViewerRow row = getViewerRowFromItem(items[0]);
+            try {
+                getControl().setRedraw(false);
+                setSelection(new TreeSelection(cast(TreePath) element));
+                TreeItem[] items = tree.getSelection();
 
-                if (row !is null) {
-                    ViewerCell cell = row.getCell(column);
-                    if (cell !is null) {
-                        getControl().setRedraw(false);
-                        try {
+                if( items.length is 1 ) {
+                    ViewerRow row = getViewerRowFromItem(items[0]);
+
+                    if (row !is null) {
+                        ViewerCell cell = row.getCell(column);
+                        if (cell !is null) {
                             triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell));
-                        } finally {
-                            getControl().setRedraw(true);
                         }
                     }
                 }
+            } finally {
+                getControl().setRedraw(true);
             }
         } else {
             super.editElement(element, column);
         }
     }
+
 }