JDK-6379813 : TransferHandler should allow the developer to choose the drop action
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
In canImport() and importData(), the developer can query the drop action on the TransferInfo. However, they need to also be able to query the source actions and pick a different one.
This support has been added as follows:
TransferHandler.TransferInfo, which previously only provided information on the transfer, has been renamed to TransferHandler.TransferSupport and has been given behavior and more methods. New informational methods are:
getSourceDropActions() - returns the actions supported by the source of the transfer
getUserDropAction() - returns the action chosen by the user with their gesture
The developer can query these actions in canImport() and choose an action different from the user action by calling setDropAction() on the TransferSupport.
When a drop occurs, the final chosen action can be queried with the getDropAction() method.
As part of this fix, and additional change has been made to TransferHandler. To save the developer from having to override another method, the method shouldIndicate() has been removed from TransferHandler and moved into TransferSupport, with the name setShowDropLocation, to be called from canImport().