comparison dwtx/jface/viewers/AbstractTreeViewer.d @ 54:a6683645b0d7

Fix ignored labelprovider for TreeViewer (See WrapperViewerLabelProvider.d), removed the debugging prints
author Frank Benoit <benoit@tionex.de>
date Sat, 12 Apr 2008 17:53:06 +0200
parents 28f6c339768e
children 46a6e0e6ccd4
comparison
equal deleted inserted replaced
53:28f6c339768e 54:a6683645b0d7
58 import dwtx.core.runtime.ListenerList; 58 import dwtx.core.runtime.ListenerList;
59 import dwtx.jface.util.SafeRunnable; 59 import dwtx.jface.util.SafeRunnable;
60 60
61 import dwt.dwthelper.utils; 61 import dwt.dwthelper.utils;
62 import dwt.dwthelper.Runnable; 62 import dwt.dwthelper.Runnable;
63 import tango.util.log.Trace;
64 63
65 /** 64 /**
66 * Abstract base implementation for tree-structure-oriented viewers (trees and 65 * Abstract base implementation for tree-structure-oriented viewers (trees and
67 * table trees). 66 * table trees).
68 * <p> 67 * <p>
771 */ 770 */
772 protected void createChildren(Widget widget) { 771 protected void createChildren(Widget widget) {
773 bool oldBusy = busy; 772 bool oldBusy = busy;
774 busy = true; 773 busy = true;
775 try { 774 try {
776 final Item[] tis = getChildren(widget); 775 Item[] tis = getChildren(widget);
777 if (tis !is null && tis.length > 0) { 776 if (tis !is null && tis.length > 0) {
778 Object data = tis[0].getData(); 777 Object data = tis[0].getData();
779 if (data !is null) { 778 if (data !is null) {
780 return; // children already there! 779 return; // children already there!
781 } 780 }
913 * the DWT item 912 * the DWT item
914 * @param element 913 * @param element
915 * the element 914 * the element
916 */ 915 */
917 protected void doUpdateItem(Item item, Object element) { 916 protected void doUpdateItem(Item item, Object element) {
918 // Trace.formatln( "{} {}: doUpdateItem", __FILE__, __LINE__ );
919 if (item.isDisposed()) { 917 if (item.isDisposed()) {
920 unmapElement(element, item); 918 unmapElement(element, item);
921 return; 919 return;
922 } 920 }
923 921
929 927
930 bool isVirtual = (getControl().getStyle() & DWT.VIRTUAL) !is 0; 928 bool isVirtual = (getControl().getStyle() & DWT.VIRTUAL) !is 0;
931 929
932 // If the control is virtual, we cannot use the cached viewer row object. See bug 188663. 930 // If the control is virtual, we cannot use the cached viewer row object. See bug 188663.
933 if (isVirtual) { 931 if (isVirtual) {
934 // Trace.formatln( "{} {}: doUpdateItem", __FILE__, __LINE__ );
935 viewerRowFromItem = cast(ViewerRow) viewerRowFromItem.clone(); 932 viewerRowFromItem = cast(ViewerRow) viewerRowFromItem.clone();
936 } 933 }
937 934
938 for (int column = 0; column < columnCount; column++) { 935 for (int column = 0; column < columnCount; column++) {
939 // Trace.formatln( "{} {}: doUpdateItem", __FILE__, __LINE__ );
940 ViewerColumn columnViewer = getViewerColumn(column); 936 ViewerColumn columnViewer = getViewerColumn(column);
941 ViewerCell cellToUpdate = updateCell(viewerRowFromItem, column, 937 ViewerCell cellToUpdate = updateCell(viewerRowFromItem, column,
942 element); 938 element);
943 939
944 // If the control is virtual, we cannot use the cached cell object. See bug 188663. 940 // If the control is virtual, we cannot use the cached cell object. See bug 188663.
1784 internalRefresh(element, true); 1780 internalRefresh(element, true);
1785 } 1781 }
1786 1782
1787 /* (non-Javadoc) Method declared on StructuredViewer. */ 1783 /* (non-Javadoc) Method declared on StructuredViewer. */
1788 protected override void internalRefresh(Object element, bool updateLabels) { 1784 protected override void internalRefresh(Object element, bool updateLabels) {
1789 // Trace.formatln( "{} {}: ", __FILE__, __LINE__ );
1790 // PrintStackTrace();
1791 // If element is null, do a full refresh. 1785 // If element is null, do a full refresh.
1792 if (element is null) { 1786 if (element is null) {
1793 internalRefresh(getControl(), getRoot(), true, updateLabels); 1787 internalRefresh(getControl(), getRoot(), true, updateLabels);
1794 return; 1788 return;
1795 } 1789 }
1796 Widget[] items = findItems(element); 1790 Widget[] items = findItems(element);
1797 // Trace.formatln( "{} {}: ,items.length={}", __FILE__, __LINE__ ,items.length);
1798 if (items.length !is 0) { 1791 if (items.length !is 0) {
1799 for (int i = 0; i < items.length; i++) { 1792 for (int i = 0; i < items.length; i++) {
1800 // pick up structure changes too 1793 // pick up structure changes too
1801 internalRefresh(items[i], element, true, updateLabels); 1794 internalRefresh(items[i], element, true, updateLabels);
1802 } 1795 }
2991 * 2984 *
2992 * @see dwtx.jface.viewers.StructuredViewer#buildLabel(dwtx.jface.viewers.ViewerLabel, 2985 * @see dwtx.jface.viewers.StructuredViewer#buildLabel(dwtx.jface.viewers.ViewerLabel,
2993 * java.lang.Object) 2986 * java.lang.Object)
2994 */ 2987 */
2995 protected override void buildLabel(ViewerLabel updateLabel, Object elementOrPath) { 2988 protected override void buildLabel(ViewerLabel updateLabel, Object elementOrPath) {
2996 // Trace.formatln( "{} {}:", __FILE__, __LINE__ );
2997 Object element; 2989 Object element;
2998 if (auto path = cast(TreePath)elementOrPath ) { 2990 if (auto path = cast(TreePath)elementOrPath ) {
2999 IBaseLabelProvider provider = getLabelProvider(); 2991 IBaseLabelProvider provider = getLabelProvider();
3000 if ( auto pprov = cast(ITreePathLabelProvider) provider ) { 2992 if ( auto pprov = cast(ITreePathLabelProvider) provider ) {
3001 buildLabel(updateLabel, path, pprov); 2993 buildLabel(updateLabel, path, pprov);