Source for java.awt.dnd.DropTargetDropEvent

   1: /* DropTargetDropEvent.java --
   2:    Copyright (C) 2002, 2006 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 java.awt.Point;
  41: import java.awt.datatransfer.DataFlavor;
  42: import java.awt.datatransfer.Transferable;
  43: import java.util.List;
  44: 
  45: /**
  46:  * @since 1.2
  47:  */
  48: public class DropTargetDropEvent extends DropTargetEvent
  49: {
  50:   /**
  51:    * Compatible with JDK 1.2+
  52:    */
  53:   private static final long serialVersionUID = -1721911170440459322L;
  54: 
  55:   private final int dropAction;
  56:   private final int actions;
  57:   private final Point location;
  58:   private final boolean isLocalTx;
  59: 
  60:   /**
  61:    * Initializes a <code>DropTargetDropEvent</code>. By default this constructor
  62:    * assumes that the target is not int same JVM.
  63:    *
  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.
  67:    */
  68:   public DropTargetDropEvent(DropTargetContext dtc, Point location,
  69:                              int dropAction, int actions)
  70:   {
  71:     this(dtc, location, dropAction, actions, false);
  72:   }
  73: 
  74:   /**
  75:    * Initializes a <code>DropTargetDropEvent</code>.
  76:    *
  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.
  80:    */
  81:   public DropTargetDropEvent(DropTargetContext dtc, Point location,
  82:                              int dropAction, int actions, boolean isLocalTx)
  83:   {
  84:     super(dtc);
  85: 
  86:     if (location == null)
  87:       throw new NullPointerException();
  88: 
  89:     if (dtc == null)
  90:       throw new IllegalArgumentException();
  91: 
  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();
  99: 
 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