KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > util > TransferDropTargetListener


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jface.util;
12
13 import org.eclipse.swt.dnd.DropTargetEvent;
14 import org.eclipse.swt.dnd.DropTargetListener;
15 import org.eclipse.swt.dnd.Transfer;
16
17 /**
18  * A <code>TransferDropTargetListener</code> is a <code>DropTragetListener</code>
19  * that handles one type of SWT {@link Transfer}.
20  * The purpose of a <code>TransferDropTargetListener</code> is to:
21  * <ul>
22  * <li>Determine enablement for a drop operation. A <code>TransferDropTargetListener</code>
23  * will not be used if <code>isEnabled</code> returns false.
24  * <li>When enabled, optionally show feedback on the <code>DropTarget</code>.
25  * <li>Perform the actual drop
26  * </ul>
27  * A <code>DelegatingDropAdapter</code> allows these functions to be implemented
28  * separately for unrelated types of drags. <code>DelegatingDropAdapter</code> then
29  * combines the function of each <code>TransferDropTargetListener</code>, while
30  * allowing them to be implemented as if they were the only <code>DragSourceListener</code>.
31  * @since 3.0
32  */

33 public interface TransferDropTargetListener extends DropTargetListener {
34     /**
35      * Returns the <code>Transfer</code> type that this listener can
36      * accept a drop operation for.
37      *
38      * @return the <code>Transfer</code> for this listener
39      */

40     Transfer getTransfer();
41
42     /**
43      * Returns <code>true</code> if this listener can handle the drop
44      * based on the given <code>DropTargetEvent</code>.
45      * <p>
46      * This method is called by the <code>DelegatingDropAdapter</code> only
47      * if the <code>DropTargetEvent</code> contains a transfer data type
48      * supported by this listener. The <code>Transfer</code> returned by the
49      * <code>#getTransfer()</code> method is used for this purpose.
50      * </p>
51      *
52      * @param event the drop target event
53      * @return <code>true</code> if the listener is enabled for the given
54      * drop target event.
55      */

56     boolean isEnabled(DropTargetEvent event);
57 }
58
Popular Tags