summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine <veronika>2002-05-07 11:44:14 +0000
committerVeronika Irvine <veronika>2002-05-07 11:44:14 +0000
commitd01864955fb125fc04d2f61d759e3f0094bdb63e (patch)
tree8af2660126520b138b8b22bc14a022b3d16b7c80
parent24ab2e2d5942b511aea808aadde3c571e63acdf9 (diff)
downloadeclipse.platform.swt-d01864955fb125fc04d2f61d759e3f0094bdb63e.tar.gz
eclipse.platform.swt-d01864955fb125fc04d2f61d759e3f0094bdb63e.tar.xz
eclipse.platform.swt-d01864955fb125fc04d2f61d759e3f0094bdb63e.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.swt/.classpath_gtk2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ByteArrayTransfer.java62
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Clipboard.java176
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java146
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java132
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/FileTransfer.java98
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/RTFTransfer.java79
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TextTransfer.java81
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Transfer.java58
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TransferData.java35
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java6
11 files changed, 872 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/.classpath_gtk b/bundles/org.eclipse.swt/.classpath_gtk
index 06bb46a057..29deb82a9e 100644
--- a/bundles/org.eclipse.swt/.classpath_gtk
+++ b/bundles/org.eclipse.swt/.classpath_gtk
@@ -10,7 +10,7 @@
<classpathentry kind="src" path="Eclipse SWT PI/common_j2se"/>
<classpathentry kind="src" path="Eclipse SWT Accessibility/emulated"/>
<classpathentry kind="src" path="Eclipse SWT Accessibility/common"/>
- <classpathentry kind="src" path="Eclipse SWT Drag and Drop/emulated"/>
+ <classpathentry kind="src" path="Eclipse SWT Drag and Drop/gtk"/>
<classpathentry kind="src" path="Eclipse SWT Drag and Drop/common"/>
<classpathentry kind="src" path="Eclipse SWT Printing/gtk"/>
<classpathentry kind="src" path="Eclipse SWT Printing/common"/>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ByteArrayTransfer.java
new file mode 100644
index 0000000000..dde8f9e634
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/ByteArrayTransfer.java
@@ -0,0 +1,62 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.gtk.OS;
+
+/**
+ * The class <code>ByteArrayTransfer</code> provides a platform specific mechanism for transforming
+ * a Java array of bytes into a format that can be passed around in a Drag and Drop operation and vice
+ * versa.
+ *
+ * <p>This abstract class can be subclassed to provided utilities for transforming Java data types
+ * into the byte array based platform specific drag and drop data types. See TextTransfer and
+ * FileTransfer for examples. If the data you are transferring <b>does not</b> map to a byte array,
+ * you should sub-class Transfer directly and do your own mapping to the platform data types.</p>
+ */
+public abstract class ByteArrayTransfer extends Transfer {
+
+public TransferData[] getSupportedTypes(){
+ int[] types = getTypeIds();
+ TransferData[] data = new TransferData[types.length];
+ for (int i = 0; i < types.length; i++) {
+ data[i] = new TransferData();
+ data[i].type = types[i];
+ }
+ return data;
+}
+
+public boolean isSupportedType(TransferData transferData){
+ if ( transferData == null ) return false;
+ int[] types = getTypeIds();
+ for (int i = 0; i < types.length; i++) {
+ if (transferData.type == types[i]) return true;
+ }
+ return false;
+}
+
+protected void javaToNative (Object object, TransferData transferData){
+ if ((object == null) || !(object instanceof byte[]) || !(isSupportedType(transferData))) {
+ transferData.result = 0;
+ return;
+ }
+ byte[] buffer = (byte[])object;
+ transferData.pValue = OS.g_malloc(buffer.length);
+ OS.memmove(transferData.pValue, buffer, buffer.length);
+ transferData.length = buffer.length;
+ transferData.format = 8;
+ transferData.result = 1;
+}
+
+protected Object nativeToJava(TransferData transferData){
+ if ( !isSupportedType(transferData) || transferData.pValue == 0 ) return null;
+ int size = transferData.format * transferData.length / 8;
+ byte[] buffer = new byte[size];
+ OS.memmove(buffer, transferData.pValue, size);
+ return buffer;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Clipboard.java
new file mode 100644
index 0000000000..f022ac4458
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Clipboard.java
@@ -0,0 +1,176 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.GtkSelectionData;
+import org.eclipse.swt.internal.gtk.GtkTargetEntry;
+import org.eclipse.swt.internal.gtk.OS;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ */
+public class Clipboard {
+
+ Display display;
+ Callback getFunc;
+ Callback clearFunc;
+ int pGtkClipboard;
+
+ /* Data is not flushed to the clipboard immediately.
+ * This class will remember the data and provide it when requested. */
+ Object[] data;
+ Transfer[] dataTypes;
+
+public Clipboard(Display display) {
+ checkSubclass ();
+ if (display == null) {
+ display = Display.getCurrent();
+ if (display == null) {
+ display = Display.getDefault();
+ }
+ }
+ if (display.getThread() != Thread.currentThread()) {
+ SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.display = display;
+ getFunc = new Callback( this, "getFunc", 4);
+ clearFunc = new Callback( this, "clearFunc", 2);
+ pGtkClipboard = OS.gtk_clipboard_get(OS.GDK_NONE);
+}
+
+int clearFunc(int clipboard,int user_data_or_owner){
+ data = null;
+ dataTypes = null;
+ return 1;
+}
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = Clipboard.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+
+public void dispose () {
+ if (pGtkClipboard == 0) return;
+ if (data != null) OS.gtk_clipboard_clear(pGtkClipboard);
+ OS.g_free(pGtkClipboard);
+ pGtkClipboard = 0;
+ display = null;
+ if (getFunc != null ) getFunc.dispose();
+ getFunc = null;
+ if (clearFunc != null) clearFunc.dispose();
+ clearFunc = null;
+}
+
+public Object getContents(Transfer transfer) {
+ if (transfer == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int selection_data = 0;
+ int[] typeIds = transfer.getTypeIds();
+ for (int i = 0; i < typeIds.length; i++) {
+ selection_data = OS.gtk_clipboard_wait_for_contents(pGtkClipboard, typeIds[i]);
+ if( selection_data != 0) break;
+ };
+ if (selection_data == 0) return null; // No data available for this transfer
+
+ GtkSelectionData gtkSelectionData = new GtkSelectionData();
+ OS.memmove(gtkSelectionData, selection_data, GtkSelectionData.sizeof);
+ TransferData tdata = new TransferData();
+ tdata.type = gtkSelectionData.target;
+ tdata.pValue = gtkSelectionData.data;
+ tdata.length = gtkSelectionData.length;
+ tdata.format = gtkSelectionData.format;
+ Object result = transfer.nativeToJava(tdata);
+ OS.gtk_selection_data_free(selection_data);
+ return result;
+}
+
+/**
+ * This function provides the data to the clipboard on request.
+ * When this clipboard is disposed, the data will no longer be available.
+ */
+int getFunc( int clipboard, int selection_data, int info, int user_data_or_owner){
+ if (selection_data == 0) return 0;
+ GtkSelectionData selectionData = new GtkSelectionData();
+ OS.memmove(selectionData, selection_data, GtkSelectionData.sizeof);
+ TransferData tdata = new TransferData();
+ tdata.type = selectionData.target;
+ int index = -1;
+ for (int i = 0; i < dataTypes.length; i++) {
+ if (dataTypes[i].isSupportedType(tdata)) {
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) return 0;
+ dataTypes[index].javaToNative(data[index], tdata);
+ OS.gtk_selection_data_set(selection_data, tdata.type, tdata.format, tdata.pValue, tdata.length);
+ return 1;
+}
+
+public void setContents(Object[] data, Transfer[] dataTypes){
+ if (data == null || dataTypes == null || data.length != dataTypes.length) {
+ DND.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (display.isDisposed() ) DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+ if (dataTypes.length == 0) return;
+
+ if (this.data != null) {
+ OS.gtk_clipboard_clear(pGtkClipboard);
+ }
+
+ GtkTargetEntry[] entries = new GtkTargetEntry [0];
+ for (int i = 0; i < dataTypes.length; i++) {
+ Transfer transfer = dataTypes[i];
+ int[] typeIds = transfer.getTypeIds();
+ String[] typeNames = transfer.getTypeNames();
+ for (int j = 0; j < typeIds.length; j++) {
+ GtkTargetEntry entry = new GtkTargetEntry();
+ entry.info = typeIds[j];
+ byte[] buffer = Converter.wcsToMbcs(null, typeNames[j], true);
+ int pName = OS.g_malloc(buffer.length);
+ OS.memmove(pName, buffer, buffer.length);
+ entry.target = pName;
+ GtkTargetEntry[] tmp = new GtkTargetEntry [entries.length + 1];
+ System.arraycopy(entries, 0, tmp, 0, entries.length);
+ tmp[entries.length] = entry;
+ entries = tmp;
+ }
+ }
+
+ int pTargetsList = OS.g_malloc(GtkTargetEntry.sizeof * entries.length);
+ int offset = 0;
+ for (int i = 0; i < entries.length; i++) {
+ OS.memmove(pTargetsList + offset, entries[i], GtkTargetEntry.sizeof);
+ offset += GtkTargetEntry.sizeof;
+ }
+
+ this.data = data;
+ this.dataTypes = dataTypes;
+
+ boolean result = OS.gtk_clipboard_set_with_data(pGtkClipboard, pTargetsList, entries.length, getFunc.getAddress(), clearFunc.getAddress(), 0);
+
+ for (int i = 0; i < entries.length; i++) {
+ GtkTargetEntry entry = entries[i];
+ if( entry.target != 0) OS.g_free(entry.target);
+ }
+ if (pTargetsList != 0) OS.g_free(pTargetsList);
+
+ if (!result) DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+}
+/*
+ * Note: getAvailableTypeNames is a tool for writing a Transfer sub-class only. It should
+ * NOT be used within an application because it provides platform specfic
+ * information.
+ */
+public String[] getAvailableTypeNames() {
+ return new String[0];
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
new file mode 100644
index 0000000000..b68b571372
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DragSource.java
@@ -0,0 +1,146 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+
+/**
+ *
+ * Class <code>DragSource</code> defines the source object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * <p>This class defines the following items:<ul>
+ * <li>the <code>Control</code> that the user clicks on to intiate a drag;
+ * <li>the data that will be transferred on a successful drop;
+ * <li>and the modes (move, copy, link) of transfer that are allowed.
+ * </ul></p>
+ *
+ * <p>You may have several DragSources in an application but you can only have one DragSource
+ * per Control. Data dragged from this DragSource can be dropped on a site within this application
+ * but it can also be dropped on another application such as an external Text editor.</p>
+ *
+ * <p>The application supplies the content of the data being transferred by implementing the interface
+ * <code>DragSourceListener</code> which uses the class <code>DragSourceEvent</code>.
+ * The application is required to take the appropriate action to remove the data from the drag source
+ * when a successful move operation occurs.</p>
+ *
+ * <code><pre>
+ * // Enable a label as a Drag Source
+ * Label label = new Label(shell, SWT.NONE);
+ * // This example will allow text to be dragged
+ * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ * // This example will allow the text to be copied or moved to the drop target
+ * int operations = DND.DROP_MOVE | DND.DROP_COPY;
+ *
+ * DragSource source = new DragSource (label, operations);
+ * source.setTransfer(types);
+ * source.addDragListener (new DragSourceListener() {
+ * public void dragStart(DragSourceEvent e) {
+ * // Only start the drag if there is actually text in the
+ * // label - this text will be what is dropped on the target.
+ * if (label.getText().length() == 0) {
+ * event.doit = false;
+ * }
+ * };
+ * public void dragSetData (DragSourceEvent event) {
+ * // A drop has been performed, so provide the data of the
+ * // requested type.
+ * // (Checking the type of the requested data is only
+ * // necessary if the drag source supports more than
+ * // one data type but is shown here as an example).
+ * if (TextTransfer.getInstance().isSupportedType(event.dataType)){
+ * event.data = label.getText();
+ * }
+ * }
+ * public void dragFinished(DragSourceEvent event) {
+ * // A Move operation has been performed so remove the data
+ * // from the source
+ * if (event.detail == DND.DROP_MOVE)
+ * label.setText("");
+ * }
+ * });
+ * </pre></code>
+ *
+ *
+ * <dl>
+ * <dt><b>Styles</b> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ * <dt><b>Events</b> <dd>DND.DragEnd, DND.DragSetData
+ * </dl>
+ */
+public final class DragSource extends Widget {
+
+/**
+ * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
+ *
+ * @param control the <code>Control</code> that the user clicks on to initiate the drag
+ *
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
+ * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ */
+public DragSource(Control control, int style) {
+ super (control, style);
+}
+/**
+ * Adds the listener to receive events.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void addDragListener(DragSourceListener listener) {
+
+}
+
+/**
+ * Returns the Control which is registered for this DragSource. This is the control that the
+ * user clicks in to initiate dragging.
+ *
+ * @return the Control which is registered for this DragSource
+ */
+public Control getControl () {
+ return null;
+}
+
+public Display getDisplay () {
+ return null;
+}
+/**
+ * Returns the list of data types that can be transferred by this DragSource.
+ *
+ * @return the list of data types that can be transferred by this DragSource
+ */
+public Transfer[] getTransfer(){
+ return null;
+}
+
+/**
+ * Removes the listener.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void removeDragListener(DragSourceListener listener) {
+}
+/**
+ * Specifies the list of data types that can be transferred by this DragSource.
+ * The application must be able to provide data to match each of these types when
+ * a successful drop has occurred.
+ */
+public void setTransfer(Transfer[] transferAgents){
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
new file mode 100644
index 0000000000..27d836cf1f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
@@ -0,0 +1,132 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+
+/**
+ *
+ * Class <code>DropTarget</code> defines the target object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * <p>This class identifies the <code>Control</code> over which the user must position the cursor
+ * in order to drop the data being transferred. It also specifies what data types can be dropped on
+ * this control and what operations can be performed. You may have several DropTragets in an
+ * application but there can only be a one to one mapping between a <code>Control</code> and a <code>DropTarget</code>.
+ * The DropTarget can receive data from within the same application or from other applications
+ * (such as text dragged from a text editor like Word).</p>
+ *
+ * <code><pre>
+ * int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
+ * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ * DropTarget target = new DropTarget(label, operations);
+ * target.setTransfer(types);
+ * </code></pre>
+ *
+ * <p>The application is notified of data being dragged over this control and of when a drop occurs by
+ * implementing the interface <code>DropTargetListener</code> which uses the class
+ * <code>DropTargetEvent</code>. The application can modify the type of drag being performed
+ * on this Control at any stage of the drag by modifying the <code>event.detail</code> field or the
+ * <code>event.currentDataType</code> field. When the data is dropped, it is the responsibility of
+ * the application to copy this data for its own purposes.
+ *
+ * <code><pre>
+ * target.addDropListener (new DropTargetListener() {
+ * public void dragEnter(DropTargetEvent event) {};
+ * public void dragOver(DropTargetEvent event) {};
+ * public void dragLeave(DropTargetEvent event) {};
+ * public void dragOperationChanged(DropTargetEvent event) {};
+ * public void dropAccept(DropTargetEvent event) {}
+ * public void drop(DropTargetEvent event) {
+ * // A drop has occurred, copy over the data
+ * if (event.data == null) { // no data to copy, indicate failure in event.detail
+ * event.detail = DND.DROP_NONE;
+ * return;
+ * }
+ * label.setText ((String) event.data); // data copied to label text
+ * }
+ * });
+ * </pre></code>
+ *
+ * <dl>
+ * <dt><b>Styles</b> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ * <dt><b>Events</b> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
+ * DND.Drop, DND.DropAccept
+ * </dl>
+ */
+public final class DropTarget extends Widget {
+
+/**
+ * Creates a new <code>DropTarget</code> to handle dropping on the specified <code>Control</code>.
+ *
+ * @param control the <code>Control</code> over which the user positions the cursor to drop data
+ *
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
+ * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ */
+public DropTarget(Control control, int style) {
+ super(control, style);
+}
+
+/**
+ * Adds the listener to receive events.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void addDropListener(DropTargetListener listener) {
+}
+
+/**
+ * Returns the Control which is registered for this DropTarget. This is the control over which the
+ * user positions the cursor to drop the data.
+ *
+ * @return the Control which is registered for this DropTarget
+ *
+ */
+public Control getControl () {
+ return null;
+}
+public Display getDisplay () {
+ return null;
+}
+/**
+ * Returns the list of data types that can be transferred to this DropTarget.
+ *
+ * @return the list of data types that can be transferred to this DropTarget
+ *
+ */
+public Transfer[] getTransfer() { return null; }
+public void notifyListener (int eventType, Event event) {}
+/**
+ * Removes the listener.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void removeDropListener(DropTargetListener listener) {}
+/**
+ * Specifies the list of data types that can be transferred to this DropTarget.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dropped on this target
+ */
+public void setTransfer(Transfer[] transferAgents){}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/FileTransfer.java
new file mode 100644
index 0000000000..3cf97ac367
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/FileTransfer.java
@@ -0,0 +1,98 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+import org.eclipse.swt.internal.Converter;
+
+/**
+ * The <code>FileTransfer</code> class is used to transfer files in a drag and drop operation.
+ */
+public class FileTransfer extends ByteArrayTransfer {
+
+ private static FileTransfer _instance = new FileTransfer();
+ private static final String TYPENAME = "text/uri-list";
+ private static final int TYPEID = registerType(TYPENAME);
+
+private FileTransfer() {}
+/**
+ * Returns the singleton instance of the FileTransfer class.
+ *
+ * @return the singleton instance of the FileTransfer class
+ */
+public static FileTransfer getInstance () {
+ return _instance;
+}
+/**
+ * Converts a list of filenames to a platform specific representation.
+ * <p>
+ * On a successful conversion, the transferData.result field will be set as follows:
+ * <ul>
+ * <li>Windows: OLE.S_OK
+ * <li>Motif: 0
+ * </ul>
+ * If this transfer agent is unable to perform the conversion,
+ * the transferData.result field will be set to a failure value as follows:
+ * <ul>
+ * <li>Windows: OLE.DV_E_TYMED
+ * <li>Motif: 1
+ * </ul></p>
+ *
+ * @param object a list of file names
+ * @param transferData an empty TransferData object; this object will be filled in on return
+ * with the platform specific format of the data
+ */
+public void javaToNative(Object object, TransferData transferData) {
+ if (object == null || !(object instanceof String[])) return;
+ // build a byte array from data
+ String[] files = (String[])object;
+
+ // create a string separated by "new lines" to represent list of files
+ String nativeFormat = "file:";
+ for (int i = 0, length = files.length; i < length; i++){
+ nativeFormat += files[i]+"\r";
+ }
+ byte[] buffer = Converter.wcsToMbcs(null, nativeFormat, true);
+ // pass byte array on to super to convert to native
+ super.javaToNative(buffer, transferData);
+}
+/**
+ * Converts a platform specific representation of a list of file names to a Java array of String.
+ *
+ * @param transferData the platform specific representation of the data that has been transferred
+ * @return a Java array of String containing a list of file names if the conversion was successful;
+ * otherwise null
+ */
+public Object nativeToJava(TransferData transferData) {
+
+ byte[] data = (byte[])super.nativeToJava(transferData);
+ if (data == null) return null;
+ char[] unicode = Converter.mbcsToWcs(null, data);
+ String string = new String(unicode);
+ // parse data and convert string to array of files
+ int start = string.indexOf("file:");
+ if (start == -1) return null;
+ start += 5;
+ String[] fileNames = new String[0];
+ while (start < string.length() - 1) {
+ int end = string.indexOf("\r", start);
+ if (end == -1) end = string.length() - 1;
+ String fileName = string.substring(start, end);
+
+ String[] newFileNames = new String[fileNames.length + 1];
+ System.arraycopy(fileNames, 0, newFileNames, 0, fileNames.length);
+ newFileNames[fileNames.length] = fileName;
+ fileNames = newFileNames;
+
+ start = end + 1;
+ }
+ return fileNames;
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID};
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/RTFTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/RTFTransfer.java
new file mode 100644
index 0000000000..e91a61a3a0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/RTFTransfer.java
@@ -0,0 +1,79 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.Converter;
+
+/**
+ * The <code>RTFTransfer</code> class is used to transfer text with the RTF format
+ * in a drag and drop operation.
+ */
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static RTFTransfer _instance = new RTFTransfer();
+ private static final String TYPENAME1 = "text/rtf";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "TEXT/RTF";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "application/rtf";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private RTFTransfer() {
+}
+/**
+ * Returns the singleton instance of the RTFTransfer class.
+ *
+ * @return the singleton instance of the RTFTransfer class
+ */
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+/**
+ * Converts a RTF-formatted Java String to a platform specific representation.
+ * <p>
+ * On a successful conversion, the transferData.result field will be set as follows:
+ * <ul>
+ * <li>Windows: OLE.S_OK
+ * <li>Motif: 0
+ * </ul>
+ * If this transfer agent is unable to perform the conversion,
+ * the transferData.result field will be set to a failure value as follows:
+ * <ul>
+ * <li>Windows: OLE.DV_E_TYMED
+ * <li>Motif: 1
+ * </ul></p>
+ *
+ * @param object a Java String containing the data to be transferred
+ * @param transferData an empty TransferData object; this object will be filled in on return
+ * with the platform specific format of the data
+ */
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+ byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
+ super.javaToNative(buffer, transferData);
+}
+/**
+ * Converts a platform specific representation of a string to a Java String.
+ *
+ * @param transferData the platform specific representation of the data that has been transferred
+ * @return a Java String containing the transferred data if the conversion was successful;
+ * otherwise null
+ */
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TextTransfer.java
new file mode 100644
index 0000000000..d3afdde70a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TextTransfer.java
@@ -0,0 +1,81 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.Converter;
+/**
+ * The <code>TextTransfer</code> class is used to transfer text in a drag and drop operation.
+ */
+public class TextTransfer extends ByteArrayTransfer {
+
+ private static TextTransfer _instance = new TextTransfer();
+ private static final String TYPENAME1 = "STRING";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "text/plain";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "text/text";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+ private static final String TYPENAME4 = "TEXT";
+ private static final int TYPEID4 = registerType(TYPENAME4);
+
+private TextTransfer() {
+}
+/**
+ * Returns the singleton instance of the TextTransfer class.
+ *
+ * @return the singleton instance of the TextTransfer class
+ */
+public static TextTransfer getInstance () {
+ return _instance;
+}
+/**
+ * Converts a plain text Java String to a platform specific representation.
+ * <p>
+ * On a successful conversion, the transferData.result field will be set as follows:
+ * <ul>
+ * <li>Windows: OLE.S_OK
+ * <li>Motif: 1
+ * <li>GTK: 1
+ * </ul>
+ * If this transfer agent is unable to perform the conversion,
+ * the transferData.result field will be set to a failure value as follows:
+ * <ul>
+ * <li>Windows: OLE.DV_E_TYMED
+ * <li>Motif: 0
+ * <li>GTK: 0
+ * </ul></p>
+ *
+ * @param object a Java String containing the data to be transferred
+ * @param transferData an empty TransferData object; this object will be filled in on return
+ * with the platform specific format of the data
+ */
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+ byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
+ super.javaToNative(buffer, transferData);
+}
+/**
+ * Converts a platform specific representation of a string to a Java String.
+ *
+ * @param transferData the platform specific representation of the data that has been transferred
+ * @return a Java String containing the transferred data if the conversion was successful;
+ * otherwise null
+ */
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3, TYPENAME4};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3, TYPEID4};
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Transfer.java
new file mode 100644
index 0000000000..958e6e8fe7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Transfer.java
@@ -0,0 +1,58 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.gtk.OS;
+
+/**
+ * The class <code>Transfer</code> provides a mechanism for converting a Java object to a
+ * platform specific format that can be passed around in a Drag and Drop operation and vice versa.
+ *
+ * <p>You should only need to become familiar with this class if you are implementing
+ * a Transfer subclass and you are unable to subclass the ByteArrayTransfer class.</p>
+ */
+public abstract class Transfer {
+/**
+ * Returns a list of the data types that can be transferred using this Transfer agent.
+ *
+ * <p>Only the data type fields of the TransferData Object are filled in.</p>
+ *
+ * @return a list of the data types that can be transferred using this Transfer agent
+ */
+abstract public TransferData[] getSupportedTypes();
+/**
+ * Returns true if the transferData data type can be transferred using this Transfer agent.
+ *
+ * @param transferData a platform specific description of a data type; only the data type fields
+ * of the TransferData Object need to be filled in
+ *
+ * @return true if the transferData data type can be transferred using this Transfer agent
+ */
+abstract public boolean isSupportedType(TransferData transferData);
+abstract protected String[] getTypeNames();
+abstract protected int[] getTypeIds();
+abstract protected void javaToNative (Object object, TransferData transferData);
+abstract protected Object nativeToJava(TransferData transferData);
+/**
+ * Registers a name for a data type and returns the associated unique identifier.
+ *
+ * <p>You may register the same type more than once, the same unique identifier will be returned if the
+ * type has been previously registered.</p>
+ *
+ * <p>Note: Do <b>not</b> call this method with pre-defined Clipboard Format types such as CF_TEXT
+ * or CF_BITMAP because the pre-defined value will not be returned</p>
+ *
+ * @param formatName the name of a data type
+ *
+ * @return the unique identifier associated with this data type
+ */
+public static int registerType(String formatName){
+ if (formatName == null) return OS.GDK_NONE;
+ byte[] buffer = Converter.wcsToMbcs(null, formatName, true);
+ return OS.gdk_atom_intern(buffer, false);
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TransferData.java
new file mode 100644
index 0000000000..64a8c75864
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TransferData.java
@@ -0,0 +1,35 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+/**
+ * The <code>TransferData</code> class is a platform specific data structure for describing the type and the
+ * contents of data being transferred in a Drag and Drop operation.
+ *
+ * <p>As an application writer, you do not need to know anything about the specifics of TransferData. You
+ * should just pass the TransferData instances to subclass of Transfer and let the Transfer objects deal
+ * with the platform specific issues. You can ask a Transfer subclass if it can handle this data by calling
+ * TextTransfer.isSupportedType(transferData). You can get a list of the types of TransferData supported by a
+ * Transfer object by calling TextTransfer.getSupportedTypes().</p>
+ *
+ * <p>You should only need to become familiar with the fields in this class if you are implementing
+ * a Transfer subclass and you are unable to subclass the ByteArrayTransfer class.</p>
+ */
+public class TransferData {
+ /**
+ * Data Type - a pre-defined clipboard format <b>or</b> the unique identifier of a user defined format
+ * (Warning: This field is platform dependent)
+ */
+ public int type;
+
+ // attributes specific to set/get
+ int length;
+ int format;
+ int pValue;
+
+ int result;
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java
index f57f526211..aacceefb38 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java
@@ -37,13 +37,15 @@ public static TextTransfer getInstance () {
* On a successful conversion, the transferData.result field will be set as follows:
* <ul>
* <li>Windows: OLE.S_OK
- * <li>Motif: 0
+ * <li>Motif: 1
+ * <li>GTK: 1
* </ul>
* If this transfer agent is unable to perform the conversion,
* the transferData.result field will be set to a failure value as follows:
* <ul>
* <li>Windows: OLE.DV_E_TYMED
- * <li>Motif: 1
+ * <li>Motif: 0
+ * <li>GTK: 0
* </ul></p>
*
* @param object a Java String containing the data to be transferred