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.

DropTargetDetailEquals.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. /**
  5. *
  6. */
  7. package com.vaadin.event.dd.acceptCriteria;
  8. import com.vaadin.event.dd.DragAndDropEvent;
  9. import com.vaadin.terminal.PaintException;
  10. import com.vaadin.terminal.PaintTarget;
  11. import com.vaadin.terminal.gwt.client.ui.dd.VDropDetailEquals;
  12. /**
  13. * Criteria for checking if drop target details contain the specific property
  14. * with the specific value.
  15. *
  16. * @since 6.3
  17. *
  18. */
  19. @ClientCriterion(VDropDetailEquals.class)
  20. public final class DropTargetDetailEquals extends ClientSideCriterion {
  21. private String propertyName;
  22. private String value;
  23. /**
  24. * TODO should support basic UIDL data types
  25. *
  26. * @param propertyName
  27. * @param value
  28. */
  29. public DropTargetDetailEquals(String propertyName, String value) {
  30. this.propertyName = propertyName;
  31. this.value = value;
  32. }
  33. @Override
  34. public void paintContent(PaintTarget target) throws PaintException {
  35. super.paintContent(target);
  36. target.addAttribute("p", propertyName);
  37. target.addAttribute("v", value);
  38. }
  39. public boolean accepts(DragAndDropEvent dragEvent) {
  40. Object data = dragEvent.getDropTargetDetails().getData(propertyName);
  41. return value.equals(data);
  42. }
  43. }