Mercurial > projects > dwt-addons
comparison dwtx/jface/util/DelegatingDropAdapter.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 | 644f1334b451 |
children |
comparison
equal
deleted
inserted
replaced
103:2d6540440fe6 | 104:04b47443bb01 |
---|---|
13 module dwtx.jface.util.DelegatingDropAdapter; | 13 module dwtx.jface.util.DelegatingDropAdapter; |
14 | 14 |
15 import dwtx.jface.util.TransferDropTargetListener; | 15 import dwtx.jface.util.TransferDropTargetListener; |
16 import dwtx.jface.util.SafeRunnable; | 16 import dwtx.jface.util.SafeRunnable; |
17 | 17 |
18 import tango.util.collection.ArraySeq; | |
19 | 18 |
20 import dwt.dnd.DND; | 19 import dwt.dnd.DND; |
21 import dwt.dnd.DropTargetEvent; | 20 import dwt.dnd.DropTargetEvent; |
22 import dwt.dnd.DropTargetListener; | 21 import dwt.dnd.DropTargetListener; |
23 import dwt.dnd.Transfer; | 22 import dwt.dnd.Transfer; |
24 import dwt.dnd.TransferData; | 23 import dwt.dnd.TransferData; |
25 | 24 |
26 import dwt.dwthelper.utils; | 25 import dwt.dwthelper.utils; |
26 import dwtx.dwtxhelper.Collection; | |
27 | 27 |
28 /** | 28 /** |
29 * A <code>DelegatingDropAdapter</code> is a <code>DropTargetListener</code> that | 29 * A <code>DelegatingDropAdapter</code> is a <code>DropTargetListener</code> that |
30 * maintains and delegates to a set of {@link TransferDropTargetListener}s. Each | 30 * maintains and delegates to a set of {@link TransferDropTargetListener}s. Each |
31 * <code>TransferDropTargetListener</code> can then be implemented as if it were | 31 * <code>TransferDropTargetListener</code> can then be implemented as if it were |
102 * viewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, dropAdapter.getTransfers(), dropAdapter); | 102 * viewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, dropAdapter.getTransfers(), dropAdapter); |
103 * </pre></code> | 103 * </pre></code> |
104 * @since 3.0 | 104 * @since 3.0 |
105 */ | 105 */ |
106 public class DelegatingDropAdapter : DropTargetListener { | 106 public class DelegatingDropAdapter : DropTargetListener { |
107 private ArraySeq!(Object) listeners; | 107 private List listeners; |
108 | 108 |
109 private TransferDropTargetListener currentListener; | 109 private TransferDropTargetListener currentListener; |
110 | 110 |
111 private int originalDropType; | 111 private int originalDropType; |
112 | 112 |
113 this(){ | 113 this(){ |
114 listeners = new ArraySeq!(Object); | 114 listeners = new ArrayList(); |
115 } | 115 } |
116 | 116 |
117 /** | 117 /** |
118 * Adds the given <code>TransferDropTargetListener</code>. | 118 * Adds the given <code>TransferDropTargetListener</code>. |
119 * | 119 * |
120 * @param listener the new listener | 120 * @param listener the new listener |
121 */ | 121 */ |
122 public void addDropTargetListener(TransferDropTargetListener listener) { | 122 public void addDropTargetListener(TransferDropTargetListener listener) { |
123 listeners.append(cast(Object)listener); | 123 listeners.add(cast(Object)listener); |
124 } | 124 } |
125 | 125 |
126 /** | 126 /** |
127 * The cursor has entered the drop target boundaries. The current listener is | 127 * The cursor has entered the drop target boundaries. The current listener is |
128 * updated, and <code>#dragEnter()</code> is forwarded to the current listener. | 128 * updated, and <code>#dragEnter()</code> is forwarded to the current listener. |
310 * | 310 * |
311 * @return <code>true</code> if there are no <code>TransferDropTargetListeners</code> | 311 * @return <code>true</code> if there are no <code>TransferDropTargetListeners</code> |
312 * <code>false</code> otherwise | 312 * <code>false</code> otherwise |
313 */ | 313 */ |
314 public bool isEmpty() { | 314 public bool isEmpty() { |
315 return listeners.drained(); | 315 return listeners.isEmpty(); |
316 } | 316 } |
317 | 317 |
318 /** | 318 /** |
319 * Removes the given <code>TransferDropTargetListener</code>. | 319 * Removes the given <code>TransferDropTargetListener</code>. |
320 * Listeners should not be removed while a drag and drop operation is in progress. | 320 * Listeners should not be removed while a drag and drop operation is in progress. |
379 // revert the detail to the "original" drop type that the User indicated. | 379 // revert the detail to the "original" drop type that the User indicated. |
380 // this is necessary because the previous listener may have changed the detail | 380 // this is necessary because the previous listener may have changed the detail |
381 // to something other than what the user indicated. | 381 // to something other than what the user indicated. |
382 event.detail = originalDropType; | 382 event.detail = originalDropType; |
383 | 383 |
384 foreach( e; listeners ){ | 384 Iterator iter = listeners.iterator(); |
385 TransferDropTargetListener listener = cast(TransferDropTargetListener)e; | 385 while (iter.hasNext()) { |
386 TransferDropTargetListener listener = cast(TransferDropTargetListener) iter | |
387 .next(); | |
386 TransferData dataType = getSupportedTransferType(event.dataTypes, | 388 TransferData dataType = getSupportedTransferType(event.dataTypes, |
387 listener); | 389 listener); |
388 if (dataType !is null) { | 390 if (dataType !is null) { |
389 TransferData originalDataType = event.currentDataType; | 391 TransferData originalDataType = event.currentDataType; |
390 // set the data type supported by the drop listener | 392 // set the data type supported by the drop listener |