Lines 85-90
Link Here
|
85 |
private int lastValidOperation; |
85 |
private int lastValidOperation; |
86 |
|
86 |
|
87 |
/** |
87 |
/** |
|
|
88 |
* This is used because we allow the operation |
89 |
* to be temporarily overridden (for example a move to a copy) for a drop that |
90 |
* happens immediately after the operation is overridden. |
91 |
*/ |
92 |
private int overrideOperation; |
93 |
|
94 |
/** |
88 |
* The current DropTargetEvent, used only during validateDrop() |
95 |
* The current DropTargetEvent, used only during validateDrop() |
89 |
*/ |
96 |
*/ |
90 |
private DropTargetEvent currentEvent; |
97 |
private DropTargetEvent currentEvent; |
Lines 181-198
Link Here
|
181 |
* that it is still enabled. |
188 |
* that it is still enabled. |
182 |
*/ |
189 |
*/ |
183 |
private void doDropValidation(DropTargetEvent event) { |
190 |
private void doDropValidation(DropTargetEvent event) { |
184 |
//always remember what was previously requested |
191 |
//always remember what was previously requested, but not if it |
185 |
if (event.detail != DND.DROP_NONE) |
192 |
//was overridden |
|
|
193 |
if (event.detail != DND.DROP_NONE && overrideOperation == -1) |
186 |
lastValidOperation = event.detail; |
194 |
lastValidOperation = event.detail; |
187 |
|
195 |
|
188 |
currentOperation = lastValidOperation; |
196 |
currentOperation = lastValidOperation; |
189 |
|
|
|
190 |
//the client may change the currentOperation inside of here |
191 |
currentEvent = event; |
197 |
currentEvent = event; |
|
|
198 |
overrideOperation = -1; |
192 |
if (!validateDrop(currentTarget, currentOperation, event.currentDataType)) { |
199 |
if (!validateDrop(currentTarget, currentOperation, event.currentDataType)) { |
193 |
currentOperation = DND.DROP_NONE; |
200 |
currentOperation = DND.DROP_NONE; |
194 |
} |
201 |
} |
195 |
event.detail = currentOperation; |
202 |
|
|
|
203 |
//give the right feedback for the override |
204 |
if (overrideOperation != -1) |
205 |
event.detail = overrideOperation; |
206 |
else |
207 |
event.detail = currentOperation; |
196 |
currentEvent = null; |
208 |
currentEvent = null; |
197 |
} |
209 |
} |
198 |
|
210 |
|
Lines 246-251
Link Here
|
246 |
currentLocation = determineLocation(event); |
258 |
currentLocation = determineLocation(event); |
247 |
currentEvent = event; |
259 |
currentEvent = event; |
248 |
|
260 |
|
|
|
261 |
if (overrideOperation != -1) |
262 |
currentOperation = overrideOperation; |
263 |
|
249 |
//perform the drop behavior |
264 |
//perform the drop behavior |
250 |
if (!performDrop(event.data)) { |
265 |
if (!performDrop(event.data)) { |
251 |
event.detail = DND.DROP_NONE; |
266 |
event.detail = DND.DROP_NONE; |
Lines 402-415
Link Here
|
402 |
public abstract boolean performDrop(Object data); |
417 |
public abstract boolean performDrop(Object data); |
403 |
|
418 |
|
404 |
/** |
419 |
/** |
405 |
* Sets the current operation. |
420 |
* Overrides the current operation for a drop that happens immediately |
|
|
421 |
* after the current validateDrop. |
406 |
* |
422 |
* |
407 |
* This maybe called only from within a |
423 |
* This maybe called only from within a |
408 |
* {@link #validateDrop(Object, int, TransferData)} method |
424 |
* {@link #validateDrop(Object, int, TransferData)} method |
409 |
* |
425 |
* |
410 |
* |
426 |
* |
411 |
* @param operation |
427 |
* @param operation |
412 |
* the operation to set to be current. |
428 |
* the operation to be used for the drop. |
413 |
* |
429 |
* |
414 |
* @see DND#DROP_COPY |
430 |
* @see DND#DROP_COPY |
415 |
* @see DND#DROP_MOVE |
431 |
* @see DND#DROP_MOVE |
Lines 418-427
Link Here
|
418 |
* |
434 |
* |
419 |
* @since 3.5 |
435 |
* @since 3.5 |
420 |
*/ |
436 |
*/ |
421 |
protected void setCurrentOperation(int operation) { |
437 |
protected void overrideOperation(int operation) { |
422 |
currentOperation = operation; |
438 |
overrideOperation = operation; |
423 |
} |
439 |
} |
424 |
|
440 |
|
425 |
/* (non-Javadoc) |
441 |
/* (non-Javadoc) |
426 |
* Method declared on DropTargetAdapter. |
442 |
* Method declared on DropTargetAdapter. |
427 |
* The mouse has moved over the drop target. If the |
443 |
* The mouse has moved over the drop target. If the |