aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxParentDisable.java
blob: 14cf564d8d0089650347282f3375d5ca2c9ad72a (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
48
49
50
51
52
53
54
55
package com.vaadin.tests.components.combobox;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.VerticalLayout;

/**
 * The Application's "main" class
 */
@SuppressWarnings("serial")
public class ComboBoxParentDisable extends AbstractTestUIWithLog {

    @Override
    protected void setup(VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        final FormLayout formLayout = new FormLayout();

        final ComboBox<String> combo = new ComboBox<>("Item:");
        combo.setItems("Item 1", "Item 2", "Item 3", "Item 4");
        combo.addValueChangeListener(
                event -> log.log("you made a selection change"));

        Button btn1 = new Button("Click me");
        btn1.addClickListener(event -> log.log("you clicked me"));

        formLayout.addComponent(combo);
        formLayout.addComponent(btn1);

        layout.addComponent(formLayout);

        Button btn = new Button("Enable/Disable combobox",
                event -> combo.setEnabled(!combo.isEnabled()));
        layout.addComponent(btn);
        btn = new Button("Enable/Disable parent",
                event -> formLayout.setEnabled(!formLayout.isEnabled()));
        layout.addComponent(btn);

    }

    @Override
    protected String getTestDescription() {
        return "Test for ensuring that disabling a parent properly disables the combobox";
    }

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