| 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.*;
|
| import org.eclipse.swt.internal.gtk.*;
|
|
|
| /** |
| * |
| * 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) {
|
|
|
| }
|
|
|
| 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){
|
| }
|
| /**
|
| * @deprecated - use DragSourceListener.dragStart
|
| */
|
| public void startDrag() {
|
| }
|
|
|
| }
|