comparison dwtx/jface/viewers/DelegatingStyledCellLabelProvider.d @ 104:04b47443bb01

Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections. These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author Frank Benoit <benoit@tionex.de>
date Thu, 07 Aug 2008 15:01:33 +0200
parents 7ffeace6c47f
children
comparison
equal deleted inserted replaced
103:2d6540440fe6 104:04b47443bb01
24 import dwt.graphics.Color; 24 import dwt.graphics.Color;
25 import dwt.graphics.Font; 25 import dwt.graphics.Font;
26 import dwt.graphics.Image; 26 import dwt.graphics.Image;
27 27
28 import dwt.dwthelper.utils; 28 import dwt.dwthelper.utils;
29 import dwtx.dwtxhelper.Collection;
29 30
30 /** 31 /**
31 * A {@link DelegatingStyledCellLabelProvider} is a 32 * A {@link DelegatingStyledCellLabelProvider} is a
32 * {@link StyledCellLabelProvider} that delegates requests for the styled string 33 * {@link StyledCellLabelProvider} that delegates requests for the styled string
33 * and the image to a 34 * and the image to a
110 public void update(ViewerCell cell) { 111 public void update(ViewerCell cell) {
111 Object element = cell.getElement(); 112 Object element = cell.getElement();
112 113
113 StyledString styledString = getStyledText(element); 114 StyledString styledString = getStyledText(element);
114 String newText= styledString.toString(); 115 String newText= styledString.toString();
115 116
116 StyleRange[] oldStyleRanges= cell.getStyleRanges(); 117 StyleRange[] oldStyleRanges= cell.getStyleRanges();
117 StyleRange[] newStyleRanges= isOwnerDrawEnabled() ? styledString.getStyleRanges() : null; 118 StyleRange[] newStyleRanges= isOwnerDrawEnabled() ? styledString.getStyleRanges() : null;
118 119
119 if (!Arrays.equals(oldStyleRanges, newStyleRanges)) { 120 if (!Arrays.equals(oldStyleRanges, newStyleRanges)) {
120 cell.setStyleRanges(newStyleRanges); 121 cell.setStyleRanges(newStyleRanges);
121 if (cell.getText().equals(newText)) { 122 if (cell.getText().equals(newText)) {
122 // make sure there will be a refresh from a change 123 // make sure there will be a refresh from a change
123 cell.setText(""); //$NON-NLS-1$ 124 cell.setText(""); //$NON-NLS-1$
124 } 125 }
125 } 126 }
126 127
127 cell.setText(newText); 128 cell.setText(newText);
128 cell.setImage(getImage(element)); 129 cell.setImage(getImage(element));
129 cell.setFont(getFont(element)); 130 cell.setFont(getFont(element));
130 cell.setForeground(getForeground(element)); 131 cell.setForeground(getForeground(element));
131 cell.setBackground(getBackground(element)); 132 cell.setBackground(getBackground(element));
132 133
133 // no super call required. changes on item will trigger the refresh. 134 // no super call required. changes on item will trigger the refresh.
134 } 135 }
135 136
136 /** 137 /**
137 * Provides a foreground color for the given element. 138 * Provides a foreground color for the given element.