changeset 6458:fab11b21ee6e

7143768: [macosx] Unexpected NullPointerException and java.io.IOException during DnD Reviewed-by: alexp
author kizune
date Thu, 24 Jan 2013 16:09:48 +0400
parents 40a45a72a120
children 7dd1896b37c8
files src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java
diffstat 1 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Thu Jan 24 15:55:04 2013 +0400
+++ b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Thu Jan 24 16:09:48 2013 +0400
@@ -273,8 +273,31 @@
 
     @Override
     protected ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList) throws IOException {
-        // TODO Auto-generated method stub
-        return null;
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        for (int i = 0; i < fileList.size(); i++)
+        {
+            byte[] bytes = fileList.get(i).getBytes();
+            bos.write(bytes, 0, bytes.length);
+            bos.write(0);
+        }
+        return bos;
+    }
+
+    @Override
+    protected boolean isURIListFormat(long format) {
+        String nat = getNativeForFormat(format);
+        if (nat == null) {
+            return false;
+        }
+        try {
+            DataFlavor df = new DataFlavor(nat);
+            if (df.getPrimaryType().equals("text") && df.getSubType().equals("uri-list")) {
+                return true;
+            }
+        } catch (Exception e) {
+            // Not a MIME format.
+        }
+        return false;
     }
 }