]> source.dussan.org Git - vaadin-framework.git/blob
c10e1ece643c6707ca357c5b24ef8dfb66530fa0
[vaadin-framework.git] /
1 package com.vaadin.tests.components.combobox;
2
3 import com.vaadin.server.VaadinRequest;
4 import com.vaadin.tests.components.AbstractTestUI;
5 import com.vaadin.ui.Label;
6 import com.vaadin.v7.data.Property.ValueChangeEvent;
7 import com.vaadin.v7.data.Property.ValueChangeListener;
8 import com.vaadin.v7.ui.ComboBox;
9
10 @SuppressWarnings("serial")
11 public class ComboSelectedValueBeyondTheFirstDropdownPage
12         extends AbstractTestUI {
13
14     protected static final int ITEM_COUNT = 21;
15     protected static final String ITEM_NAME_TEMPLATE = "Item %d";
16
17     @Override
18     protected void setup(VaadinRequest request) {
19         Label value = getLabel();
20         ComboBox combobox = getComboBox(value);
21
22         addComponent(combobox);
23         addComponent(value);
24     }
25
26     private Label getLabel() {
27         final Label value = new Label();
28         value.setId("value");
29
30         return value;
31     }
32
33     private ComboBox getComboBox(final Label value) {
34         final ComboBox combobox = new ComboBox("MyCaption");
35         combobox.setDescription(
36                 "ComboBox with more than 10 elements in it's dropdown list.");
37
38         combobox.setImmediate(true);
39
40         for (int i = 1; i <= ITEM_COUNT; i++) {
41             combobox.addItem(String.format(ITEM_NAME_TEMPLATE, i));
42         }
43
44         combobox.addValueChangeListener(new ValueChangeListener() {
45             @Override
46             public void valueChange(ValueChangeEvent event) {
47                 value.setValue(String.valueOf(event.getProperty().getValue()));
48             }
49         });
50
51         return combobox;
52     }
53
54     @Override
55     protected String getTestDescription() {
56         return "Test for ensuring that ComboBox shows selected value beyound the first dropdown page";
57     }
58
59     @Override
60     protected Integer getTicketNumber() {
61         return 10600;
62     }
63 }