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.

WidthToggleReadOnly.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.vaadin.tests.components.combobox;
  2. import com.vaadin.tests.components.TestBase;
  3. import com.vaadin.ui.CheckBox;
  4. import com.vaadin.ui.ComboBox;
  5. public class WidthToggleReadOnly extends TestBase {
  6. @Override
  7. protected void setup() {
  8. ComboBox combo = createNewComboBoxA("Untouched combobox");
  9. addComponent(combo);
  10. combo = createNewComboBoxA("Toggled combobox");
  11. addComponent(combo);
  12. addComponent(createReadOnlyForComboBox(combo));
  13. }
  14. private ComboBox<String> createNewComboBoxA(String caption) {
  15. ComboBox<String> combo = new ComboBox<>(caption);
  16. combo.setItems("first");
  17. combo.setValue("first");
  18. addComponent(combo);
  19. return combo;
  20. }
  21. private CheckBox createReadOnlyForComboBox(ComboBox combo) {
  22. CheckBox readonly = new CheckBox("Second combobox is read only");
  23. readonly.setValue(combo.isReadOnly());
  24. readonly.addValueChangeListener(
  25. event -> combo.setReadOnly(event.getValue()));
  26. addComponent(readonly);
  27. return readonly;
  28. }
  29. @Override
  30. protected String getDescription() {
  31. return "Check that toggling read only mode of second combobox does not change it's width.";
  32. }
  33. @Override
  34. protected Integer getTicketNumber() {
  35. return 5833;
  36. }
  37. }