123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package com.vaadin.tests.components.combobox;
-
- import com.vaadin.server.VaadinRequest;
- import com.vaadin.tests.components.AbstractReindeerTestUI;
- import com.vaadin.ui.Button;
- import com.vaadin.ui.HorizontalLayout;
- import com.vaadin.ui.VerticalLayout;
- import com.vaadin.v7.ui.ComboBox;
-
- public class ComboBoxResetValue extends AbstractReindeerTestUI {
-
- protected static final String EMPTY_VALUE = "Empty value";
- protected static final String WITH_SET_NULL_SELECTION_ITEM_ID = "nullSelectionAllowedWithSetNullSelectionItemId";
- protected static final String WITHOUT_NULL_SELECTION_ITEM_ID = "nullSelectionAllowedWithoutNullSelectionItemId";
- protected static final String NULL_SELECTION_NOT_ALLOWED = "nullSelectionNotAllowed";
-
- @Override
- protected void setup(VaadinRequest request) {
- final ComboBox cbNullSelectionAllowedWithSetNullSelectionItemId = getComboBoxWithNullSelectionAllowedWithSetNullSelectionItemId();
- final ComboBox cbNullSelectionAllowedWithoutNullSelectionItemId = getComboBoxWithNullSelectionAllowedWithoutNullSelectionItemId();
- final ComboBox cbNullSelectionNotAllowed = getComboBoxWithNullSelectionNotAllowed();
-
- Button b = new Button("Reset");
- b.addClickListener(event -> {
- cbNullSelectionAllowedWithSetNullSelectionItemId.setValue(null);
- cbNullSelectionAllowedWithoutNullSelectionItemId.setValue(null);
- cbNullSelectionNotAllowed.setValue(null);
- });
- addComponents(new HorizontalLayout(new VerticalLayout(
- cbNullSelectionAllowedWithSetNullSelectionItemId,
- cbNullSelectionAllowedWithoutNullSelectionItemId,
- cbNullSelectionNotAllowed), b));
- }
-
- protected ComboBox getComboBoxWithNullSelectionAllowedWithSetNullSelectionItemId() {
- ComboBox cb = new ComboBox();
- cb.setId(WITH_SET_NULL_SELECTION_ITEM_ID);
- cb.setImmediate(true);
- cb.setNullSelectionAllowed(true);
-
- cb.addItem(EMPTY_VALUE);
- cb.setNullSelectionItemId(EMPTY_VALUE);
-
- cb.addItem(1);
- cb.select(1);
- return cb;
- }
-
- protected ComboBox getComboBoxWithNullSelectionAllowedWithoutNullSelectionItemId() {
- ComboBox cb = new ComboBox();
- cb.setId(WITHOUT_NULL_SELECTION_ITEM_ID);
- cb.setImmediate(true);
- cb.setNullSelectionAllowed(true);
-
- cb.addItem(1);
- cb.select(1);
- return cb;
- }
-
- protected ComboBox getComboBoxWithNullSelectionNotAllowed() {
- ComboBox cb = new ComboBox();
- cb.setId(NULL_SELECTION_NOT_ALLOWED);
- cb.setImmediate(true);
- cb.setNullSelectionAllowed(false);
-
- cb.addItem(1);
- cb.select(1);
- return cb;
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 13217;
- }
-
- @Override
- protected String getTestDescription() {
- return "Tests that reseting (setValue(null), select(null)) of combobox works correctly (removes/updates old selection, also correctly works with filtering)";
- }
-
- }
|