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.

HorizontalLayoutFullsizeContentWithErrorMsg.java 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package com.vaadin.tests.components.orderedlayout;
  2. import com.vaadin.server.UserError;
  3. import com.vaadin.server.VaadinRequest;
  4. import com.vaadin.tests.components.AbstractReindeerTestUI;
  5. import com.vaadin.ui.Alignment;
  6. import com.vaadin.ui.Button;
  7. import com.vaadin.ui.Button.ClickEvent;
  8. import com.vaadin.ui.Button.ClickListener;
  9. import com.vaadin.ui.HorizontalLayout;
  10. import com.vaadin.v7.ui.TextField;
  11. public class HorizontalLayoutFullsizeContentWithErrorMsg
  12. extends AbstractReindeerTestUI {
  13. static final String FIELD_ID = "f";
  14. static final String BUTTON_ID = "b";
  15. private TextField tf;
  16. @Override
  17. protected Integer getTicketNumber() {
  18. return 12564;
  19. }
  20. /*
  21. * (non-Javadoc)
  22. *
  23. * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
  24. * VaadinRequest)
  25. */
  26. @Override
  27. protected void setup(VaadinRequest request) {
  28. HorizontalLayout hl = new HorizontalLayout();
  29. hl.setWidth("500px");
  30. tf = new TextField();
  31. tf.setId(FIELD_ID);
  32. tf.setWidth("100%");
  33. hl.addComponent(tf);
  34. hl.setExpandRatio(tf, 1);
  35. hl.setComponentAlignment(tf, Alignment.MIDDLE_CENTER);
  36. Button toggleError = new Button("Toggle error");
  37. toggleError.setId(BUTTON_ID);
  38. toggleError.addClickListener(new ClickListener() {
  39. @Override
  40. public void buttonClick(ClickEvent event) {
  41. tf.setComponentError(tf.getComponentError() == null
  42. ? new UserError("foo") : null);
  43. }
  44. });
  45. hl.addComponent(toggleError);
  46. addComponent(hl);
  47. }
  48. /*
  49. * (non-Javadoc)
  50. *
  51. * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
  52. */
  53. @Override
  54. protected String getTestDescription() {
  55. return "TextField should remain at same level vertically, horizontally width should adjust to fit error indicator.";
  56. }
  57. }