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 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.v7.event;
  17. import java.util.Map;
  18. import com.vaadin.event.Transferable;
  19. import com.vaadin.event.TransferableImpl;
  20. import com.vaadin.ui.Component;
  21. import com.vaadin.v7.data.Container;
  22. /**
  23. * Parent class for {@link Transferable} implementations that have a Vaadin
  24. * container as a data source. The transfer is associated with an item
  25. * (identified by its Id) and optionally also a property identifier (e.g. a
  26. * table column identifier when transferring a single table cell).
  27. *
  28. * The component must implement the interface {@link Container.Viewer}.
  29. *
  30. * In most cases, receivers of data transfers should depend on this class
  31. * instead of its concrete subclasses.
  32. *
  33. * @since 6.3
  34. *
  35. * @deprecated As of 8.0, no replacement available.
  36. */
  37. @Deprecated
  38. public abstract class DataBoundTransferable extends TransferableImpl {
  39. public DataBoundTransferable(Component sourceComponent,
  40. Map<String, Object> rawVariables) {
  41. super(sourceComponent, rawVariables);
  42. }
  43. /**
  44. * Returns the identifier of the item being transferred.
  45. *
  46. * @return item identifier
  47. */
  48. public abstract Object getItemId();
  49. /**
  50. * Returns the optional property identifier that the transfer concerns.
  51. *
  52. * This can be e.g. the table column from which a drag operation originated.
  53. *
  54. * @return property identifier
  55. */
  56. public abstract Object getPropertyId();
  57. /**
  58. * Returns the container data source from which the transfer occurs.
  59. *
  60. * {@link Container.Viewer#getContainerDataSource()} is used to obtain the
  61. * underlying container of the source component.
  62. *
  63. * @return Container
  64. */
  65. public Container getSourceContainer() {
  66. Component sourceComponent = getSourceComponent();
  67. if (sourceComponent instanceof Container.Viewer) {
  68. return ((Container.Viewer) sourceComponent)
  69. .getContainerDataSource();
  70. } else {
  71. // this should not happen
  72. return null;
  73. }
  74. }
  75. }