JDK-4746177 : DnD of an URL from Mozilla (Netscape 6.2) to Java doesn't work
  • Type: Enhancement
  • Status: Resolved
  • Resolution: Fixed
  • Component: client-libs
  • Sub-Component: java.awt
  • Priority: P4
  • Affected Version: 1.4.1
  • OS: generic
  • CPU: generic
  • Submit Date: 2002-09-12
  • Updated Date: 2008-11-05
  • Resolved Date: 2002-11-15
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 Availabitlity Release.

To download the current JDK release, click here.
Other
1.4.2 mantisResolved
Related Reports
Relates :  
Description

Name: dsR10078			Date: 09/12/2002

###@###.###

The problem is reproducible with JDK 1.4.1-b21 on linux and solaris.
To reproduce compile and run the following test case:
-----------------------------------------------------------------------------------
import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.dnd.*;

public class DnDTest {
     public static void main(String[] args) {
         final Frame f = new Frame("Source");
         final DropTargetListener dtl = new DropTargetAdapter() {
                 public void drop(DropTargetDropEvent dtde) {
                     int action = dtde.getDropAction();
                     System.out.println("[Target] drop");
                     if (action != DnDConstants.ACTION_NONE) {
                         dtde.acceptDrop(action);
                         Transferable t = dtde.getTransferable();
                         DataFlavor[] dfs = t.getTransferDataFlavors();
                         System.out.println(dfs.length + " flavors available");
                         for (int i = 0; i < dfs.length; i++) {
                             System.out.println("    " + dfs[i]);
                         }
                         dtde.dropComplete(true);
                     } else {
                         dtde.rejectDrop();
                     }
                 }
             };
         final DropTarget dt = new DropTarget(f, dtl);
         f.setBounds(100, 100, 200, 200);
         f.setVisible(true);
     }
}
-----------------------------------------------------------------------------------
A frame will appear. 
Run Netscape 6.2, drag an URL from browser and drop it onto a frame.
The console output of the test reports that no flavors are available:
-----------------------------------------------------------------------------------
[Target] drop
0 flavors available
-----------------------------------------------------------------------------------
The browser version string:
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20020326 

Note that the problem is not reproducible with Netscape 4.76.
When an URL is dragged from it and dropped onto the Java frame the output is as follows:
-----------------------------------------------------------------------------------
[Target] drop
25 flavors available
    java.awt.datatransfer.DataFlavor[mimetype=application/x-java-serialized-object;representationclass=java.lang.String]
    java.awt.datatransfer.DataFlavor[mimetype=application/x-java-file-list;representationclass=java.util.List]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.Reader]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.lang.String]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.CharBuffer]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[C]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=UTF-16]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-16]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=UTF-16]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=UTF-8]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-8]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=UTF-8]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=UTF-16BE]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-16BE]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=UTF-16BE]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=UTF-16LE]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-16LE]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=UTF-16LE]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=unicode]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=ISO-8859-1]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=ISO-8859-1]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=ISO-8859-1]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=US-ASCII]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=US-ASCII]
    java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=US-ASCII]
-----------------------------------------------------------------------------------
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis FIXED IN: mantis INTEGRATED IN: mantis mantis-b08
2004-06-14

SUGGESTED FIX Name: dsR10078 Date: 10/26/2002 Ideally we should handle the general case when the data provider uses MIME types instead of the registered selection targets to represent the available data formats. Anyway, we will have to do it as a part of the fix for 4638443 (XDnD support), as XDnD protocol explicitly states that the atom names of the data types are the corresponding MIME types. This requires substantial changes to the Data Transfer subsystem, so for Mantis we suggest a minimal solution: add a mapping for text/plain format to the flavormap.properties. Note, that this mapping should have lower priority than those for UTF8_STRING and COMPOUND_TEXT, as this format is unable to represent an arbitrary Unicode string. --- flavormap.properties Sat Oct 26 11:38:42 2002 *************** *** 73,78 **** --- 73,79 ---- TEXT=text/plain;eoln="\n";terminators=0 STRING=text/plain;charset=iso8859-1;eoln="\n";terminators=0 + text/plain=text/plain;eoln="\n";terminators=0 FILE_NAME=application/x-java-file-list;class=java.util.List PNG=image/x-java-image;class=java.awt.Image JFIF=image/x-java-image;class=java.awt.Image ###@###.### 2002-10-26 ======================================================================
2002-10-26

EVALUATION Commit to fix in Mantis. ###@###.### 2002-09-22 Name: dsR10078 Date: 10/26/2002 The cause is that when an URL is dragged from Netscape 6.2, the drag source exports the following native formats (Atom names are listed): _NETSCAPE_URL text/plain text/unicode text/x-moz-url text/html None of them is a registered selection target (see ICCCM 2.6.2), and none of them is currently supported by JRE. That's why Java applications are unable to retrieve the transfer data in this case. ###@###.### 2002-10-26 ======================================================================
2002-10-26

WORK AROUND Name: dsR10078 Date: 09/12/2002 1.Add a new mapping between native format and Java flavor to the SystemFlavorMap. This can be done with the following static initializer for the class: ----------------------------------------------------------------------------------- static { final SystemFlavorMap sfm = (SystemFlavorMap)SystemFlavorMap.getDefaultFlavorMap(); final String nat = "text/plain"; final DataFlavor df = new DataFlavor("text/plain; charset=ASCII; class=java.io.InputStream", "Plain Text"); sfm.addUnencodedNativeForFlavor(df, nat); sfm.addFlavorForUnencodedNative(nat, df); } ----------------------------------------------------------------------------------- 2.Append the following line to the lib/flavormap.properties in the JRE installation: ----------------------------------------------------------------------------------- text/plain=text/plain;eoln="\n";terminators=0 ----------------------------------------------------------------------------------- With either of the two changes the console output looks as follows: ----------------------------------------------------------------------------------- [Target] drop 1 flavors available java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=ASCII] ----------------------------------------------------------------------------------- and the dropped URL can be successfully retrieved using this flavor. Note that the first solution enables URL drop support for the single program run on any JRE installation, while the second solution enables it for any program run on the single JRE installation. ###@###.### 2002-09-12 ======================================================================
2002-09-12