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.

TouchDevicesTooltip.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package com.vaadin.tests.components;
  2. import com.vaadin.annotations.Viewport;
  3. import com.vaadin.data.util.converter.StringToIntegerConverter;
  4. import com.vaadin.data.validator.IntegerRangeValidator;
  5. import com.vaadin.server.VaadinRequest;
  6. import com.vaadin.ui.Label;
  7. import com.vaadin.ui.TextField;
  8. import javax.validation.constraints.Min;
  9. import javax.validation.constraints.NotNull;
  10. @Viewport(value = "width=device-width,height=device-height")
  11. public class TouchDevicesTooltip extends AbstractTestUI {
  12. @Override
  13. protected void setup(VaadinRequest request) {
  14. final Label errorLabel = new Label("No error");
  15. addComponent(errorLabel);
  16. for (int i = 0; i < 50; i++) {
  17. createTextField(i);
  18. }
  19. }
  20. private void createTextField(int n) {
  21. TextField textField = new TextField("Value" + n);
  22. textField.setConverter(new StringToIntegerConverter());
  23. textField.addValidator(new IntegerRangeValidator(getErrorMessage(n), 0, 100));
  24. textField.setImmediate(true);
  25. textField.setValue("-5");
  26. addComponent(textField);
  27. }
  28. private String getErrorMessage(int n) {
  29. if(n % 2 == 0) {
  30. return "incorrect value" + n;
  31. } else {
  32. return "super long long long long long long long long long long long error message " + n;
  33. }
  34. }
  35. public static class Bean {
  36. @NotNull
  37. @Min(0)
  38. private Integer value;
  39. public Integer getValue() {
  40. return value;
  41. }
  42. public void setValue(Integer value) {
  43. this.value = value;
  44. }
  45. }
  46. @Override
  47. protected Integer getTicketNumber() {
  48. return 17150;
  49. }
  50. @Override
  51. public String getDescription() {
  52. return "Unable to dismiss a tooltip on touch devices";
  53. }
  54. }