Mercurial > projects > dwt-addons
comparison dwtx/jface/viewers/AbstractTableViewer.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 | ea8ff534f622 |
children | 7ffeace6c47f |
comparison
equal
deleted
inserted
replaced
69:07b9d96fd764 | 70:46a6e0e6ccd4 |
---|---|
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation bug 154329 | 10 * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation bug 154329 |
11 * - fixes in bug 170381, 198665 | 11 * - fixes in bug 170381, 198665, 200731 |
12 * Port to the D programming language: | 12 * Port to the D programming language: |
13 * Frank Benoit <benoit@tionex.de> | 13 * Frank Benoit <benoit@tionex.de> |
14 *******************************************************************************/ | 14 *******************************************************************************/ |
15 | 15 |
16 module dwtx.jface.viewers.AbstractTableViewer; | 16 module dwtx.jface.viewers.AbstractTableViewer; |
255 * @param elements | 255 * @param elements |
256 * the elements to add | 256 * the elements to add |
257 */ | 257 */ |
258 public void add(Object[] elements) { | 258 public void add(Object[] elements) { |
259 assertElementsNotNull(elements); | 259 assertElementsNotNull(elements); |
260 if (isBusy()) | 260 if (checkBusy()) |
261 return; | 261 return; |
262 Object[] filtered = filter(elements); | 262 Object[] filtered = filter(elements); |
263 | 263 |
264 for (int i = 0; i < filtered.length; i++) { | 264 for (int i = 0; i < filtered.length; i++) { |
265 Object element = filtered[i]; | 265 Object element = filtered[i]; |
355 * | 355 * |
356 * @see dwtx.jface.viewers.StructuredViewer#doUpdateItem(dwt.widgets.Widget, | 356 * @see dwtx.jface.viewers.StructuredViewer#doUpdateItem(dwt.widgets.Widget, |
357 * java.lang.Object, bool) | 357 * java.lang.Object, bool) |
358 */ | 358 */ |
359 protected override void doUpdateItem(Widget widget, Object element, bool fullMap) { | 359 protected override void doUpdateItem(Widget widget, Object element, bool fullMap) { |
360 bool oldBusy = busy; | 360 bool oldBusy = isBusy(); |
361 busy = true; | 361 setBusy(true); |
362 try { | 362 try { |
363 if ( auto item = cast(Item)widget ) { | 363 if ( auto item = cast(Item)widget ) { |
364 | 364 |
365 // remember element we are showing | 365 // remember element we are showing |
366 if (fullMap) { | 366 if (fullMap) { |
413 | 413 |
414 } | 414 } |
415 | 415 |
416 } | 416 } |
417 } finally { | 417 } finally { |
418 busy = oldBusy; | 418 setBusy(oldBusy); |
419 } | 419 } |
420 } | 420 } |
421 | 421 |
422 /* | 422 /* |
423 * (non-Javadoc) | 423 * (non-Javadoc) |
620 return; | 620 return; |
621 } | 621 } |
622 if (position is -1) { | 622 if (position is -1) { |
623 position = doGetItemCount(); | 623 position = doGetItemCount(); |
624 } | 624 } |
625 if (isBusy()) | 625 if (checkBusy()) |
626 return; | 626 return; |
627 createItem(element, position); | 627 createItem(element, position); |
628 } | 628 } |
629 | 629 |
630 /* | 630 /* |
766 */ | 766 */ |
767 private void internalRemove(Object[] elements) { | 767 private void internalRemove(Object[] elements) { |
768 Object input = getInput(); | 768 Object input = getInput(); |
769 for (int i = 0; i < elements.length; ++i) { | 769 for (int i = 0; i < elements.length; ++i) { |
770 if (opEquals(elements[i], input)) { | 770 if (opEquals(elements[i], input)) { |
771 bool oldBusy = busy; | 771 bool oldBusy = isBusy(); |
772 busy = false; | 772 setBusy(false); |
773 try { | 773 try { |
774 setInput(null); | 774 setInput(null); |
775 } finally { | 775 } finally { |
776 busy = oldBusy; | 776 setBusy(oldBusy); |
777 } | 777 } |
778 return; | 778 return; |
779 } | 779 } |
780 } | 780 } |
781 // use remove(int[]) rather than repeated TableItem.dispose() calls | 781 // use remove(int[]) rather than repeated TableItem.dispose() calls |
821 * @param elements | 821 * @param elements |
822 * the elements to remove | 822 * the elements to remove |
823 */ | 823 */ |
824 public void remove( Object[] elements) { | 824 public void remove( Object[] elements) { |
825 assertElementsNotNull(elements); | 825 assertElementsNotNull(elements); |
826 if (isBusy()) | 826 if (checkBusy()) |
827 return; | 827 return; |
828 if (elements.length is 0) { | 828 if (elements.length is 0) { |
829 return; | 829 return; |
830 } | 830 } |
831 preservingSelection(new class(elements) Runnable { | 831 preservingSelection(new class(elements) Runnable { |
998 } | 998 } |
999 | 999 |
1000 if (count < size) { | 1000 if (count < size) { |
1001 System.arraycopy(indices, 0, indices = new int[count], 0, count); | 1001 System.arraycopy(indices, 0, indices = new int[count], 0, count); |
1002 } | 1002 } |
1003 doSetSelection(indices); | 1003 doDeselectAll(); |
1004 doSelect(indices); | |
1004 | 1005 |
1005 if (reveal && firstItem !is null) { | 1006 if (reveal && firstItem !is null) { |
1006 doShowItem(firstItem); | 1007 doShowItem(firstItem); |
1007 } | 1008 } |
1008 } | 1009 } |
1014 * the new table size. | 1015 * the new table size. |
1015 * | 1016 * |
1016 * @since 3.1 | 1017 * @since 3.1 |
1017 */ | 1018 */ |
1018 public void setItemCount(int count) { | 1019 public void setItemCount(int count) { |
1019 if (isBusy()) | 1020 if (checkBusy()) |
1020 return; | 1021 return; |
1021 int oldCount = doGetItemCount(); | 1022 int oldCount = doGetItemCount(); |
1022 if (count < oldCount) { | 1023 if (count < oldCount) { |
1023 // need to disassociate elements that are being disposed | 1024 // need to disassociate elements that are being disposed |
1024 for (int i = count; i < oldCount; i++) { | 1025 for (int i = count; i < oldCount; i++) { |
1046 * @see ILazyContentProvider | 1047 * @see ILazyContentProvider |
1047 * | 1048 * |
1048 * @since 3.1 | 1049 * @since 3.1 |
1049 */ | 1050 */ |
1050 public void replace(Object element, int index) { | 1051 public void replace(Object element, int index) { |
1051 if (isBusy()) | 1052 if (checkBusy()) |
1052 return; | 1053 return; |
1053 Item item = doGetItem(index); | 1054 Item item = doGetItem(index); |
1054 refreshItem(item, element); | 1055 refreshItem(item, element); |
1055 } | 1056 } |
1056 | 1057 |