001/* DropTargetDropEvent.java -- 002 Copyright (C) 2002, 2006 Free Software Foundation, Inc. 003 004This file is part of GNU Classpath. 005 006GNU Classpath is free software; you can redistribute it and/or modify 007it under the terms of the GNU General Public License as published by 008the Free Software Foundation; either version 2, or (at your option) 009any later version. 010 011GNU Classpath is distributed in the hope that it will be useful, but 012WITHOUT ANY WARRANTY; without even the implied warranty of 013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014General Public License for more details. 015 016You should have received a copy of the GNU General Public License 017along with GNU Classpath; see the file COPYING. If not, write to the 018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 01902110-1301 USA. 020 021Linking this library statically or dynamically with other modules is 022making a combined work based on this library. Thus, the terms and 023conditions of the GNU General Public License cover the whole 024combination. 025 026As a special exception, the copyright holders of this library give you 027permission to link this library with independent modules to produce an 028executable, regardless of the license terms of these independent 029modules, and to copy and distribute the resulting executable under 030terms of your choice, provided that you also meet, for each linked 031independent module, the terms and conditions of the license of that 032module. An independent module is a module which is not derived from 033or based on this library. If you modify this library, you may extend 034this exception to your version of the library, but you are not 035obligated to do so. If you do not wish to do so, delete this 036exception statement from your version. */ 037 038package java.awt.dnd; 039 040import java.awt.Point; 041import java.awt.datatransfer.DataFlavor; 042import java.awt.datatransfer.Transferable; 043import java.util.List; 044 045/** 046 * @since 1.2 047 */ 048public class DropTargetDropEvent extends DropTargetEvent 049{ 050 /** 051 * Compatible with JDK 1.2+ 052 */ 053 private static final long serialVersionUID = -1721911170440459322L; 054 055 private final int dropAction; 056 private final int actions; 057 private final Point location; 058 private final boolean isLocalTx; 059 060 /** 061 * Initializes a <code>DropTargetDropEvent</code>. By default this constructor 062 * assumes that the target is not int same JVM. 063 * 064 * @exception IllegalArgumentException If dropAction is not one of DnDConstants, 065 * actions is not a bitwise mask of DnDConstants, or dtc is null. 066 * @exception NullPointerException If location is null. 067 */ 068 public DropTargetDropEvent(DropTargetContext dtc, Point location, 069 int dropAction, int actions) 070 { 071 this(dtc, location, dropAction, actions, false); 072 } 073 074 /** 075 * Initializes a <code>DropTargetDropEvent</code>. 076 * 077 * @exception IllegalArgumentException If dropAction is not one of DnDConstants, 078 * actions is not a bitwise mask of DnDConstants, or dtc is null. 079 * @exception NullPointerException If location is null. 080 */ 081 public DropTargetDropEvent(DropTargetContext dtc, Point location, 082 int dropAction, int actions, boolean isLocalTx) 083 { 084 super(dtc); 085 086 if (location == null) 087 throw new NullPointerException(); 088 089 if (dtc == null) 090 throw new IllegalArgumentException(); 091 092 if (dropAction != DnDConstants.ACTION_NONE 093 && dropAction != DnDConstants.ACTION_COPY 094 && dropAction != DnDConstants.ACTION_MOVE 095 && dropAction != DnDConstants.ACTION_COPY_OR_MOVE 096 && dropAction != DnDConstants.ACTION_LINK 097 && dropAction != DnDConstants.ACTION_REFERENCE) 098 throw new IllegalArgumentException(); 099 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; 106 107 if (~(actions ^ actionsMask) != 0) 108 throw new IllegalArgumentException(); 109 110 this.dropAction = dropAction; 111 this.actions = actions; 112 this.location = location; 113 this.isLocalTx = isLocalTx; 114 } 115 116 public Point getLocation() 117 { 118 return location; 119 } 120 121 public DataFlavor[] getCurrentDataFlavors() 122 { 123 return context.getCurrentDataFlavors(); 124 } 125 126 public List<DataFlavor> getCurrentDataFlavorsAsList() 127 { 128 return context.getCurrentDataFlavorsAsList(); 129 } 130 131 public boolean isDataFlavorSupported(DataFlavor flavor) 132 { 133 return context.isDataFlavorSupported(flavor); 134 } 135 136 public int getSourceActions() 137 { 138 return actions; 139 } 140 141 public int getDropAction() 142 { 143 return dropAction; 144 } 145 146 public Transferable getTransferable() 147 { 148 return context.getTransferable (); 149 } 150 151 public void acceptDrop(int dropAction) 152 { 153 context.acceptDrop(dropAction); 154 } 155 156 public void rejectDrop() 157 { 158 context.rejectDrop(); 159 } 160 161 public void dropComplete(boolean success) 162 { 163 context.dropComplete(success); 164 } 165 166 public boolean isLocalTransfer() 167 { 168 return isLocalTx; 169 } 170} // class DropTargetDropEvent