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

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