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.

VTargetDetailIs.java 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. /**
  5. *
  6. */
  7. package com.vaadin.terminal.gwt.client.ui.dd;
  8. import com.vaadin.terminal.gwt.client.UIDL;
  9. @AcceptCriterion("com.vaadin.event.dd.acceptcriteria.TargetDetailIs")
  10. final public class VTargetDetailIs extends VAcceptCriterion {
  11. @Override
  12. protected boolean accept(VDragEvent drag, UIDL configuration) {
  13. String name = configuration.getStringAttribute("p");
  14. String t = configuration.hasAttribute("t") ? configuration
  15. .getStringAttribute("t").intern() : "s";
  16. Object value = null;
  17. if (t == "s") {
  18. value = configuration.getStringAttribute("v");
  19. } else if (t == "b") {
  20. value = configuration.getBooleanAttribute("v");
  21. }
  22. if (value != null) {
  23. Object object = drag.getDropDetails().get(name);
  24. if (object instanceof Enum) {
  25. return ((Enum<?>) object).name().equals(value);
  26. } else {
  27. return value.equals(object);
  28. }
  29. } else {
  30. return false;
  31. }
  32. }
  33. }