jdk/src/share/classes/java/awt/dnd/DropTargetListener.java
author dav
Thu, 29 May 2008 13:48:51 +0400
changeset 638 69a80895db21
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6691328: DragSourceContext returns unexpected cursor Summary: make the code to be executed if other options don't suit Reviewed-by: dcherepanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt.dnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.EventListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.dnd.DropTargetDragEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.dnd.DropTargetDropEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * The <code>DropTargetListener</code> interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * is the callback interface used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <code>DropTarget</code> class to provide
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * notification of DnD operations that involve
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * the subject <code>DropTarget</code>. Methods of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * this interface may be implemented to provide
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * "drag under" visual feedback to the user throughout
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * the Drag and Drop operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Create a listener object by implementing the interface and then register it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * with a <code>DropTarget</code>. When the drag enters, moves over, or exits
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * the operable part of the drop site for that <code>DropTarget</code>, when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * the drop action changes, and when the drop occurs, the relevant method in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * the listener object is invoked, and the <code>DropTargetEvent</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * passed to it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * The operable part of the drop site for the <code>DropTarget</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * the part of the associated <code>Component</code>'s geometry that is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * obscured by an overlapping top-level window or by another
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <code>Component</code> higher in the Z-order that has an associated active
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <code>DropTarget</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * During the drag, the data associated with the current drag operation can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * retrieved by calling <code>getTransferable()</code> on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <code>DropTargetDragEvent</code> instances passed to the listener's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * Note that <code>getTransferable()</code> on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <code>DropTargetDragEvent</code> instance should only be called within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * respective listener's method and all the necessary data should be retrieved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * from the returned <code>Transferable</code> before that method returns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
public interface DropTargetListener extends EventListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Called while a drag operation is ongoing, when the mouse pointer enters
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * the operable part of the drop site for the <code>DropTarget</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * registered with this listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @param dtde the <code>DropTargetDragEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    void dragEnter(DropTargetDragEvent dtde);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Called when a drag operation is ongoing, while the mouse pointer is still
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * over the operable part of the drop site for the <code>DropTarget</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * registered with this listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @param dtde the <code>DropTargetDragEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    void dragOver(DropTargetDragEvent dtde);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Called if the user has modified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * the current drop gesture.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @param dtde the <code>DropTargetDragEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    void dropActionChanged(DropTargetDragEvent dtde);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Called while a drag operation is ongoing, when the mouse pointer has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * exited the operable part of the drop site for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * <code>DropTarget</code> registered with this listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @param dte the <code>DropTargetEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    void dragExit(DropTargetEvent dte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Called when the drag operation has terminated with a drop on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * the operable part of the drop site for the <code>DropTarget</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * registered with this listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * This method is responsible for undertaking
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * the transfer of the data associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * gesture. The <code>DropTargetDropEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * provides a means to obtain a <code>Transferable</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * object that represents the data object(s) to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * be transfered.<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * From this method, the <code>DropTargetListener</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * shall accept or reject the drop via the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * acceptDrop(int dropAction) or rejectDrop() methods of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * <code>DropTargetDropEvent</code> parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * Subsequent to acceptDrop(), but not before,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * <code>DropTargetDropEvent</code>'s getTransferable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * method may be invoked, and data transfer may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * performed via the returned <code>Transferable</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * getTransferData() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * At the completion of a drop, an implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * of this method is required to signal the success/failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * of the drop by passing an appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * <code>boolean</code> to the <code>DropTargetDropEvent</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * dropComplete(boolean success) method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Note: The data transfer should be completed before the call  to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * <code>DropTargetDropEvent</code>'s dropComplete(boolean success) method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * After that, a call to the getTransferData() method of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * <code>Transferable</code> returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * <code>DropTargetDropEvent.getTransferable()</code> is guaranteed to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * succeed only if the data transfer is local; that is, only if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * <code>DropTargetDropEvent.isLocalTransfer()</code> returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * <code>true</code>. Otherwise, the behavior of the call is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * implementation-dependent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param dtde the <code>DropTargetDropEvent</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    void drop(DropTargetDropEvent dtde);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
}