jdk/src/share/classes/java/awt/dnd/DropTargetDropEvent.java
author yan
Fri, 28 Mar 2014 14:33:53 +0400
changeset 23588 b0269b21e313
parent 23010 6dadb192ad81
permissions -rw-r--r--
8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event Reviewed-by: pchelko, serb Contributed-by: Alexander Stepanov <alexander.v.stepanov@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20156
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
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.awt.Point;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.datatransfer.DataFlavor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.datatransfer.Transferable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * The <code>DropTargetDropEvent</code> is delivered
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * via the <code>DropTargetListener</code> drop() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * The <code>DropTargetDropEvent</code> reports the <i>source drop actions</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * and the <i>user drop action</i> that reflect the current state of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * drag-and-drop operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <i>Source drop actions</i> is a bitwise mask of <code>DnDConstants</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * that represents the set of drop actions supported by the drag source for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * this drag-and-drop operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * <i>User drop action</i> depends on the drop actions supported by the drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * source and the drop action selected by the user. The user can select a drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * action by pressing modifier keys during the drag operation:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <pre>
20156
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
    51
 *   Ctrl + Shift -&gt; ACTION_LINK
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
    52
 *   Ctrl         -&gt; ACTION_COPY
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
    53
 *   Shift        -&gt; ACTION_MOVE
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * If the user selects a drop action, the <i>user drop action</i> is one of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <code>DnDConstants</code> that represents the selected drop action if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * drop action is supported by the drag source or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <code>DnDConstants.ACTION_NONE</code> if this drop action is not supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * by the drag source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * If the user doesn't select a drop action, the set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <code>DnDConstants</code> that represents the set of drop actions supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * by the drag source is searched for <code>DnDConstants.ACTION_MOVE</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * then for <code>DnDConstants.ACTION_COPY</code>, then for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <code>DnDConstants.ACTION_LINK</code> and the <i>user drop action</i> is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * first constant found. If no constant is found the <i>user drop action</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * is <code>DnDConstants.ACTION_NONE</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
public class DropTargetDropEvent extends DropTargetEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private static final long serialVersionUID = -1721911170440459322L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Construct a <code>DropTargetDropEvent</code> given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * the <code>DropTargetContext</code> for this operation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * the location of the drag <code>Cursor</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * hotspot in the <code>Component</code>'s coordinates,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * the currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * selected user drop action, and the current set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * actions supported by the source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * By default, this constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * assumes that the target is not in the same virtual machine as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * the source; that is, {@link #isLocalTransfer()} will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * return <code>false</code>.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 23010
diff changeset
    88
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param dtc        The <code>DropTargetContext</code> for this operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @param cursorLocn The location of the "Drag" Cursor's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * hotspot in <code>Component</code> coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param dropAction the user drop action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @param srcActions the source drop actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *
20156
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
    95
     * @throws NullPointerException
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * if cursorLocn is <code>null</code>
20156
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
    97
     * @throws IllegalArgumentException
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
    98
     *         if dropAction is not one of  <code>DnDConstants</code>.
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
    99
     * @throws IllegalArgumentException
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
   100
     *         if srcActions is not a bitwise mask of <code>DnDConstants</code>.
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
   101
     * @throws IllegalArgumentException if dtc is <code>null</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public DropTargetDropEvent(DropTargetContext dtc, Point cursorLocn, int dropAction, int srcActions)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        super(dtc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        if (cursorLocn == null) throw new NullPointerException("cursorLocn");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        if (dropAction != DnDConstants.ACTION_NONE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            dropAction != DnDConstants.ACTION_COPY &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            dropAction != DnDConstants.ACTION_MOVE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            dropAction != DnDConstants.ACTION_LINK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        ) throw new IllegalArgumentException("dropAction = " + dropAction);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        if ((srcActions & ~(DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK)) != 0) throw new IllegalArgumentException("srcActions");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        location        = cursorLocn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        actions         = srcActions;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        this.dropAction = dropAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Construct a <code>DropTargetEvent</code> given the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * <code>DropTargetContext</code> for this operation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * the location of the drag <code>Cursor</code>'s hotspot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * in the <code>Component</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * coordinates, the currently selected user drop action,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * the current set of actions supported by the source,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * and a <code>boolean</code> indicating if the source is in the same JVM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * as the target.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 23010
diff changeset
   131
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param dtc        The DropTargetContext for this operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @param cursorLocn The location of the "Drag" Cursor's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * hotspot in Component's coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @param dropAction the user drop action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @param srcActions the source drop actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @param isLocal  True if the source is in the same JVM as the target
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
20156
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
   139
     * @throws NullPointerException
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
   140
     *         if cursorLocn is  <code>null</code>
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
   141
     * @throws IllegalArgumentException
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
   142
     *         if dropAction is not one of <code>DnDConstants</code>.
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
   143
     * @throws IllegalArgumentException if srcActions is not a bitwise mask of <code>DnDConstants</code>.
e19f062edcfe 8025114: Eliminate doclint errors in java.awt.dnd package javadoc
yan
parents: 5506
diff changeset
   144
     * @throws IllegalArgumentException  if dtc is <code>null</code>.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public DropTargetDropEvent(DropTargetContext dtc, Point cursorLocn, int dropAction, int srcActions, boolean isLocal)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        this(dtc, cursorLocn, dropAction, srcActions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        isLocalTx = isLocal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * This method returns a <code>Point</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * indicating the <code>Cursor</code>'s current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * location in the <code>Component</code>'s coordinates.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 23010
diff changeset
   157
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @return the current <code>Cursor</code> location in Component's coords.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public Point getLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        return location;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * This method returns the current DataFlavors.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 23010
diff changeset
   168
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @return current DataFlavors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public DataFlavor[] getCurrentDataFlavors() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return getDropTargetContext().getCurrentDataFlavors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * This method returns the currently available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * <code>DataFlavor</code>s as a <code>java.util.List</code>.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 23010
diff changeset
   179
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @return the currently available DataFlavors as a java.util.List
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    public List<DataFlavor> getCurrentDataFlavorsAsList() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        return getDropTargetContext().getCurrentDataFlavorsAsList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * This method returns a <code>boolean</code> indicating if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * specified <code>DataFlavor</code> is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * from the source.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 23010
diff changeset
   191
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @param df the <code>DataFlavor</code> to test
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 23010
diff changeset
   193
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @return if the DataFlavor specified is available from the source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public boolean isDataFlavorSupported(DataFlavor df) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        return getDropTargetContext().isDataFlavorSupported(df);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * This method returns the source drop actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @return the source drop actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    public int getSourceActions() { return actions; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * This method returns the user drop action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @return the user drop actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public int getDropAction() { return dropAction; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * This method returns the <code>Transferable</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * associated with the drop.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 23010
diff changeset
   218
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @return the <code>Transferable</code> associated with the drop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public Transferable getTransferable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        return getDropTargetContext().getTransferable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * accept the drop, using the specified action.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 23010
diff changeset
   228
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @param dropAction the specified action
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public void acceptDrop(int dropAction) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        getDropTargetContext().acceptDrop(dropAction);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * reject the Drop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public void rejectDrop() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        getDropTargetContext().rejectDrop();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * This method notifies the <code>DragSource</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * that the drop transfer(s) are completed.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 23010
diff changeset
   247
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @param success a <code>boolean</code> indicating that the drop transfer(s) are completed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public void dropComplete(boolean success) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        getDropTargetContext().dropComplete(success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * This method returns an <code>int</code> indicating if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * the source is in the same JVM as the target.
23588
b0269b21e313 8038242: Tidy warnings cleanup for java.awt.datatransfer, java.awt.dnd, java.awt.event
yan
parents: 23010
diff changeset
   258
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @return if the Source is in the same JVM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public boolean isLocalTransfer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        return isLocalTx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    static final private Point  zero     = new Point(0,0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * The location of the drag cursor's hotspot in Component coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    private Point               location   = zero;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * The source drop actions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    private int                 actions    = DnDConstants.ACTION_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * The user drop action.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    private int                 dropAction = DnDConstants.ACTION_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * <code>true</code> if the source is in the same JVM as the target.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    private boolean             isLocalTx = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
}