Mercurial > projects > dwt-addons
comparison dwtx/jface/viewers/CheckboxTableViewer.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 |
---|---|
18 import dwtx.jface.viewers.CheckStateChangedEvent; | 18 import dwtx.jface.viewers.CheckStateChangedEvent; |
19 import dwtx.jface.viewers.TableLayout; | 19 import dwtx.jface.viewers.TableLayout; |
20 import dwtx.jface.viewers.ColumnWeightData; | 20 import dwtx.jface.viewers.ColumnWeightData; |
21 import dwtx.jface.viewers.CustomHashtable; | 21 import dwtx.jface.viewers.CustomHashtable; |
22 | 22 |
23 import tango.util.collection.ArraySeq; | |
24 import tango.util.collection.model.Seq; | |
25 | 23 |
26 import dwt.DWT; | 24 import dwt.DWT; |
27 import dwt.events.SelectionEvent; | 25 import dwt.events.SelectionEvent; |
28 import dwt.widgets.Composite; | 26 import dwt.widgets.Composite; |
29 import dwt.widgets.Table; | 27 import dwt.widgets.Table; |
33 import dwtx.core.runtime.Assert; | 31 import dwtx.core.runtime.Assert; |
34 import dwtx.core.runtime.ListenerList; | 32 import dwtx.core.runtime.ListenerList; |
35 import dwtx.jface.util.SafeRunnable; | 33 import dwtx.jface.util.SafeRunnable; |
36 | 34 |
37 import dwt.dwthelper.utils; | 35 import dwt.dwthelper.utils; |
36 import dwtx.dwtxhelper.Collection; | |
38 import dwt.dwthelper.Runnable; | 37 import dwt.dwthelper.Runnable; |
39 | 38 |
40 /** | 39 /** |
41 * A concrete viewer based on an DWT <code>Table</code> | 40 * A concrete viewer based on an DWT <code>Table</code> |
42 * control with checkboxes on each node. | 41 * control with checkboxes on each node. |
185 * @see ICheckStateListener#checkStateChanged | 184 * @see ICheckStateListener#checkStateChanged |
186 */ | 185 */ |
187 private void fireCheckStateChanged(CheckStateChangedEvent event) { | 186 private void fireCheckStateChanged(CheckStateChangedEvent event) { |
188 Object[] array = checkStateListeners.getListeners(); | 187 Object[] array = checkStateListeners.getListeners(); |
189 for (int i = 0; i < array.length; i++) { | 188 for (int i = 0; i < array.length; i++) { |
190 SafeRunnable.run(new class(cast(ICheckStateListener) array[i], event) SafeRunnable { | 189 SafeRunnable.run( dgSafeRunnable( (ICheckStateListener l, CheckStateChangedEvent event_) { |
191 ICheckStateListener l; | 190 l.checkStateChanged(event_); |
192 CheckStateChangedEvent event_; | 191 }, cast(ICheckStateListener) array[i], event )); |
193 this(ICheckStateListener a,CheckStateChangedEvent b){ | |
194 event_=b; | |
195 l = a; | |
196 } | |
197 public void run() { | |
198 l.checkStateChanged(event_); | |
199 } | |
200 }); | |
201 } | 192 } |
202 } | 193 } |
203 | 194 |
204 /* (non-Javadoc) | 195 /* (non-Javadoc) |
205 * Method declared on ICheckable. | 196 * Method declared on ICheckable. |
223 * @return the array of checked elements | 214 * @return the array of checked elements |
224 * @see #setCheckedElements | 215 * @see #setCheckedElements |
225 */ | 216 */ |
226 public Object[] getCheckedElements() { | 217 public Object[] getCheckedElements() { |
227 TableItem[] children = getTable().getItems(); | 218 TableItem[] children = getTable().getItems(); |
228 auto v = new ArraySeq!(Object); | 219 ArrayList v = new ArrayList(children.length); |
229 v.capacity(children.length); | |
230 for (int i = 0; i < children.length; i++) { | 220 for (int i = 0; i < children.length; i++) { |
231 TableItem item = children[i]; | 221 TableItem item = children[i]; |
232 if (item.getChecked()) { | 222 if (item.getChecked()) { |
233 v.append(item.getData()); | 223 v.add(item.getData()); |
234 } | 224 } |
235 } | 225 } |
236 return v.toArray(); | 226 return v.toArray(); |
237 } | 227 } |
238 | 228 |
262 * @return the array of grayed elements | 252 * @return the array of grayed elements |
263 * @see #setGrayedElements | 253 * @see #setGrayedElements |
264 */ | 254 */ |
265 public Object[] getGrayedElements() { | 255 public Object[] getGrayedElements() { |
266 TableItem[] children = getTable().getItems(); | 256 TableItem[] children = getTable().getItems(); |
267 auto v = new ArraySeq!(Object); | 257 ArrayList v = new ArrayList(children.length); |
268 v.capacity(children.length); | |
269 for (int i = 0; i < children.length; i++) { | 258 for (int i = 0; i < children.length; i++) { |
270 TableItem item = children[i]; | 259 TableItem item = children[i]; |
271 if (item.getGrayed()) { | 260 if (item.getGrayed()) { |
272 v.append(item.getData()); | 261 v.add(item.getData()); |
273 } | 262 } |
274 } | 263 } |
275 return v.toArray(); | 264 return v.toArray(); |
276 } | 265 } |
277 | 266 |