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.

GridDragStartEvent.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.ui.components.grid;
  17. import java.util.Collections;
  18. import java.util.List;
  19. import com.vaadin.shared.ui.dnd.EffectAllowed;
  20. import com.vaadin.ui.Grid;
  21. import com.vaadin.ui.dnd.event.DragStartEvent;
  22. /**
  23. * Drag start event on an HTML5 drag source {@link Grid} row.
  24. *
  25. * @param <T>
  26. * The Grid bean type.
  27. * @author Vaadin Ltd.
  28. * @see GridDragSource#addGridDragStartListener(GridDragStartListener)
  29. * @since 8.1
  30. */
  31. public class GridDragStartEvent<T> extends DragStartEvent<Grid<T>> {
  32. private final List<T> draggedItems;
  33. /**
  34. * Creates a drag start event.
  35. *
  36. * @param source
  37. * The source grid where the rows are being dragged from.
  38. * @param effectAllowed
  39. * Allowed effect from {@code DataTransfer.effectAllowed} object.
  40. * @param draggedItems
  41. * Set of items being dragged.
  42. */
  43. public GridDragStartEvent(Grid<T> source, EffectAllowed effectAllowed,
  44. List<T> draggedItems) {
  45. super(source, effectAllowed);
  46. this.draggedItems = draggedItems;
  47. }
  48. /**
  49. * Get the dragged row items.
  50. * <p>
  51. * The ordering of the list is the following: first the item that the drag
  52. * started from, optionally followed by all the other selected rows in
  53. * first-to-last order on the client side.
  54. *
  55. * @return an unmodifiable list of items that are being dragged.
  56. */
  57. public List<T> getDraggedItems() {
  58. return Collections.unmodifiableList(draggedItems);
  59. }
  60. }