KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > dnd > DragSourceEffect


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.dnd;
12
13 import org.eclipse.swt.*;
14 import org.eclipse.swt.widgets.*;
15
16 /**
17  * This class provides default implementations to display a drag source
18  * effect during a drag and drop operation. The current implementation
19  * does not provide any visual feedback.
20  *
21  * <p>The drag source effect has the same API as the
22  * <code>DragSourceAdapter</code> so that it can provide custom visual
23  * feedback when a <code>DragSourceEvent</code> occurs.
24  * </p>
25  *
26  * <p>Classes that wish to provide their own drag source effect such as
27  * displaying a default source image during a drag can extend the <code>DragSourceEffect</code>
28  * class, override the <code>DragSourceAdapter.dragStart</code> method and set
29  * the field <code>DragSourceEvent.image</code> with their own image.
30  * The image should be disposed when <code>DragSourceAdapter.dragFinished</code> is called.
31  * </p>
32  *
33  * @see DragSourceAdapter
34  * @see DragSourceEvent
35  *
36  * @since 3.3
37  */

38 public class DragSourceEffect extends DragSourceAdapter {
39     Control control = null;
40
41     /**
42      * Creates a new <code>DragSourceEffect</code> to handle drag effect from the specified <code>Control</code>.
43      *
44      * @param control the <code>Control</code> that the user clicks on to initiate the drag
45      *
46      * @exception IllegalArgumentException <ul>
47      * <li>ERROR_NULL_ARGUMENT - if the control is null</li>
48      * </ul>
49      */

50     public DragSourceEffect(Control control) {
51         if (control == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
52         this.control = control;
53     }
54
55     /**
56      * Returns the Control which is registered for this DragSourceEffect. This is the control that the
57      * user clicks in to initiate dragging.
58      *
59      * @return the Control which is registered for this DragSourceEffect
60      */

61     public Control getControl() {
62         return control;
63     }
64 }
65
Popular Tags