FSF GCC merge 02/23/03
[official-gcc.git] / libjava / java / awt / dnd / DropTargetDropEvent.java
blobbb57f23b08f83ab56db29dce28ac1d2adcfa90ec
1 /* DropTargetDropEvent.java --
2 Copyright (C) 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package java.awt.dnd;
40 import java.awt.Point;
41 import java.awt.datatransfer.DataFlavor;
42 import java.awt.datatransfer.Transferable;
43 import java.util.List;
45 /**
46 * @since 1.2
48 public class DropTargetDropEvent extends DropTargetEvent
50 /**
51 * Compatible with JDK 1.2+
53 private static final long serialVersionUID = -1721911170440459322L;
55 private final int dropAction;
56 private final int actions;
57 private final Point location;
58 private final boolean isLocalTx;
60 /**
61 * Initializes a <code>DropTargetDropEvent</code>. By default this constructor
62 * assumes that the target is not int same JVM.
64 * @exception IllegalArgumentException If dropAction is not one of DnDConstants,
65 * actions is not a bitwise mask of DnDConstants, or dtc is null.
66 * @exception NullPointerException If location is null.
68 public DropTargetDropEvent (DropTargetContext dtc, Point location,
69 int dropAction, int actions)
71 this (dtc, location, dropAction, actions, false);
74 /**
75 * Initializes a <code>DropTargetDropEvent</code>.
77 * @exception IllegalArgumentException If dropAction is not one of DnDConstants,
78 * actions is not a bitwise mask of DnDConstants, or dtc is null.
79 * @exception NullPointerException If location is null.
81 public DropTargetDropEvent (DropTargetContext dtc, Point location,
82 int dropAction, int actions, boolean isLocalTx)
84 super (dtc);
86 if (location == null)
87 throw new NullPointerException ();
89 if (dtc == null)
90 throw new IllegalArgumentException ();
92 if (dropAction != DnDConstants.ACTION_NONE
93 && dropAction != DnDConstants.ACTION_COPY
94 && dropAction != DnDConstants.ACTION_MOVE
95 && dropAction != DnDConstants.ACTION_COPY_OR_MOVE
96 && dropAction != DnDConstants.ACTION_LINK
97 && dropAction != DnDConstants.ACTION_REFERENCE)
98 throw new IllegalArgumentException ();
100 int actionsMask = DnDConstants.ACTION_NONE
101 | DnDConstants.ACTION_COPY
102 | DnDConstants.ACTION_MOVE
103 | DnDConstants.ACTION_COPY_OR_MOVE
104 | DnDConstants.ACTION_LINK
105 | DnDConstants.ACTION_REFERENCE;
107 if (~(actions ^ actionsMask) != 0)
108 throw new IllegalArgumentException ();
110 this.dropAction = dropAction;
111 this.actions = actions;
112 this.location = location;
113 this.isLocalTx = isLocalTx;
116 public Point getLocation ()
118 return location;
121 public DataFlavor[] getCurrentDataFlavors ()
123 return context.getCurrentDataFlavors ();
126 public List getCurrentDataFlavorsAsList ()
128 return context.getCurrentDataFlavorsAsList ();
131 public boolean isDataFlavorSupported (DataFlavor flavor)
133 return context.isDataFlavorSupported (flavor);
136 public int getSourceActions ()
138 return actions;
141 public int getDropAction ()
143 return dropAction;
146 public Transferable getTransferable ()
148 return context.getTransferable ();
151 public void acceptDrop (int dropAction)
153 context.acceptDrop (dropAction);
156 public void rejectDrop ()
158 context.rejectDrop ();
161 public void dropComplete (boolean success)
163 // FIXME: implement this
166 public boolean isLocalTransfer()
168 return isLocalTx;
170 } // class DropTargetDropEvent