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.

TextAreaSetRows.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package com.vaadin.tests.components.textarea;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractTestUI;
  4. import com.vaadin.tests.util.LoremIpsum;
  5. import com.vaadin.ui.Button;
  6. import com.vaadin.ui.CssLayout;
  7. import com.vaadin.ui.Panel;
  8. import com.vaadin.ui.TextArea;
  9. public class TextAreaSetRows extends AbstractTestUI {
  10. protected static final String ROWS_0 = "Set rows to 0";
  11. protected static final String ROWS_1 = "Set rows to 1";
  12. protected static final String ROWS_2 = "Set rows to 2";
  13. protected static final String ROWS_3 = "Set rows to 3";
  14. protected static final String ROWS_4 = "Set rows to 4";
  15. protected static final String HEIGHT0 = "Set height to 0px";
  16. protected static final String HEIGHTR = "Reset height setting";
  17. protected static final String WWRAP = "Toggle word wrap";
  18. protected static final String LONGS = "Use longer contents (separate)";
  19. protected static final String LONGN = "Use longer contents (no breaks)";
  20. protected static final String SCROLLB = "Add scrollbar to panel";
  21. @Override
  22. protected void setup(VaadinRequest request) {
  23. TextArea ta = new TextArea();
  24. String value = "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n";
  25. ta.setValue(value);
  26. addComponent(ta);
  27. addComponent(new Button(ROWS_0, e -> ta.setRows(0)));
  28. addComponent(new Button(ROWS_1, e -> ta.setRows(1)));
  29. addComponent(new Button(ROWS_2, e -> ta.setRows(2)));
  30. addComponent(new Button(ROWS_3, e -> ta.setRows(3)));
  31. addComponent(new Button(ROWS_4, e -> ta.setRows(4)));
  32. addComponent(new Button(HEIGHT0, e -> ta.setHeight("0px")));
  33. addComponent(new Button(HEIGHTR, e -> ta.setHeight("-1px")));
  34. addComponent(new Button(WWRAP, e -> ta.setWordWrap(!ta.isWordWrap())));
  35. addComponent(new Button(LONGS,
  36. e -> ta.setValue(value + LoremIpsum.get(50))));
  37. addComponent(new Button(LONGN,
  38. e -> ta.setValue(value + getClass().getName())));
  39. Panel p = new Panel();
  40. CssLayout content = new CssLayout();
  41. p.setContent(content);
  42. content.setHeight("0px");
  43. p.setHeightUndefined();
  44. p.setWidth("100px");
  45. addComponent(p);
  46. addComponent(new Button(SCROLLB, e -> content.setWidth("200px")));
  47. }
  48. @Override
  49. protected Integer getTicketNumber() {
  50. return 10138;
  51. }
  52. @Override
  53. protected String getTestDescription() {
  54. return "Default height: 5 rows. Minimum height: 1 rows. "
  55. + "Height should update as expected. Disabling word wrap "
  56. + "adds space for a scrollbar whether one is needed or not. "
  57. + "Firefox always behaves like word wrap was disabled.";
  58. }
  59. }