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.

VTransferable.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.ui.dd;
  5. import java.util.Collection;
  6. import java.util.HashMap;
  7. import java.util.Map;
  8. import com.vaadin.event.dd.DragSource;
  9. import com.vaadin.terminal.gwt.client.Paintable;
  10. /**
  11. * Client side counterpart for Transferable in com.vaadin.event.Transferable
  12. *
  13. */
  14. public class VTransferable {
  15. private Paintable component;
  16. private final Map<String, Object> variables = new HashMap<String, Object>();
  17. /**
  18. * Returns the component from which the transferable is created (eg. a tree
  19. * which node is dragged).
  20. *
  21. * @return the component
  22. */
  23. public Paintable getDragSource() {
  24. return component;
  25. }
  26. /**
  27. * Sets the component currently being dragged or from which the transferable
  28. * is created (eg. a tree which node is dragged).
  29. * <p>
  30. * The server side counterpart of the componennt may implement
  31. * {@link DragSource} interface if it wants to translate or complement the
  32. * server side instance of this Transferable.
  33. *
  34. * @param component
  35. * the component to set
  36. */
  37. public void setDragSource(Paintable component) {
  38. this.component = component;
  39. }
  40. public Object getData(String dataFlawor) {
  41. return variables.get(dataFlawor);
  42. }
  43. public void setData(String dataFlawor, Object value) {
  44. variables.put(dataFlawor, value);
  45. }
  46. public Collection<String> getDataFlavors() {
  47. return variables.keySet();
  48. }
  49. /**
  50. * This helper method should only be called by {@link VDragAndDropManager}.
  51. *
  52. * @return data in this Transferable that needs to be moved to server.
  53. */
  54. Map<String, Object> getVariableMap() {
  55. return variables;
  56. }
  57. }