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.

TextFieldsCssTest.java 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package com.vaadin.tests.components.uitest.components;
  2. import java.util.Iterator;
  3. import com.vaadin.tests.components.uitest.TestSampler;
  4. import com.vaadin.ui.AbstractField;
  5. import com.vaadin.ui.Component;
  6. import com.vaadin.ui.GridLayout;
  7. import com.vaadin.ui.PasswordField;
  8. import com.vaadin.ui.RichTextArea;
  9. import com.vaadin.ui.TextField;
  10. import com.vaadin.v7.ui.TextArea;
  11. import com.vaadin.v7.ui.themes.ChameleonTheme;
  12. import com.vaadin.v7.ui.themes.Reindeer;
  13. @SuppressWarnings("deprecation")
  14. public class TextFieldsCssTest extends GridLayout {
  15. private TestSampler parent;
  16. private int debugIdCounter = 0;
  17. public TextFieldsCssTest(TestSampler parent) {
  18. this.parent = parent;
  19. setSpacing(true);
  20. setColumns(7);
  21. setRows(2);
  22. setWidth("100%");
  23. createTextFieldWith(null, null, null);
  24. createTextFieldWith("Input prompt", null, "Input prompt");
  25. createTextFieldWith("Small", Reindeer.TEXTFIELD_SMALL, null);
  26. createTextFieldWith("Big", ChameleonTheme.TEXTFIELD_BIG, null);
  27. createTextFieldWith("Search", ChameleonTheme.TEXTFIELD_SEARCH, null);
  28. TextArea ta = new TextArea();
  29. ta.setId("textfield" + debugIdCounter++);
  30. addComponent(ta);
  31. PasswordField pf = new PasswordField();
  32. pf.setId("textfield" + debugIdCounter++);
  33. addComponent(pf);
  34. RichTextArea rta = new RichTextArea();
  35. rta.setId("textfield" + debugIdCounter++);
  36. addComponent(rta, 0, 1, 6, 1);
  37. parent.addReadOnlyChangeListener(event -> {
  38. Iterator<Component> iterator = iterator();
  39. while (iterator.hasNext()) {
  40. Component c = iterator.next();
  41. if (c instanceof AbstractField) {
  42. AbstractField<?> af = (AbstractField<?>) c;
  43. af.setReadOnly(!af.isReadOnly());
  44. }
  45. }
  46. });
  47. }
  48. private void createTextFieldWith(String caption, String primaryStyleName,
  49. String inputPrompt) {
  50. TextField tf = new TextField();
  51. tf.setId("textfield" + debugIdCounter++);
  52. if (caption != null) {
  53. tf.setCaption(caption);
  54. }
  55. if (primaryStyleName != null) {
  56. tf.addStyleName(primaryStyleName);
  57. }
  58. if (inputPrompt != null) {
  59. tf.setPlaceholder(inputPrompt);
  60. }
  61. addComponent(tf);
  62. }
  63. @Override
  64. public void addComponent(Component c) {
  65. parent.registerComponent(c);
  66. super.addComponent(c);
  67. }
  68. @Override
  69. public void addComponent(Component component, int column1, int row1,
  70. int column2, int row2)
  71. throws OverlapsException, OutOfBoundsException {
  72. parent.registerComponent(component);
  73. super.addComponent(component, column1, row1, column2, row2);
  74. }
  75. }