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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. /**
  5. *
  6. */
  7. package com.vaadin.terminal.gwt.client.ui.dd;
  8. import com.vaadin.terminal.gwt.client.ApplicationConnection;
  9. import com.vaadin.terminal.gwt.client.UIDL;
  10. /**
  11. * TODO implementation could now be simplified/optimized
  12. *
  13. */
  14. final public class VAnd extends VAcceptCriterion {
  15. private boolean b1;
  16. private boolean b2;
  17. private VAcceptCriterion crit1;
  18. private VAcceptCriterion crit2;
  19. private VAcceptCriterion getCriteria(VDragEvent drag, UIDL configuration,
  20. int i) {
  21. UIDL childUIDL = configuration.getChildUIDL(i);
  22. return VAcceptCriteria.get(childUIDL.getStringAttribute("name"));
  23. }
  24. @Override
  25. public boolean validates(VDragEvent drag, UIDL configuration) {
  26. if (crit1 == null) {
  27. crit1 = getCriteria(drag, configuration, 0);
  28. crit2 = getCriteria(drag, configuration, 1);
  29. if (crit1 == null || crit2 == null) {
  30. ApplicationConnection.getConsole().log(
  31. "And criteria didn't found a chidl criteria");
  32. return false;
  33. }
  34. }
  35. b1 = false;
  36. b2 = false;
  37. VAcceptCallback accept1cb = new VAcceptCallback() {
  38. public void accepted(VDragEvent event) {
  39. b1 = true;
  40. }
  41. };
  42. VAcceptCallback accept2cb = new VAcceptCallback() {
  43. public void accepted(VDragEvent event) {
  44. b2 = true;
  45. }
  46. };
  47. crit1.accept(drag, configuration.getChildUIDL(0), accept1cb);
  48. crit2.accept(drag, configuration.getChildUIDL(1), accept2cb);
  49. return b1 && b2;
  50. }
  51. }