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.

ComboBoxValueInput.java 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.vaadin.tests.components.combobox;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractReindeerTestUI;
  4. import com.vaadin.v7.shared.ui.combobox.FilteringMode;
  5. import com.vaadin.v7.ui.ComboBox;
  6. public class ComboBoxValueInput extends AbstractReindeerTestUI {
  7. @Override
  8. protected void setup(VaadinRequest request) {
  9. (getLayout()).setSpacing(true);
  10. ComboBox cb = getComboBox("A combobox", false, "default");
  11. addComponent(cb);
  12. cb = getComboBox("A combobox with input prompt", false,
  13. "default-prompt");
  14. cb.setInputPrompt("Please select");
  15. addComponent(cb);
  16. cb = getComboBox("A combobox with null item", true, "null");
  17. addComponent(cb);
  18. cb = getComboBox("A combobox with null item and input prompt", true,
  19. "null-prompt");
  20. cb.setInputPrompt("Please select");
  21. addComponent(cb);
  22. cb = getComboBox("A combobox with filteringMode off", false,
  23. "filtering-off");
  24. cb.setFilteringMode(FilteringMode.OFF);
  25. addComponent(cb);
  26. }
  27. @Override
  28. protected String getTestDescription() {
  29. return "A combobox should always show the selected value when it is not focused. Entering a text when nothing is selected and blurring the combobox should reset the value. The same should happen when a value is selected";
  30. }
  31. @Override
  32. protected Integer getTicketNumber() {
  33. return 3268;
  34. }
  35. private ComboBox getComboBox(String caption, boolean addNullItem,
  36. String id) {
  37. ComboBox cb = new ComboBox(caption);
  38. cb.setImmediate(true);
  39. if (addNullItem) {
  40. cb.addItem("Null item");
  41. cb.setNullSelectionItemId("Null item");
  42. }
  43. cb.addItem("Value 1");
  44. cb.addItem("Value 2");
  45. cb.addItem("Value 3");
  46. cb.setId(id);
  47. return cb;
  48. }
  49. }