Frames | No Frames |
1: /* DropTargetDropEvent.java -- 2: Copyright (C) 2002 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 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. 10: 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. 15: 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., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 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. 25: 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. */ 37: 38: package java.awt.dnd; 39: 40: import gnu.classpath.NotImplementedException; 41: 42: import java.awt.Point; 43: import java.awt.datatransfer.DataFlavor; 44: import java.awt.datatransfer.Transferable; 45: import java.util.List; 46: 47: /** 48: * @since 1.2 49: */ 50: public class DropTargetDropEvent extends DropTargetEvent 51: { 52: /** 53: * Compatible with JDK 1.2+ 54: */ 55: private static final long serialVersionUID = -1721911170440459322L; 56: 57: private final int dropAction; 58: private final int actions; 59: private final Point location; 60: private final boolean isLocalTx; 61: 62: /** 63: * Initializes a <code>DropTargetDropEvent</code>. By default this constructor 64: * assumes that the target is not int same JVM. 65: * 66: * @exception IllegalArgumentException If dropAction is not one of DnDConstants, 67: * actions is not a bitwise mask of DnDConstants, or dtc is null. 68: * @exception NullPointerException If location is null. 69: */ 70: public DropTargetDropEvent(DropTargetContext dtc, Point location, 71: int dropAction, int actions) 72: { 73: this(dtc, location, dropAction, actions, false); 74: } 75: 76: /** 77: * Initializes a <code>DropTargetDropEvent</code>. 78: * 79: * @exception IllegalArgumentException If dropAction is not one of DnDConstants, 80: * actions is not a bitwise mask of DnDConstants, or dtc is null. 81: * @exception NullPointerException If location is null. 82: */ 83: public DropTargetDropEvent(DropTargetContext dtc, Point location, 84: int dropAction, int actions, boolean isLocalTx) 85: { 86: super(dtc); 87: 88: if (location == null) 89: throw new NullPointerException(); 90: 91: if (dtc == null) 92: throw new IllegalArgumentException(); 93: 94: if (dropAction != DnDConstants.ACTION_NONE 95: && dropAction != DnDConstants.ACTION_COPY 96: && dropAction != DnDConstants.ACTION_MOVE 97: && dropAction != DnDConstants.ACTION_COPY_OR_MOVE 98: && dropAction != DnDConstants.ACTION_LINK 99: && dropAction != DnDConstants.ACTION_REFERENCE) 100: throw new IllegalArgumentException(); 101: 102: int actionsMask = DnDConstants.ACTION_NONE 103: | DnDConstants.ACTION_COPY 104: | DnDConstants.ACTION_MOVE 105: | DnDConstants.ACTION_COPY_OR_MOVE 106: | DnDConstants.ACTION_LINK 107: | DnDConstants.ACTION_REFERENCE; 108: 109: if (~(actions ^ actionsMask) != 0) 110: throw new IllegalArgumentException(); 111: 112: this.dropAction = dropAction; 113: this.actions = actions; 114: this.location = location; 115: this.isLocalTx = isLocalTx; 116: } 117: 118: public Point getLocation() 119: { 120: return location; 121: } 122: 123: public DataFlavor[] getCurrentDataFlavors() 124: { 125: return context.getCurrentDataFlavors(); 126: } 127: 128: public List getCurrentDataFlavorsAsList() 129: { 130: return context.getCurrentDataFlavorsAsList(); 131: } 132: 133: public boolean isDataFlavorSupported(DataFlavor flavor) 134: { 135: return context.isDataFlavorSupported(flavor); 136: } 137: 138: public int getSourceActions() 139: { 140: return actions; 141: } 142: 143: public int getDropAction() 144: { 145: return dropAction; 146: } 147: 148: public Transferable getTransferable() 149: { 150: return context.getTransferable (); 151: } 152: 153: public void acceptDrop(int dropAction) 154: { 155: context.acceptDrop(dropAction); 156: } 157: 158: public void rejectDrop() 159: { 160: context.rejectDrop(); 161: } 162: 163: public void dropComplete(boolean success) 164: throws NotImplementedException 165: { 166: // FIXME: implement this 167: } 168: 169: public boolean isLocalTransfer() 170: { 171: return isLocalTx; 172: } 173: } // class DropTargetDropEvent