1. /*
  2. * @(#)DragSourceDragEvent.java 1.17 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.awt.dnd;
  8. import java.awt.dnd.DragSourceEvent;
  9. /**
  10. * The <code>DragSourceDragEvent</code> is
  11. * delivered from the <code>DragSourceContextPeer</code>,
  12. * via the <code>DragSourceContext</code>, to the currently
  13. * registered <code>DragSourceListener</code>.
  14. * It contains state regarding the current state of the operation to enable
  15. * the operations initiator to provide the end user with the appropriate
  16. * drag over feedback.
  17. *
  18. * @version 1.17
  19. * @since JDK1.2
  20. *
  21. */
  22. public class DragSourceDragEvent extends DragSourceEvent {
  23. /**
  24. * Constructs a <code>DragSourceDragEvent</code>.
  25. * This class is typically
  26. * instantiated by the <code>DragSourceContextPeer</code>
  27. * rather than directly
  28. * by client code.
  29. * <P>
  30. * @param dsc the <code>DragSourceContext</code> that is to manage
  31. * notifications for this event.
  32. * @param dropAction the value of one of the static fields from
  33. * <code>DNDConstants</code> indicating the type of user drop
  34. * action this event represents.
  35. * @param actions the value of one of the static fields from
  36. * <code>DNDConstants</code> indicating the type of target drop
  37. * action supported by and returned from the current drop target.
  38. * @param modifiers specifies the state of the input device modifiers
  39. * associated with the user gesture.
  40. */
  41. public DragSourceDragEvent(DragSourceContext dsc, int dropAction, int actions, int modifiers) {
  42. super(dsc);
  43. targetActions = actions;
  44. gestureModifiers = modifiers;
  45. this.dropAction = dropAction;
  46. }
  47. /**
  48. * This method returns the logical intersection of the current target,
  49. * source, and user actions.
  50. * <P>
  51. * @return the logical intersection
  52. * of the current target, source and user actions
  53. */
  54. public int getTargetActions() {
  55. return targetActions;
  56. }
  57. /**
  58. * This method returns an <code>int</code> representing
  59. * the current state of the input device modifiers
  60. * associated with the user's gesture. Typically these
  61. * would be mouse buttons or keyboard modifiers.
  62. * <P>
  63. * @return the current state of the input device modifiers
  64. */
  65. public int getGestureModifiers() {
  66. return gestureModifiers;
  67. }
  68. /**
  69. * This method returns an <code>int</code> representing
  70. * the user's currently selected drop action.
  71. * <P>
  72. * @return the user's currently selected drop action
  73. */
  74. public int getUserAction() { return dropAction; }
  75. /**
  76. * This method returns an <code>int</code> representing
  77. * the effective drop action which is the
  78. * intersection of the user's
  79. * selected action, and the source and target actions.
  80. * <P>
  81. * @return the effective drop action which is the
  82. * intersection of the user's
  83. * selected action, and the source and target actions.
  84. */
  85. public int getDropAction() {
  86. return dropAction & targetActions & getDragSourceContext().getSourceActions();
  87. }
  88. /*
  89. * fields
  90. */
  91. private int targetActions = DnDConstants.ACTION_NONE;
  92. private int dropAction = DnDConstants.ACTION_NONE;
  93. private int gestureModifiers = 0;
  94. }