Class URLTransfer

  extended by org.eclipse.swt.dnd.Transfer
      extended by org.eclipse.swt.dnd.ByteArrayTransfer
          extended by org.gudy.azureus2.ui.swt.URLTransfer

public class URLTransfer
extends org.eclipse.swt.dnd.ByteArrayTransfer

URL Transfer type for Drag and Drop of URLs Windows IDs are already functional. Please use Win32TransferTypes to determine the IDs for other OSes!

Rene Leonhardt, TuxPaper (require incoming string types have an URL prefix), TuxPaper (UTF-8, UTF-16, BOM stuff) TuxPaper's Notes: This class is flakey. It's better to use HTMLTransfer, and then parse the URL from the HTML. However, IE drag and drops do not support HTMLTransfer, so this class must stay Windows --- TypeIDs seem to be assigned differently on different platform versions (or maybe even different installations!). Here's some examples 49314: Moz/IE 0x01 4-0x00 0x80 lots-of-0x00 "[D]URL" lots-more-0x00 49315: Moz/IE Same as 49315, except unicode 49313: Moz/IE URL in .url format "[InternetShortcut]\nURL=%1" 49324: Moz/IE URL in text format 49395: Moz Same as 49324, except unicode 49319: Moz Dragged HTML Fragment with position information 49398: Moz Dragged HTML Fragment (NO position information, just HTML), unicode 49396: Moz HTML. Unknown. There's probably a link to the ID and they type name in the registry, or via a Windows API call. We don't want to do that, and fortunately, SWT doesn't seem to pay attention to getTypeIds() on Windows, so we check every typeid we get to see if we can parse an URL from it. Also, dragging from the IE URL bar hangs SWT (sometimes for a very long time). Fortunately, most people willdrag the URL from the actual content window. Dragging an IE bookmark is actually dragging the .url file, and should be handled by the FileTranfer (and then opening it and extracting the URL). Moz Bookmarks are processed as HTML. Linux --- For Linux, this class isn't required. HTMLTransfer will take care of Gecko and Konquerer. Opera --- As of 8.5, Opera still doesn't allow dragging outside of itself (at least on windows)
See Also:

Nested Class Summary
static class URLTransfer.URLType
Constructor Summary
Method Summary
 URLTransfer.URLType bytebufferToJava(byte[] buffer)
static URLTransfer getInstance()
protected  int[] getTypeIds()
protected  String[] getTypeNames()
 boolean isSupportedType(org.eclipse.swt.dnd.TransferData transferData)
 void javaToNative(Object object, org.eclipse.swt.dnd.TransferData transferData)
static void main(String[] args)
          Test for varioud UTF Strings BOM information from
 Object nativeToJava(org.eclipse.swt.dnd.TransferData transferData)
static org.eclipse.swt.dnd.TransferData pickBestType(org.eclipse.swt.dnd.TransferData[] dataTypes, org.eclipse.swt.dnd.TransferData def)
          Sometimes, CF_Text will be in currentDataType even though CF_UNICODETEXT is present.
Methods inherited from class org.eclipse.swt.dnd.ByteArrayTransfer
Methods inherited from class org.eclipse.swt.dnd.Transfer
registerType, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public URLTransfer()
Method Detail


public static URLTransfer getInstance()


public void javaToNative(Object object,
                         org.eclipse.swt.dnd.TransferData transferData)
javaToNative in class org.eclipse.swt.dnd.ByteArrayTransfer


public Object nativeToJava(org.eclipse.swt.dnd.TransferData transferData)
nativeToJava in class org.eclipse.swt.dnd.ByteArrayTransfer


public URLTransfer.URLType bytebufferToJava(byte[] buffer)


protected String[] getTypeNames()
Specified by:
getTypeNames in class org.eclipse.swt.dnd.Transfer


protected int[] getTypeIds()
Specified by:
getTypeIds in class org.eclipse.swt.dnd.Transfer


public boolean isSupportedType(org.eclipse.swt.dnd.TransferData transferData)
isSupportedType in class org.eclipse.swt.dnd.ByteArrayTransfer
transferData -
See Also:


public static org.eclipse.swt.dnd.TransferData pickBestType(org.eclipse.swt.dnd.TransferData[] dataTypes,
                                                            org.eclipse.swt.dnd.TransferData def)
Sometimes, CF_Text will be in currentDataType even though CF_UNICODETEXT is present. This is a workaround until its fixed properly.

Place it in dropAccept

if ( instanceof URLTransfer.URLType)
        event.currentDataType = URLTransfer.pickBestType(event.dataTypes, event.currentDataType);

dataTypes -
def -


public static void main(String[] args)
Test for varioud UTF Strings BOM information from

args -