-
Enhancement
-
Resolution: Fixed
-
P3
-
1.4.0
-
03
-
x86
-
windows_2000
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2052889 | 5.0 | Shannon Hickey | P3 | Resolved | Fixed | b06 |
JDK-2052888 | 1.4.2 | Shannon Hickey | P3 | Resolved | Fixed | mantis |
JDK-2052887 | 1.4.1_02 | Shannon Hickey | P3 | Resolved | Fixed | 02 |
Name: rmT116609 Date: 03/20/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
DESCRIPTION OF THE PROBLEM :
Dragging links from IE to my application fails.
Dragging a link/URL from IE 5.5 causes the drag and drop procedure to execute and call canImport() on the drop target. canImport() returns true but TransferHandler fails to recognize DnDConstants.ACTION_LINK as a valid action
for the drop target and hence the drag is rejected. This is because TransferHandler is hardcoded to only recognize actions COPY or MOVE.
Refer to -
TransferHandler.java:617
(TransferHandler:DropHandler.actionSupported())
private static class DropHandler implements
DropTargetListener, Serializable {
private boolean canImport;
private boolean actionSupported(int action) {
617: return (action & COPY_OR_MOVE) != NONE;
}
//---------------------------------------------------------|
// At this point
// action = 0x40000000( DnDConstants.ACTION_LINK)and
// COPY_OR_MOVE = 0x3(DnDConstants.ACTION_COPY_OR_MOVE)
//
// hence actionPerformed() returns false and
// the drag is rejected at line 636.
//
// 636: if (canImport && actionSupported(dropAction)) {
// e.acceptDrag(dropAction);
// } else {
// e.rejectDrag();
//
//---------------------------------------------------------|
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try dragging a link from IE 5.5 (has nothing to do with IE version) to an application which accepts a DataFlavor with a MIME type of
"application/x-java-url; class=java.net.URL".
This bug can be reproduced always.
My problem is as follows -
- I have a GUI component which knows and accepts the data flavor in which URL's from IE are provided in, and has DnDConstants.ACTION_LINK as one of the
actions but the drag operation still gets aborted.
- I am using the TransferHandler class for implementing drag and drop in my application as this is the recommended way to implement drag and drop in JDK 1.4.
To illustrate the issue, please download and run my example code from
http://www.geocities.com/vjsvohra
when I drag a link from IE to the JTextArea component (MyText) in the program, the component understands and accepts the data flavor of the dragged URL (as
you can make out from the debug messages). MyText's canImport() returns true, but the problem comes in when the listeners setup by TransferHandler and it's
supporting classes don't recognize DnDConstants.ACTION_LINK as a valid action and abort the drag.
This happens in TransferHandler's private inner class 'DropHandler' which is hard coded to recognize COPY_OR_MOVE as the only valid actions ( method -
actionSupported() ).
CUSTOMER WORKAROUND :
TransferHandler.java:622
public void dragEnter(DropTargetDragEvent e) {
DataFlavor[] flavors = e.getCurrentDataFlavors();
JComponent c = (JComponent)e.getDropTargetContext
().getComponent();
TransferHandler importer = c.getTransferHandler();
if (importer != null && importer.canImport(c,
flavors)) {
canImport = true;
} else {
canImport = false;
}
int dropAction = e.getDropAction();
if (canImport && actionSupported(dropAction)) {
//---------------------------------------------------------|
// At this point, for a drop to be valid canImport should
// be true and the drop target should accept the current
// action
//
// One solution is to replace the above if condition with
//
// if( canImport &&
// ((importer.getSourceActions() & dropAction)!=NONE))
//
//---------------------------------------------------------|
e.acceptDrag(dropAction);
} else {
e.rejectDrag();
}
}
(Review ID: 139022)
======================================================================
- backported by
-
JDK-2052887 TransferHandler doesn't recognize ACTION_LINK as a valid drop action
-
- Resolved
-
-
JDK-2052888 TransferHandler doesn't recognize ACTION_LINK as a valid drop action
-
- Resolved
-
-
JDK-2052889 TransferHandler doesn't recognize ACTION_LINK as a valid drop action
-
- Resolved
-
- relates to
-
JDK-4735546 NPE in BasicTableUI during Swing drag and drop
-
- Closed
-