diff dwtx/jface/viewers/StructuredViewer.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/StructuredViewer.d	Mon May 19 13:41:06 2008 +0200
+++ b/dwtx/jface/viewers/StructuredViewer.d	Thu May 22 01:36:46 2008 +0200
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -334,7 +334,7 @@
     }
 
     /**
-     * The ColorAndFontManager collects fonts and colors without a
+     * The ColorAndFontCollector collects fonts and colors without a
      * a color or font provider.
      *
      */
@@ -1025,7 +1025,7 @@
             return StructuredSelection.EMPTY;
         }
         auto list = getSelectionFromWidget();
-        return new StructuredSelection(list);
+        return new StructuredSelection(list, comparer);
     }
 
     /**
@@ -1382,9 +1382,7 @@
      * <code>setSelectionToWidget</code></li>
      * <li>rediscovers the resulting selection (via <code>getSelection</code>)
      * </li>
-     * <li>calls <code>handleInvalidSelection</code> if the selection did not
-     * take</li>
-     * <li>calls <code>postUpdateHook</code></li>
+     * <li>calls <code>handleInvalidSelection</code> if the resulting selection is different from the old selection</li>
      * </ul>
      * </p>
      *
@@ -1410,7 +1408,6 @@
      * </li>
      * <li>calls <code>handleInvalidSelection</code> if the selection did not
      * take</li>
-     * <li>calls <code>postUpdateHook</code></li>
      * </ul>
      * </p>
      *
@@ -1539,7 +1536,7 @@
 
     /**
      *
-     * Refreshes the given TableItem with the given element. Calls
+     * Refreshes the given item with the given element. Calls
      * <code>doUpdateItem(..., false)</code>.
      * <p>
      * This method is internal to the framework; subclassers should not call
@@ -1947,6 +1944,9 @@
         }
     }
 
+    // flag to indicate that a full refresh took place. See bug 102440.
+    private bool refreshOccurred;
+    
     /**
      * Updates the given elements' presentation when one or more of their
      * properties change. Only the given elements are updated.
@@ -1987,8 +1987,17 @@
      *            indicate unknown
      */
     public void update(Object[] elements, String[] properties) {
-        for (int i = 0; i < elements.length; ++i) {
-            update(elements[i], properties);
+        bool previousValue = refreshOccurred;
+        refreshOccurred = false;
+        try {
+            for (int i = 0; i < elements.length; ++i) {
+                update(elements[i], properties);
+                if (refreshOccurred) {
+                    return;
+                }
+            }
+        } finally {
+            refreshOccurred = previousValue;
         }
     }
 
@@ -2035,8 +2044,13 @@
         Assert.isNotNull(element);
         Widget[] items = findItems(element);
 
+        bool mayExitEarly = !refreshOccurred;
         for (int i = 0; i < items.length; i++) {
             internalUpdate(items[i], element, properties);
+            if (mayExitEarly && refreshOccurred) {
+                // detected a change from refreshOccurredisfalse to refreshOccurredistrue 
+                return;
+            }
         }
     }
 
@@ -2073,6 +2087,7 @@
             preservingSelection(new class Runnable {
                 public void run() {
                     internalRefresh(getRoot());
+                    refreshOccurred = true;
                 }
             });
             return;