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