Re: Dragging an image from Webpage within Firefox no longer provides it as DataFlavour java.net.URL/java.util.List on OSX with Java 7

2014-01-15 Thread Hendrik Schreiber
On Jan 13, 2014, at 18:36, Petr Pchelko petr.pche...@oracle.com wrote:

Hey Petr!

Thank! Please find the requested info below.

 We’ve had numerous regression in datatransfer area in JDK-8 but wight now 
 they should all be fixed. 
 
 However the URI transfer on Mac OS X still does not work in some cases, it’s 
 simply not implemented. 
 I have a related issue: https://bugs.openjdk.java.net/browse/JDK-7124379
 
 Could you please clarify 
 1. what exactly you are trying do drag 
 2. how you do it (do you select a text+picture or just picture or just drag 
 without selection)
 3. which browser versions do you use
 4. what result do are expect. 
 I’ll have a look at it and either fix it under an JDK-7124379 or file a new 
 CR for you.

1. (to make this easy) I'm dragging the OpenJDK image on 
http://openjdk.java.net
2. Just the image, no text or anything else.
3. FireFox 26, Chrome 31 and Safari 7.0.1 on OS X 10.9.1.
4. I expect at least a 
mimetype=application/x-java-url;representationclass=java.net.URL data flavor, 
just like Java 6 provided. Additionally, I expect a 
mimetype=image/x-java-image;representationclass=java.awt.Image, some 
text/plain data flavors that allow me to retrieve the URL as String, and (I 
guess) a text/uri-list data flavor, because it just makes sense.


The worst case is Chrome 31 -- Java build 1.8.0-ea-b121; only a 
java.awt.Image is provided.
When dragging from Firefox 26, all flavors seem to occur 3 times.
According to the docs for Transferable#getTransferDataFlavors():

 * Returns an array of DataFlavor objects indicating the flavors the data
 * can be provided in.  The array should be ordered according to preference
 * for providing the data (from most richly descriptive to least 
descriptive).

Unfortunately, I cannot recognize a meaningful ordering in Java 8.

I conducted a bunch of tests with the following source code:

import javax.swing.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;

public class DragHere {

public static void main(String[] args) {
final JFrame frame = new JFrame();
final JPanel panel = new JPanel();
frame.getContentPane().add(panel);
panel.setTransferHandler(new TransferHandler(){
@Override
public boolean canImport(final TransferSupport support) {
return true;
}

@Override
public boolean importData(final TransferSupport support) {
final Transferable transferable = support.getTransferable();
final DataFlavor[] flavors = 
transferable.getTransferDataFlavors();
for (final DataFlavor flavor : flavors){
try {
final Object transferData = 
transferable.getTransferData(flavor);
System.out.print(flavor + :\t);
System.out.println(transferData);
} catch (UnsupportedFlavorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
});
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame.setBounds(100, 100, 100, 100);
frame.setVisible(true);
}
});
}
}


When dragging the OpenJDK image on http://openjdk.java.net onto the panel, I 
get the following output, showing supported flavors and their values for 
different browsers and JVMs.

Safari 7.0.1 -- Java 1.6.0_65:

java.awt.datatransfer.DataFlavor[mimetype=application/x-java-url;representationclass=java.net.URL]:
 http://openjdk.java.net/images/openjdk.png
java.awt.datatransfer.DataFlavor[mimetype=image/x-java-image;representationclass=java.awt.Image]:
   BufferedImage@2e00e753: type = 3 DirectColorModel: rmask=ff 
gmask=ff00 bmask=ff amask=ff00 IntegerInterleavedRaster: width = 300 height 
= 82 #Bands = 4 xOff = 0 yOff = 0 dataOffset[0] 0
java.awt.datatransfer.DataFlavor[mimetype=text/uri-list;representationclass=java.io.Reader]:
java.io.InputStreamReader@49dc423f
java.awt.datatransfer.DataFlavor[mimetype=text/uri-list;representationclass=java.lang.String]:
  http://openjdk.java.net/images/openjdk.png
java.awt.datatransfer.DataFlavor[mimetype=text/uri-list;representationclass=java.nio.CharBuffer]:
   http://openjdk.java.net/images/openjdk.png
java.awt.datatransfer.DataFlavor[mimetype=text/uri-list;representationclass=[C]:
[C@474b5f4a
java.awt.datatransfer.DataFlavor[mimetype=text/uri-list;representationclass=java.io.InputStream;charset=UTF-16]:
sun.awt.datatransfer.DataTransferer$ReencodingInputStream@255d17d7

Re: Dragging an image from Webpage within Firefox no longer provides it as DataFlavour java.net.URL/java.util.List on OSX with Java 7

2014-01-15 Thread Hendrik Schreiber

On Jan 15, 2014, at 14:31, Hendrik Schreiber h...@tagtraum.com wrote:

 On Jan 13, 2014, at 18:36, Petr Pchelko petr.pche...@oracle.com wrote:
 


Additionally, I'm under the impression that when dragging a file from Finder, I 
do get a DataFlavor.javaFileListFlavor as flavor, but when I request the actual 
data via transferable.getTransferData(dataFlavor), I only get null. This is 
also in Java 8 b121.

Cheers,

-hendrik



Re: Dragging an image from Webpage within Firefox no longer provides it as DataFlavour java.net.URL/java.util.List on OSX with Java 7

2014-01-15 Thread Petr Pchelko
Hello, Hendrik.

Thank you for the great bug reporting.

The problem with ordering is known and it's tracked under: 
https://bugs.openjdk.java.net/browse/JDK-8027148

As for the lack of DataFlavors - I've filed the following bug: 
https://bugs.openjdk.java.net/browse/JDK-8031964

Also, thank you for noticing that something is wrong with the Finder. I think I 
know the reason, but anyway I've filed 
https://bugs.openjdk.java.net/browse/JDK-8031965

With best regards. Petr.

On 15.01.2014, at 17:31, Hendrik Schreiber h...@tagtraum.com wrote:

 On Jan 13, 2014, at 18:36, Petr Pchelko petr.pche...@oracle.com wrote:
 
 Hey Petr!
 
 Thank! Please find the requested info below.
 
 We’ve had numerous regression in datatransfer area in JDK-8 but wight now 
 they should all be fixed. 
 
 However the URI transfer on Mac OS X still does not work in some cases, it’s 
 simply not implemented. 
 I have a related issue: https://bugs.openjdk.java.net/browse/JDK-7124379
 
 Could you please clarify 
 1. what exactly you are trying do drag 
 2. how you do it (do you select a text+picture or just picture or just drag 
 without selection)
 3. which browser versions do you use
 4. what result do are expect. 
 I’ll have a look at it and either fix it under an JDK-7124379 or file a new 
 CR for you.
 
 1. (to make this easy) I'm dragging the OpenJDK image on 
 http://openjdk.java.net
 2. Just the image, no text or anything else.
 3. FireFox 26, Chrome 31 and Safari 7.0.1 on OS X 10.9.1.
 4. I expect at least a 
 mimetype=application/x-java-url;representationclass=java.net.URL data 
 flavor, just like Java 6 provided. Additionally, I expect a 
 mimetype=image/x-java-image;representationclass=java.awt.Image, some 
 text/plain data flavors that allow me to retrieve the URL as String, and (I 
 guess) a text/uri-list data flavor, because it just makes sense.
 
 
 The worst case is Chrome 31 -- Java build 1.8.0-ea-b121; only a 
 java.awt.Image is provided.
 When dragging from Firefox 26, all flavors seem to occur 3 times.
 According to the docs for Transferable#getTransferDataFlavors():
 
 * Returns an array of DataFlavor objects indicating the flavors the data
 * can be provided in.  The array should be ordered according to preference
 * for providing the data (from most richly descriptive to least 
 descriptive).
 
 Unfortunately, I cannot recognize a meaningful ordering in Java 8.
 
 I conducted a bunch of tests with the following source code:
 
 import javax.swing.*;
 import java.awt.datatransfer.DataFlavor;
 import java.awt.datatransfer.Transferable;
 import java.awt.datatransfer.UnsupportedFlavorException;
 import java.io.IOException;
 
 public class DragHere {
 
public static void main(String[] args) {
final JFrame frame = new JFrame();
final JPanel panel = new JPanel();
frame.getContentPane().add(panel);
panel.setTransferHandler(new TransferHandler(){
@Override
public boolean canImport(final TransferSupport support) {
return true;
}
 
@Override
public boolean importData(final TransferSupport support) {
final Transferable transferable = support.getTransferable();
final DataFlavor[] flavors = 
 transferable.getTransferDataFlavors();
for (final DataFlavor flavor : flavors){
try {
final Object transferData = 
 transferable.getTransferData(flavor);
System.out.print(flavor + :\t);
System.out.println(transferData);
} catch (UnsupportedFlavorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
});
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame.setBounds(100, 100, 100, 100);
frame.setVisible(true);
}
});
}
 }
 
 
 When dragging the OpenJDK image on http://openjdk.java.net onto the panel, 
 I get the following output, showing supported flavors and their values for 
 different browsers and JVMs.
 
 Safari 7.0.1 -- Java 1.6.0_65:
 
 java.awt.datatransfer.DataFlavor[mimetype=application/x-java-url;representationclass=java.net.URL]:
http://openjdk.java.net/images/openjdk.png
 java.awt.datatransfer.DataFlavor[mimetype=image/x-java-image;representationclass=java.awt.Image]:
  BufferedImage@2e00e753: type = 3 DirectColorModel: rmask=ff 
 gmask=ff00 bmask=ff amask=ff00 IntegerInterleavedRaster: width = 300 
 height = 82 #Bands = 4 xOff = 0 yOff = 0 dataOffset[0] 0
 java.awt.datatransfer.DataFlavor[mimetype=text/uri-list;representationclass=java.io.Reader]:
   java.io.InputStreamReader@49dc423f
 

Re: Dragging an image from Webpage within Firefox no longer provides it as DataFlavour java.net.URL/java.util.List on OSX with Java 7

2014-01-13 Thread Paul Taylor

On 13/01/2014 16:27, Hendrik Schreiber wrote:

On Jan 13, 2014, at 14:14, Paul Taylor paul_t...@fastmail.fm wrote:


Hi, yes it is fixed in early access version of Java 8

http://download.java.net/jdk8/changes/jdk8-b119.html?q=download/jdk8/changes/jdk8-b119.html

Was this fixed by http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8027913 or 
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7124253?

Have you verified the fix?

When dragging a JPEG (which is not embedded in HTML) from a web browser to my 
app, I never get a URL or a File list flavor. What I reliably see is:

java.awt.datatransfer.DataFlavor[mimetype=image/x-java-image;representationclass=java.awt.Image]

and depending on the browser a bunch of other text/... flavors. But I'd much 
rather have a URL or a file...

This is on OS X 10.9.1 and FireFox 26, Chrome 31 and Safari 7.0.1, Java build 
1.8.0-ea-b121.

Cheers,

-hendrik


I verified it was now working , but in my use case the jpeg is within 
the html file so maybe that is the difference


paul


Re: Dragging an image from Webpage within Firefox no longer provides it as DataFlavour java.net.URL/java.util.List on OSX with Java 7

2014-01-13 Thread Paul Taylor

On 13/01/2014 16:47, Hendrik Schreiber wrote:

On Jan 13, 2014, at 17:38, Paul Taylor paul_t...@fastmail.fm wrote:


I verified it was now working , but in my use case the jpeg is within the html 
file so maybe that is the difference

I just tried that as well: no difference :-(

Which OS X and Java version did you test with?
I tried 10.9.1 and java 1.8.0-b121.

-hendrik
Hmm, maybe are talking about different things I had two issues, one was 
fixed by the final version of java 7, and issue with Chrome was fixed 
with Java 8 build 119 but its a while ago now I'm not sure on the details


Paul


Re: Dragging an image from Webpage within Firefox no longer provides it as DataFlavour java.net.URL/java.util.List on OSX with Java 7

2014-01-13 Thread Petr Pchelko
Hello, Hendrik.

 I just tried that as well: no difference :-(

We’ve had numerous regression in datatransfer area in JDK-8 but wight now they 
should all be fixed. 

However the URI transfer on Mac OS X still does not work in some cases, it’s 
simply not implemented. 
I have a related issue: https://bugs.openjdk.java.net/browse/JDK-7124379

Could you please clarify 
1. what exactly you are trying do drag 
2. how you do it (do you select a text+picture or just picture or just drag 
without selection)
3. which browser versions do you use
4. what result do are expect. 
I’ll have a look at it and either fix it under an JDK-7124379 or file a new CR 
for you.

With best regards. Petr.

13 янв. 2014 г., в 8:47 после полудня, Hendrik Schreiber h...@tagtraum.com 
написал(а):

 On Jan 13, 2014, at 17:38, Paul Taylor paul_t...@fastmail.fm wrote:
 
 I verified it was now working , but in my use case the jpeg is within the 
 html file so maybe that is the difference
 
 I just tried that as well: no difference :-(
 
 Which OS X and Java version did you test with?
 I tried 10.9.1 and java 1.8.0-b121.
 
 -hendrik



Dragging an image from Webpage within Firefox no longer provides it as DataFlavour java.net.URL/java.util.List on OSX with Java 7

2013-11-25 Thread Paul Taylor
So on Windows with Java 7  I receive an image dragged frrm a webpage in 
these flavours (plus others) but these are two I'm interested in


25/11/2013 
10.31.07:com.jthink.jaikoz.draganddrop.FileDropTarget:drop:SEVERE: 
java.awt.datatransfer.DataFlavor[mimetype=application/x-java-url;representationclass=java.net.URL]
25/11/2013 
10.31.07:com.jthink.jaikoz.draganddrop.FileDropTarget:drop:SEVERE: 
java.awt.datatransfer.DataFlavor[mimetype=application/x-java-file-list;representationclass=java.util.List]


On OSX with Java 6 I received at least one of the two above, but now 
with Java 7 (1.7.0_40) I no longer receive either


I found these bugs that seem related

https://bugs.openjdk.java.net/browse/JDK-7124379
https://bugs.openjdk.java.net/browse/JDK-8005932

Could I have a comment on this please.

Paul