summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java48
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java94
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java196
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java214
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java66
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java63
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java102
11 files changed, 903 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java
new file mode 100755
index 0000000000..ec66fefb22
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java
@@ -0,0 +1,48 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.photon.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+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){
+ 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.XtMalloc(buffer.length + 1);
+// OS.memmove(transferData.pValue, buffer, buffer.length);
+ transferData.length = buffer.length;
+ transferData.format = 8;
+ transferData.result = 1;
+}
+protected Object nativeToJava(TransferData transferData){
+
+ if (transferData.pValue == 0 || !(isSupportedType(transferData))) 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/photon/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java
new file mode 100755
index 0000000000..a51be325c3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java
@@ -0,0 +1,94 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/*
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ */
+public class Clipboard {
+
+ private Display display;
+ private final int MAX_RETRIES = 10;
+ private int shellHandle;
+
+
+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;
+
+// int widgetClass = OS.TopLevelShellWidgetClass ();
+// shellHandle = OS.XtAppCreateShell (null, null, widgetClass, display.xDisplay, null, 0);
+// OS.XtSetMappedWhenManaged (shellHandle, false);
+// OS.XtRealizeWidget (shellHandle);
+}
+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 (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
+// shellHandle = 0;
+ display = null;
+}
+public Object getContents(Transfer transfer) {
+ if (display.isDisposed() ) return null;
+ return null;
+}
+public void setContents(Object[] data, Transfer[] transferAgents){
+}
+/*
+ * 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() {
+ int[] count = new int[1];
+ int[] max_length = new int[1];
+// int xDisplay = OS.XtDisplay (shellHandle);
+// if (xDisplay == 0)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+// int xWindow = OS.XtWindow (shellHandle);
+// if (xWindow == 0)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+// if (OS.XmClipboardInquireCount(xDisplay, xWindow, count, max_length) != OS.XmClipboardSuccess)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+ String[] types = new String[count[0]];
+// for (int i = 0; i < count[0]; i++) {
+// byte[] buffer = new byte[max_length[0]];
+// int[] copied_length = new int[1];
+// int rc = OS.XmClipboardInquireFormat(xDisplay, xWindow, i + 1, buffer, buffer.length, copied_length);
+// if (rc == OS.XmClipboardNoData){
+// types[i] = "";
+// continue;
+// }
+// if (rc != OS.XmClipboardSuccess)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+// byte[] buffer2 = new byte[copied_length[0]];
+// System.arraycopy(buffer, 0, buffer2, 0, copied_length[0]);
+// types[i] = new String(buffer2);
+// }
+ return types;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java
new file mode 100755
index 0000000000..ace4bd062c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java
@@ -0,0 +1,196 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ *
+ * 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 class DragSource extends Widget {
+
+ private Callback convertProc;
+ private Callback dragDropFinish;
+ private Callback dropFinish;
+
+ // info for registering as a drag source
+ private Control control;
+ private Listener controlListener;
+ private Transfer[] transferAgents = new Transfer[0];
+
+ private boolean myDrag;
+
+ int dragContext;
+
+public DragSource(Control control, int style) {
+ super (control, checkStyle(style));
+
+ this.control = control;
+
+ controlListener = new Listener () {
+ public void handleEvent (Event event) {
+ if (event.type == SWT.Dispose) {
+ if (!DragSource.this.isDisposed()){
+ DragSource.this.dispose();
+ }
+ }
+ if (event.type == SWT.DragDetect){
+// DragSource.this.drag();
+ }
+
+ }
+ };
+ this.control.addListener (SWT.Dispose, controlListener);
+ this.control.addListener (SWT.DragDetect, controlListener);
+
+ this.addListener (SWT.Dispose, new Listener () {
+ public void handleEvent (Event event) {
+// onDispose();
+ }
+ });
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ DNDListener typedListener = new DNDListener (listener);
+ addListener (DND.DragStart, typedListener);
+ addListener (DND.DragSetData, typedListener);
+ addListener (DND.DragEnd, typedListener);
+}
+static int checkStyle (int style) {
+ if (style == SWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+
+
+
+
+
+public Control getControl () {
+ return control;
+}
+/**
+* Gets the Display.
+*/
+public Display getDisplay () {
+
+ if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ return control.getDisplay ();
+}
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+
+
+
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragStart, listener);
+ removeListener (DND.DragSetData, listener);
+ removeListener (DND.DragEnd, listener);
+}
+public void setTransfer(Transfer[] transferAgents){
+ this.transferAgents = transferAgents;
+}
+
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DragSource.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java
new file mode 100755
index 0000000000..f5184be09b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java
@@ -0,0 +1,214 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ *
+ * 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 class DropTarget extends Widget {
+
+ private Callback dropProc;
+ private Callback transferProc;
+ private Callback dragProc;
+
+ // info for registering as a droptarget
+ private Control control;
+ private Listener controlListener;
+ private Transfer[] transferAgents = new Transfer[0];
+
+ // info about data being dragged over site
+ private TransferData selectedDataType;
+ private TransferData[] dataTypes;
+ private int dropTransferObject;
+
+ private DragUnderEffect effect;
+
+public DropTarget(Control control, int style) {
+
+ super (control, checkStyle(style));
+
+ this.control = control;
+
+ controlListener = new Listener () {
+ public void handleEvent (Event event) {
+ if (!DropTarget.this.isDisposed()){
+ DropTarget.this.dispose();
+ }
+ }
+ };
+ control.addListener (SWT.Dispose, controlListener);
+
+ this.addListener (SWT.Dispose, new Listener () {
+ public void handleEvent (Event event) {
+ //onDispose();
+ }
+ });
+
+ if (control instanceof Tree) {
+ effect = new TreeDragUnderEffect((Tree)control);
+ } else if (control instanceof Table) {
+ effect = new TableDragUnderEffect((Table)control);
+ } else {
+ effect = new NoDragUnderEffect(control);
+ }
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ DNDListener typedListener = new DNDListener (listener);
+ addListener (DND.DragEnter, typedListener);
+ addListener (DND.DragLeave, typedListener);
+ addListener (DND.DragOver, typedListener);
+ addListener (DND.DragOperationChanged, typedListener);
+ addListener (DND.Drop, typedListener);
+ addListener (DND.DropAccept, typedListener);
+
+}
+static int checkStyle (int style) {
+ if (style == SWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+
+
+/**
+ * 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 control;
+}
+public Display getDisplay () {
+
+ if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ return control.getDisplay ();
+}
+/**
+ * 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 transferAgents;
+}
+public void notifyListeners (int eventType, Event event) {
+ Point coordinates = new Point(event.x, event.y);
+ coordinates = control.toControl(coordinates);
+ if (this.control instanceof Tree) {
+ event.item = ((Tree)control).getItem(coordinates);
+ }
+ if (this.control instanceof Table) {
+ event.item = ((Table)control).getItem(coordinates);
+ }
+ super.notifyListeners(eventType, event);
+}
+
+
+
+
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragEnter, listener);
+ removeListener (DND.DragLeave, listener);
+ removeListener (DND.DragOver, listener);
+ removeListener (DND.DragOperationChanged, listener);
+ removeListener (DND.Drop, listener);
+ removeListener (DND.DropAccept, listener);
+}
+public void setTransfer(Transfer[] transferAgents){
+}
+
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DropTarget.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java
new file mode 100755
index 0000000000..8b70854312
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java
@@ -0,0 +1,66 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class FileTransfer extends ByteArrayTransfer {
+
+ private static FileTransfer _instance = new FileTransfer();
+ private static final String TYPENAME = "text/uri-list\0";
+ private static final int TYPEID = registerType(TYPENAME);
+
+private FileTransfer() {}
+public static FileTransfer getInstance () {
+ return _instance;
+}
+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";
+ }
+ nativeFormat += "\0";
+ // pass byte array on to super to convert to native
+ super.javaToNative(nativeFormat.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData) {
+
+ byte[] data = (byte[])super.nativeToJava(transferData);
+ if (data == null) return null;
+ String string = new String(data);
+ // 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()) {
+ 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 = string.indexOf("file:", end);
+ if (start == -1) break;
+ start += 5;
+ }
+ 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/photon/org/eclipse/swt/dnd/RTFTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java
new file mode 100755
index 0000000000..af09aac900
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static RTFTransfer _instance = new RTFTransfer();
+ private static final String TYPENAME1 = "text/rtf\0";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "TEXT/RTF\0";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "application/rtf\0";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private RTFTransfer() {
+}
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ String text = (String)object;
+ super.javaToNative(text.getBytes(), transferData);
+}
+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
+ return new String(buffer);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java
new file mode 100755
index 0000000000..231db14dc3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java
@@ -0,0 +1,63 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TableDragUnderEffect extends DragUnderEffect {
+ private Table table;
+ private TableItem currentItem;
+ private TableItem[] selection = new TableItem[0];
+ private int currentEffect = DND.FEEDBACK_NONE;
+
+TableDragUnderEffect(Table table) {
+ this.table = table;
+}
+void show(int effect, int x, int y) {
+ TableItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = table.getSelection();
+ table.setSelection(new TableItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ table.setSelection(selection);
+ selection = new TableItem[0];
+ }
+}
+private TableItem findItem(int x, int y){
+ if (table == null) return null;
+ Point coordinates = new Point(x, y);
+ coordinates = table.toControl(coordinates);
+ TableItem item = table.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = table.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = table.toControl(coordinates);
+ item = table.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+
+}
+private void setDragUnderEffect(int effect, TableItem item) {
+ if (currentItem != item) {
+ if (item == null) {
+ table.setSelection(new TableItem[0]);
+ } else {
+ table.setSelection(new TableItem[] {item});
+ }
+ currentItem = item;
+ }
+ currentEffect = effect;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java
new file mode 100755
index 0000000000..12afd23a9d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class TextTransfer extends ByteArrayTransfer {
+
+ private static TextTransfer _instance = new TextTransfer();
+ private static final String TYPENAME1 = "STRING\0";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "text/plain\0";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "text/text\0";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private TextTransfer() {
+}
+public static TextTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ String text = (String)object;
+ super.javaToNative(text.getBytes(), transferData);
+}
+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
+ return new String(buffer);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java
new file mode 100755
index 0000000000..be1aee9ab1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public abstract class Transfer {
+abstract public TransferData[] getSupportedTypes();
+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);
+public static int registerType(String formatName){
+ return 0;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java
new file mode 100755
index 0000000000..a73cc97090
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class TransferData {
+ 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/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java
new file mode 100755
index 0000000000..f78887e054
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java
@@ -0,0 +1,102 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TreeDragUnderEffect extends DragUnderEffect {
+
+ private Tree tree;
+ private TreeItem currentItem = null;
+ private int currentEffect = DND.FEEDBACK_NONE;
+ private TreeItem[] selection = new TreeItem[0];
+
+TreeDragUnderEffect(Tree tree) {
+ this.tree = tree;
+}
+void show(int effect, int x, int y) {
+ TreeItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = tree.getSelection();
+ tree.setSelection(new TreeItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ tree.setSelection(selection);
+ selection = new TreeItem[0];
+ }
+}
+private TreeItem findItem(int x , int y){
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ TreeItem item = tree.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = tree.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = tree.toControl(coordinates);
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+}
+private void setDragUnderEffect(int effect, TreeItem item) {
+ switch (effect) {
+ case DND.FEEDBACK_SELECT:
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ setInsertMark(null, false);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ setDropSelection(item);
+ currentEffect = DND.FEEDBACK_SELECT;
+ currentItem = item;
+ }
+ break;
+ case DND.FEEDBACK_INSERT_AFTER:
+ case DND.FEEDBACK_INSERT_BEFORE:
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ setInsertMark(item, effect == DND.FEEDBACK_INSERT_AFTER);
+ currentEffect = effect;
+ currentItem = item;
+ }
+ break;
+ default :
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ setInsertMark(null, false);
+ }
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ }
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ break;
+ }
+}
+private void setDropSelection (TreeItem item) {
+ if (item == null) {
+ tree.setSelection(new TreeItem[0]);
+ } else {
+ tree.setSelection(new TreeItem[]{item});
+ }
+}
+private void setInsertMark (TreeItem item, boolean after) {
+ // not currently implemented
+}
+} \ No newline at end of file