You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GridDropEvent.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.event.dnd.grid;
  17. import com.vaadin.event.dnd.DragSourceExtension;
  18. import com.vaadin.event.dnd.DropEvent;
  19. import com.vaadin.shared.ui.grid.DropLocation;
  20. import com.vaadin.ui.AbstractComponent;
  21. import com.vaadin.ui.Grid;
  22. import com.vaadin.ui.GridDropTarget;
  23. /**
  24. * Drop event on an HTML5 drop target {@link Grid} row.
  25. *
  26. * @param <T>
  27. * The Grid bean type.
  28. * @author Vaadin Ltd.
  29. * @see GridDropTarget#addGridDropListener(GridDropListener)
  30. * @since 8.1
  31. */
  32. public class GridDropEvent<T> extends DropEvent<Grid<T>> {
  33. private final T dropTargetRow;
  34. private final DropLocation dropLocation;
  35. /**
  36. * Creates a Grid row drop event.
  37. *
  38. * @param target
  39. * Grid that received the drop.
  40. * @param dataTransferText
  41. * Data of type {@code "text"} from the {@code DataTransfer}
  42. * object.
  43. * @param dragSourceExtension
  44. * Drag source extension of the component that initiated the drop
  45. * event.
  46. * @param dropTargetRow
  47. * Target row that received the drop.
  48. * @param dropLocation
  49. * Location of the drop within the target row.
  50. */
  51. public GridDropEvent(Grid<T> target, String dataTransferText,
  52. DragSourceExtension<? extends AbstractComponent> dragSourceExtension,
  53. T dropTargetRow, DropLocation dropLocation) {
  54. super(target, dataTransferText, dragSourceExtension);
  55. this.dropTargetRow = dropTargetRow;
  56. this.dropLocation = dropLocation;
  57. }
  58. /**
  59. * Get the row item source of this event.
  60. *
  61. * @return The row item this event was originated from.
  62. */
  63. public T getDropTargetRow() {
  64. return dropTargetRow;
  65. }
  66. /**
  67. * Get the location of the drop within the row.
  68. *
  69. * @return Location of the drop within the row.
  70. */
  71. public DropLocation getDropLocation() {
  72. return dropLocation;
  73. }
  74. }