aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java
blob: a9f95ae822728213962900975a90840bf62480b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.vaadin.tests.components.combobox;

import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.Button;
import com.vaadin.v7.shared.ui.combobox.FilteringMode;
import com.vaadin.v7.ui.ComboBox;

public class ComboBoxCombinedWithEnterShortcut extends TestBase {
    final String[] cities = { "Berlin", "Brussels", "Helsinki", "Madrid",
            "Oslo", "Paris", "Stockholm" };

    private Log log = new Log(5);

    @Override
    protected void setup() {
        final ComboBox l = new ComboBox("Please select a city");
        for (String city : cities) {
            l.addItem(city);
        }

        l.setFilteringMode(FilteringMode.OFF);
        l.setImmediate(true);
        l.setNewItemsAllowed(true);

        Button aButton = new Button("Show Value");
        aButton.setClickShortcut(KeyCode.ENTER);
        aButton.addClickListener(event -> log
                .log("Button clicked. ComboBox value: " + l.getValue()));

        addComponent(log);
        addComponent(l);
        addComponent(aButton);
    }

    @Override
    protected String getDescription() {
        return "Button has Enter as click shortcut key. The shortcut should not be triggered when selecting an item in the dropdown";
    }

    @Override
    protected Integer getTicketNumber() {
        return 6686;
    }

}