|
Lines 181-187
Link Here
|
| 181 |
* that it is still enabled. |
181 |
* that it is still enabled. |
| 182 |
*/ |
182 |
*/ |
| 183 |
private void doDropValidation(DropTargetEvent event) { |
183 |
private void doDropValidation(DropTargetEvent event) { |
| 184 |
currentOperation= validateDrop(currentTarget, lastValidOperation, event.currentDataType); |
184 |
currentOperation= getDefaultDropOperation(currentTarget, lastValidOperation, event.currentDataType); |
| 185 |
event.detail = currentOperation; |
185 |
event.detail = currentOperation; |
| 186 |
} |
186 |
} |
| 187 |
|
187 |
|
|
Lines 237-244
Link Here
|
| 237 |
currentLocation = determineLocation(event); |
237 |
currentLocation = determineLocation(event); |
| 238 |
|
238 |
|
| 239 |
//perform the drop behavior |
239 |
//perform the drop behavior |
| 240 |
currentOperation= performDrop(event.data); |
240 |
if (!performDrop(event.data)) { |
| 241 |
event.detail= currentOperation; |
241 |
event.detail = DND.DROP_NONE; |
|
|
242 |
} |
| 243 |
currentOperation = event.detail; |
| 242 |
} |
244 |
} |
| 243 |
|
245 |
|
| 244 |
/* (non-Javadoc) |
246 |
/* (non-Javadoc) |
|
Lines 246-252
Link Here
|
| 246 |
* Last chance for the action to disable itself |
248 |
* Last chance for the action to disable itself |
| 247 |
*/ |
249 |
*/ |
| 248 |
public void dropAccept(DropTargetEvent event) { |
250 |
public void dropAccept(DropTargetEvent event) { |
| 249 |
event.detail= validateDrop(currentTarget, event.detail, event.currentDataType); |
251 |
event.detail= getDefaultDropOperation(currentTarget, event.detail, event.currentDataType); |
| 250 |
} |
252 |
} |
| 251 |
|
253 |
|
| 252 |
/** |
254 |
/** |
|
Lines 367-373
Link Here
|
| 367 |
* @return <code>true</code> if the drop was successful, and |
369 |
* @return <code>true</code> if the drop was successful, and |
| 368 |
* <code>false</code> otherwise |
370 |
* <code>false</code> otherwise |
| 369 |
*/ |
371 |
*/ |
| 370 |
public abstract int performDrop(Object data); |
372 |
public abstract boolean performDrop(Object data); |
| 371 |
|
373 |
|
| 372 |
/* (non-Javadoc) |
374 |
/* (non-Javadoc) |
| 373 |
* Method declared on DropTargetAdapter. |
375 |
* Method declared on DropTargetAdapter. |
|
Lines 479-492
Link Here
|
| 479 |
* @return <code>true</code> if the drop is valid, and <code>false</code> |
481 |
* @return <code>true</code> if the drop is valid, and <code>false</code> |
| 480 |
* otherwise |
482 |
* otherwise |
| 481 |
*/ |
483 |
*/ |
| 482 |
public abstract int validateDrop(Object target, int operation, |
484 |
public abstract boolean validateDrop(Object target, int operation, |
| 483 |
TransferData transferType); |
485 |
TransferData transferType); |
| 484 |
|
486 |
|
| 485 |
/** |
487 |
/** |
| 486 |
* For testing only. The location should not be set otherwise. |
488 |
* Get the default drop operation on the given object. This method is called whenever some |
| 487 |
* @param location the location to assume |
489 |
* aspect of the drop operation changes. |
| 488 |
*/ |
490 |
* <p> |
| 489 |
protected void setCurrentLocation(int location) { |
491 |
* The default operation is the one used when no modifier key is pressed by the user. |
| 490 |
currentLocation= location; |
492 |
* </p> |
| 491 |
} |
493 |
* <p> |
|
|
494 |
* Subclasses can overwrite this method to define which operation does make |
| 495 |
* sense on the drop target. |
| 496 |
* </p> |
| 497 |
* |
| 498 |
* @param target the object that the mouse is currently hovering over, or |
| 499 |
* <code>null</code> if the mouse is hovering over empty space |
| 500 |
* @param operation the current drag operation (copy, move, etc.) |
| 501 |
* @param transferType the current transfer type |
| 502 |
* @return the operation which will be executed if no modifier key is pressed |
| 503 |
* by the user |
| 504 |
* |
| 505 |
* @see DND#DROP_NONE |
| 506 |
* @see DND#DROP_MOVE |
| 507 |
* @see DND#DROP_COPY |
| 508 |
* @see DND#DROP_LINK |
| 509 |
*/ |
| 510 |
protected int getDefaultDropOperation(Object target, int operation, TransferData transferType) { |
| 511 |
if (!validateDrop(target, operation, transferType)) { |
| 512 |
return DND.DROP_NONE; |
| 513 |
} |
| 514 |
|
| 515 |
return operation; |
| 516 |
} |
| 492 |
} |
517 |
} |