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.

DataBoundTransferable.java 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.event;
  5. import java.util.Map;
  6. import com.vaadin.data.Container;
  7. import com.vaadin.ui.Component;
  8. /**
  9. * Parent class for {@link Transferable} implementations that have a Vaadin
  10. * container as a data source. The transfer is associated with an item
  11. * (identified by its Id) and optionally also a property identifier (e.g. a
  12. * table column identifier when transferring a single table cell).
  13. *
  14. * The component must implement the interface
  15. * {@link com.vaadin.data.Container.Viewer}.
  16. *
  17. * In most cases, receivers of data transfers should depend on this class
  18. * instead of its concrete subclasses.
  19. *
  20. * @since 6.3
  21. */
  22. public abstract class DataBoundTransferable extends TransferableImpl {
  23. public DataBoundTransferable(Component sourceComponent,
  24. Map<String, Object> rawVariables) {
  25. super(sourceComponent, rawVariables);
  26. }
  27. /**
  28. * Returns the identifier of the item being transferred.
  29. *
  30. * @return item identifier
  31. */
  32. public abstract Object getItemId();
  33. /**
  34. * Returns the optional property identifier that the transfer concerns.
  35. *
  36. * This can be e.g. the table column from which a drag operation originated.
  37. *
  38. * @return property identifier
  39. */
  40. public abstract Object getPropertyId();
  41. /**
  42. * Returns the container data source from which the transfer occurs.
  43. *
  44. * {@link com.vaadin.data.Container.Viewer#getContainerDataSource()} is used
  45. * to obtain the underlying container of the source component.
  46. *
  47. * @return Container
  48. */
  49. public Container getSourceContainer() {
  50. Component sourceComponent = getSourceComponent();
  51. if (sourceComponent instanceof Container.Viewer) {
  52. return ((Container.Viewer) sourceComponent)
  53. .getContainerDataSource();
  54. } else {
  55. // this should not happen
  56. return null;
  57. }
  58. }
  59. }