Search in sources :

Example 11 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.

the class CheckboxDemoPage method addCheckboxLazyHtmlLabel.

private void addCheckboxLazyHtmlLabel() {
    Checkbox checkbox = new Checkbox();
    checkbox.setId("lazy-html-label-checkbox");
    NativeButton button = new NativeButton("Set label", event -> {
        checkbox.setLabelAsHtml("Accept the <a href='https://vaadin.com/privacy-policy'>privacy policy</a>");
    });
    button.setId("set-html-label");
    addCard("Checkbox with the lazy label that contains HTML markup", checkbox, button);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) Checkbox(com.vaadin.flow.component.checkbox.Checkbox)

Example 12 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.

the class CheckboxPage method createInitialValueTest.

// https://github.com/vaadin/vaadin-checkbox-flow/issues/22
private Component createInitialValueTest(boolean checked, boolean indeterminate) {
    int id = checked ? 1 : 0;
    id += indeterminate ? 2 : 0;
    Checkbox checkbox2 = new Checkbox("initial value cb");
    checkbox2.setValue(checked);
    checkbox2.setIndeterminate(indeterminate);
    checkbox2.setId("cb-" + id);
    Label valueLabel = new Label("Value: " + checkbox2.getValue());
    valueLabel.setId("value-label-" + id);
    Label indeterminateLabel = new Label("Indeterminate: " + checkbox2.isIndeterminate());
    indeterminateLabel.setId("indeterminate-label-" + id);
    AtomicInteger checkedCounter = new AtomicInteger();
    checkbox2.addValueChangeListener(event -> {
        valueLabel.setText("Value: " + checkedCounter.incrementAndGet() + " " + event.getValue());
    });
    AtomicInteger indeterminateCounter = new AtomicInteger();
    checkbox2.getElement().addPropertyChangeListener("indeterminate", event -> indeterminateLabel.setText("Indeterminate: " + indeterminateCounter.incrementAndGet() + " " + event.getValue()));
    return new Div(checkbox2, valueLabel, indeterminateLabel);
}
Also used : Div(com.vaadin.flow.component.html.Div) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) Label(com.vaadin.flow.component.html.Label)

Example 13 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.

the class CheckboxUnitTest method initialValue.

@Test
public void initialValue() {
    Checkbox checkbox = new Checkbox();
    Assert.assertFalse(checkbox.getValue());
    checkbox = new Checkbox(true);
    Assert.assertTrue(checkbox.getValue());
    checkbox = new Checkbox(false);
    Assert.assertFalse(checkbox.getValue());
}
Also used : Checkbox(com.vaadin.flow.component.checkbox.Checkbox) Test(org.junit.Test)

Example 14 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.

the class CheckboxUnitTest method setEnable.

@Test
public void setEnable() {
    Checkbox checkbox = new Checkbox("foo", true);
    checkbox.setEnabled(true);
    Assert.assertTrue(checkbox.isEnabled());
    checkbox.setEnabled(false);
    Assert.assertFalse(checkbox.isEnabled());
}
Also used : Checkbox(com.vaadin.flow.component.checkbox.Checkbox) Test(org.junit.Test)

Example 15 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.

the class HasLabelTest method checkbox.

@Test
public void checkbox() {
    Checkbox c = new Checkbox();
    Assert.assertTrue(c instanceof HasLabel);
}
Also used : HasLabel(com.vaadin.flow.component.HasLabel) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) Test(org.junit.Test)

Aggregations

Checkbox (com.vaadin.flow.component.checkbox.Checkbox)68 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)16 Div (com.vaadin.flow.component.html.Div)14 TextField (com.vaadin.flow.component.textfield.TextField)14 Route (com.vaadin.flow.router.Route)14 Button (com.vaadin.flow.component.button.Button)12 Grid (com.vaadin.flow.component.grid.Grid)12 Label (com.vaadin.flow.component.html.Label)12 Collectors (java.util.stream.Collectors)10 Component (com.vaadin.flow.component.Component)8 NativeButton (com.vaadin.flow.component.html.NativeButton)8 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)8 Optional (java.util.Optional)8 Binder (com.vaadin.flow.data.binder.Binder)7 EmailValidator (com.vaadin.flow.data.validator.EmailValidator)7 Set (java.util.Set)7 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)6 PageTitle (io.imunity.furms.ui.components.PageTitle)6 NotificationUtils.showErrorNotification (io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification)6 DateTimeFormatter (java.time.format.DateTimeFormatter)6