DropTargetDropEvent.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* DropTargetDropEvent.java --
  2. Copyright (C) 2002, 2006 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.awt.dnd;
  32. import java.awt.Point;
  33. import java.awt.datatransfer.DataFlavor;
  34. import java.awt.datatransfer.Transferable;
  35. import java.util.List;
  36. /**
  37. * @since 1.2
  38. */
  39. public class DropTargetDropEvent extends DropTargetEvent
  40. {
  41. /**
  42. * Compatible with JDK 1.2+
  43. */
  44. private static final long serialVersionUID = -1721911170440459322L;
  45. private final int dropAction;
  46. private final int actions;
  47. private final Point location;
  48. private final boolean isLocalTx;
  49. /**
  50. * Initializes a <code>DropTargetDropEvent</code>. By default this constructor
  51. * assumes that the target is not int same JVM.
  52. *
  53. * @exception IllegalArgumentException If dropAction is not one of DnDConstants,
  54. * actions is not a bitwise mask of DnDConstants, or dtc is null.
  55. * @exception NullPointerException If location is null.
  56. */
  57. public DropTargetDropEvent(DropTargetContext dtc, Point location,
  58. int dropAction, int actions)
  59. {
  60. this(dtc, location, dropAction, actions, false);
  61. }
  62. /**
  63. * Initializes a <code>DropTargetDropEvent</code>.
  64. *
  65. * @exception IllegalArgumentException If dropAction is not one of DnDConstants,
  66. * actions is not a bitwise mask of DnDConstants, or dtc is null.
  67. * @exception NullPointerException If location is null.
  68. */
  69. public DropTargetDropEvent(DropTargetContext dtc, Point location,
  70. int dropAction, int actions, boolean isLocalTx)
  71. {
  72. super(dtc);
  73. if (location == null)
  74. throw new NullPointerException();
  75. if (dtc == null)
  76. throw new IllegalArgumentException();
  77. if (dropAction != DnDConstants.ACTION_NONE
  78. && dropAction != DnDConstants.ACTION_COPY
  79. && dropAction != DnDConstants.ACTION_MOVE
  80. && dropAction != DnDConstants.ACTION_COPY_OR_MOVE
  81. && dropAction != DnDConstants.ACTION_LINK
  82. && dropAction != DnDConstants.ACTION_REFERENCE)
  83. throw new IllegalArgumentException();
  84. int actionsMask = DnDConstants.ACTION_NONE
  85. | DnDConstants.ACTION_COPY
  86. | DnDConstants.ACTION_MOVE
  87. | DnDConstants.ACTION_COPY_OR_MOVE
  88. | DnDConstants.ACTION_LINK
  89. | DnDConstants.ACTION_REFERENCE;
  90. if (~(actions ^ actionsMask) != 0)
  91. throw new IllegalArgumentException();
  92. this.dropAction = dropAction;
  93. this.actions = actions;
  94. this.location = location;
  95. this.isLocalTx = isLocalTx;
  96. }
  97. public Point getLocation()
  98. {
  99. return location;
  100. }
  101. public DataFlavor[] getCurrentDataFlavors()
  102. {
  103. return context.getCurrentDataFlavors();
  104. }
  105. public List<DataFlavor> getCurrentDataFlavorsAsList()
  106. {
  107. return context.getCurrentDataFlavorsAsList();
  108. }
  109. public boolean isDataFlavorSupported(DataFlavor flavor)
  110. {
  111. return context.isDataFlavorSupported(flavor);
  112. }
  113. public int getSourceActions()
  114. {
  115. return actions;
  116. }
  117. public int getDropAction()
  118. {
  119. return dropAction;
  120. }
  121. public Transferable getTransferable()
  122. {
  123. return context.getTransferable ();
  124. }
  125. public void acceptDrop(int dropAction)
  126. {
  127. context.acceptDrop(dropAction);
  128. }
  129. public void rejectDrop()
  130. {
  131. context.rejectDrop();
  132. }
  133. public void dropComplete(boolean success)
  134. {
  135. context.dropComplete(success);
  136. }
  137. public boolean isLocalTransfer()
  138. {
  139. return isLocalTx;
  140. }
  141. } // class DropTargetDropEvent