Mercurial > projects > dwt-addons
comparison 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 |
comparison
equal
deleted
inserted
replaced
69:07b9d96fd764 | 70:46a6e0e6ccd4 |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
332 | 332 |
333 | 333 |
334 } | 334 } |
335 | 335 |
336 /** | 336 /** |
337 * The ColorAndFontManager collects fonts and colors without a | 337 * The ColorAndFontCollector collects fonts and colors without a |
338 * a color or font provider. | 338 * a color or font provider. |
339 * | 339 * |
340 */ | 340 */ |
341 protected class ColorAndFontCollector { | 341 protected class ColorAndFontCollector { |
342 | 342 |
1023 Control control = getControl(); | 1023 Control control = getControl(); |
1024 if (control is null || control.isDisposed()) { | 1024 if (control is null || control.isDisposed()) { |
1025 return StructuredSelection.EMPTY; | 1025 return StructuredSelection.EMPTY; |
1026 } | 1026 } |
1027 auto list = getSelectionFromWidget(); | 1027 auto list = getSelectionFromWidget(); |
1028 return new StructuredSelection(list); | 1028 return new StructuredSelection(list, comparer); |
1029 } | 1029 } |
1030 | 1030 |
1031 /** | 1031 /** |
1032 * Retrieves the selection, as a <code>List</code>, from the underlying | 1032 * Retrieves the selection, as a <code>List</code>, from the underlying |
1033 * widget. | 1033 * widget. |
1380 * <li>runs the given runnable</li> | 1380 * <li>runs the given runnable</li> |
1381 * <li>attempts to restore the old selection (using | 1381 * <li>attempts to restore the old selection (using |
1382 * <code>setSelectionToWidget</code></li> | 1382 * <code>setSelectionToWidget</code></li> |
1383 * <li>rediscovers the resulting selection (via <code>getSelection</code>) | 1383 * <li>rediscovers the resulting selection (via <code>getSelection</code>) |
1384 * </li> | 1384 * </li> |
1385 * <li>calls <code>handleInvalidSelection</code> if the selection did not | 1385 * <li>calls <code>handleInvalidSelection</code> if the resulting selection is different from the old selection</li> |
1386 * take</li> | |
1387 * <li>calls <code>postUpdateHook</code></li> | |
1388 * </ul> | 1386 * </ul> |
1389 * </p> | 1387 * </p> |
1390 * | 1388 * |
1391 * @param updateCode | 1389 * @param updateCode |
1392 * the code to run | 1390 * the code to run |
1408 * <code>setSelectionToWidget</code></li> | 1406 * <code>setSelectionToWidget</code></li> |
1409 * <li>rediscovers the resulting selection (via <code>getSelection</code>) | 1407 * <li>rediscovers the resulting selection (via <code>getSelection</code>) |
1410 * </li> | 1408 * </li> |
1411 * <li>calls <code>handleInvalidSelection</code> if the selection did not | 1409 * <li>calls <code>handleInvalidSelection</code> if the selection did not |
1412 * take</li> | 1410 * take</li> |
1413 * <li>calls <code>postUpdateHook</code></li> | |
1414 * </ul> | 1411 * </ul> |
1415 * </p> | 1412 * </p> |
1416 * | 1413 * |
1417 * @param updateCode | 1414 * @param updateCode |
1418 * the code to run | 1415 * the code to run |
1537 }); | 1534 }); |
1538 } | 1535 } |
1539 | 1536 |
1540 /** | 1537 /** |
1541 * | 1538 * |
1542 * Refreshes the given TableItem with the given element. Calls | 1539 * Refreshes the given item with the given element. Calls |
1543 * <code>doUpdateItem(..., false)</code>. | 1540 * <code>doUpdateItem(..., false)</code>. |
1544 * <p> | 1541 * <p> |
1545 * This method is internal to the framework; subclassers should not call | 1542 * This method is internal to the framework; subclassers should not call |
1546 * this method. | 1543 * this method. |
1547 * </p> | 1544 * </p> |
1945 } | 1942 } |
1946 } | 1943 } |
1947 } | 1944 } |
1948 } | 1945 } |
1949 | 1946 |
1947 // flag to indicate that a full refresh took place. See bug 102440. | |
1948 private bool refreshOccurred; | |
1949 | |
1950 /** | 1950 /** |
1951 * Updates the given elements' presentation when one or more of their | 1951 * Updates the given elements' presentation when one or more of their |
1952 * properties change. Only the given elements are updated. | 1952 * properties change. Only the given elements are updated. |
1953 * <p> | 1953 * <p> |
1954 * This does not handle structural changes (e.g. addition or removal of | 1954 * This does not handle structural changes (e.g. addition or removal of |
1985 * @param properties | 1985 * @param properties |
1986 * the properties that have changed, or <code>null</code> to | 1986 * the properties that have changed, or <code>null</code> to |
1987 * indicate unknown | 1987 * indicate unknown |
1988 */ | 1988 */ |
1989 public void update(Object[] elements, String[] properties) { | 1989 public void update(Object[] elements, String[] properties) { |
1990 for (int i = 0; i < elements.length; ++i) { | 1990 bool previousValue = refreshOccurred; |
1991 update(elements[i], properties); | 1991 refreshOccurred = false; |
1992 try { | |
1993 for (int i = 0; i < elements.length; ++i) { | |
1994 update(elements[i], properties); | |
1995 if (refreshOccurred) { | |
1996 return; | |
1997 } | |
1998 } | |
1999 } finally { | |
2000 refreshOccurred = previousValue; | |
1992 } | 2001 } |
1993 } | 2002 } |
1994 | 2003 |
1995 /** | 2004 /** |
1996 * Updates the given element's presentation when one or more of its | 2005 * Updates the given element's presentation when one or more of its |
2033 */ | 2042 */ |
2034 public void update(Object element, String[] properties) { | 2043 public void update(Object element, String[] properties) { |
2035 Assert.isNotNull(element); | 2044 Assert.isNotNull(element); |
2036 Widget[] items = findItems(element); | 2045 Widget[] items = findItems(element); |
2037 | 2046 |
2047 bool mayExitEarly = !refreshOccurred; | |
2038 for (int i = 0; i < items.length; i++) { | 2048 for (int i = 0; i < items.length; i++) { |
2039 internalUpdate(items[i], element, properties); | 2049 internalUpdate(items[i], element, properties); |
2050 if (mayExitEarly && refreshOccurred) { | |
2051 // detected a change from refreshOccurredisfalse to refreshOccurredistrue | |
2052 return; | |
2053 } | |
2040 } | 2054 } |
2041 } | 2055 } |
2042 | 2056 |
2043 /** | 2057 /** |
2044 * Updates the given element's presentation when one or more of its | 2058 * Updates the given element's presentation when one or more of its |
2071 } | 2085 } |
2072 if (needsRefilter_) { | 2086 if (needsRefilter_) { |
2073 preservingSelection(new class Runnable { | 2087 preservingSelection(new class Runnable { |
2074 public void run() { | 2088 public void run() { |
2075 internalRefresh(getRoot()); | 2089 internalRefresh(getRoot()); |
2090 refreshOccurred = true; | |
2076 } | 2091 } |
2077 }); | 2092 }); |
2078 return; | 2093 return; |
2079 } | 2094 } |
2080 | 2095 |