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.

FormsCssTest.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.vaadin.tests.components.uitest.components;
  2. import com.vaadin.tests.components.uitest.TestSampler;
  3. import com.vaadin.tests.util.Person;
  4. import com.vaadin.ui.HorizontalLayout;
  5. import com.vaadin.ui.LoginForm;
  6. import com.vaadin.ui.VerticalLayout;
  7. import com.vaadin.v7.data.fieldgroup.BeanFieldGroup;
  8. import com.vaadin.v7.data.fieldgroup.FieldGroup;
  9. import com.vaadin.v7.data.util.BeanItem;
  10. @SuppressWarnings("deprecation")
  11. public class FormsCssTest extends HorizontalLayout {
  12. private TestSampler parent;
  13. private int debugIdCounter = 0;
  14. public FormsCssTest(TestSampler parent) {
  15. this.parent = parent;
  16. setSpacing(true);
  17. setWidth("100%");
  18. VerticalLayout vl = new VerticalLayout();
  19. vl.setSpacing(false);
  20. vl.setMargin(false);
  21. FieldGroup fg = new BeanFieldGroup<>(Person.class);
  22. fg.setItemDataSource(new BeanItem<>(new Person()));
  23. for (Object propId : fg.getUnboundPropertyIds()) {
  24. if (!"address".equals(propId)) {
  25. vl.addComponent(fg.buildAndBind(propId));
  26. }
  27. }
  28. addComponent(vl);
  29. LoginForm login = new LoginForm();
  30. login.setId("form" + debugIdCounter++);
  31. login.setHeight("150px");
  32. addComponent(login);
  33. parent.addReadOnlyChangeListener(event -> {
  34. fg.setReadOnly(!fg.isReadOnly());
  35. // it's not possible to set LoginForm read-only
  36. });
  37. }
  38. @Override
  39. public void addComponent(com.vaadin.ui.Component c) {
  40. parent.registerComponent(c);
  41. super.addComponent(c);
  42. }
  43. }