[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: SWT vs SWING/AWT Drag and drop

Hi Sheldon,

That's great detective work. I thought it was just the mime type. Thanks for posting back.

Duong

=====================================
Solution:
=====================================
At run time, I tried calling:
       int maxSize = 128;
       TCHAR buffer = new TCHAR(0, maxSize);
       int size = COM.GetClipboardFormatName(49948, buffer, maxSize);
       System.out.println("size=" + size + ", buffer= " + buffer);

(where 49948 is the ID that was passed in the transferData DnD object).

Out comes...
size=107, buffer= JAVA_DATAFLAVOR:application/x-java-serialized-object; class=com.mydomain.CustomClass

....!!! It's the DataFlavor generated MIME type String, with a prefix!

So, I changed my SWT Transfer:

public final CustomTransfer extends ByteArrayTransfer{ private static final String TYPE_NAME = "JAVA_DATAFLAVOR:" + customFlavor .getMimeType();
private static final int TYPE_ID = registerType (TYPE_NAME );


    protected int[] getTypeIds() {
       return new int[] { TYPE_ID };
    }
}