aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupDisablingAndReadOnly.java
blob: 3f8fdc4abcc91ab103ae989d115e80724f07618e (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
package com.vaadin.tests.components.radiobuttongroup;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.RadioButtonGroup;

public class RadioButtonGroupDisablingAndReadOnly extends AbstractTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        RadioButtonGroup<String> group = new RadioButtonGroup<>();
        group.setEnabled(false);
        group.setReadOnly(true);
        group.setItems("a", "b", "c");
        addComponent(group);

        addComponent(new Button("Toggle enabled", e -> {
            group.setEnabled(!group.isEnabled());
        }));

        addComponent(new Button("Toggle readOnly", e -> {
            group.setReadOnly(!group.isReadOnly());
        }));

        addComponent(new Button("Clear selection", e -> {
            group.setValue(null);
        }));
    }

    @Override
    protected String getTestDescription() {
        return "Options should only be selectable when the group is "
                + "neither disabled nor readOnly";
    }
}