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.

VAnd.java 1.7KB

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