use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.
the class TestView method createOptions.
private void createOptions() {
Div options = new Div();
options.add(new NativeButton(SELECT_FIRST_ITEM, event -> select.setValue(items.get(0))));
options.add(new NativeButton(SELECT_THIRD_ITEM, event -> select.setValue(items.get(2))));
options.add(new NativeButton(SELECT_LAST_ITEM, event -> select.setValue(items.get(items.size() - 1))));
options.add(new Div());
options.add(new NativeButton("Reset 0 items", event -> setItems(0)));
options.add(new NativeButton("Reset 1 items", event -> setItems(1)));
options.add(new NativeButton("Reset 2 items", event -> setItems(2)));
options.add(new NativeButton("Reset 5 items", event -> setItems(5)));
options.add(new NativeButton("Reset 10 items", event -> setItems(10)));
options.add(new NativeButton("Reset 20 items", event -> setItems(20)));
options.add(new NativeButton("Reset 50 items", event -> setItems(50)));
options.add(new Div());
options.add(new NativeButton("Refresh item 0", event -> refreshItem(0)));
options.add(new NativeButton("Refresh item 2", event -> refreshItem(2)));
options.add(new NativeButton("Refresh item 10", event -> refreshItem(10)));
options.add(new NativeButton("Refresh All", event -> refreshAll()));
options.add(new Div());
options.add(new Checkbox("ItemLabelGenerator", event -> setItemLabelGenerator(event.getValue())));
options.add(new Checkbox("ItemEnabledProvider", event -> setItemEnabledProvider(event.getValue())));
options.add(new Div());
Checkbox emptySelectionEnabled = new Checkbox("emptySelectionEnabled", event -> setEmptySelectionAllowed(event.getValue()));
emptySelectionEnabled.setValue(select.isEmptySelectionAllowed());
emptySelectionEnabled.setId("emptySelectionEnabled");
options.add(emptySelectionEnabled);
Input emptySelectionCaption = new Input();
emptySelectionCaption.setId("emptySelectionCaption");
emptySelectionCaption.setValue(select.getEmptySelectionCaption());
emptySelectionCaption.addValueChangeListener(event -> setEmptySelectionCaption(event.getValue()));
options.add(new Span("EmptySelectionCaption:"), emptySelectionCaption);
options.add(new Div());
options.add(new NativeButton("focus()", event -> select.focus()));
Checkbox requiredIndicatorVisible = new Checkbox("RequiredIndicator", event -> select.setRequiredIndicatorVisible(event.getValue()));
requiredIndicatorVisible.setValue(select.isRequiredIndicatorVisible());
requiredIndicatorVisible.setId("requiredIndicatorVisible");
options.add(requiredIndicatorVisible);
Input errorMessage = new Input();
errorMessage.setId("errorMessage");
errorMessage.addValueChangeListener(event -> select.setErrorMessage(event.getValue()));
options.add(new Span("errorMessage"), errorMessage);
Input placeholder = new Input();
placeholder.setId("placeholder");
placeholder.addValueChangeListener(event -> select.setPlaceholder(event.getValue()));
options.add(new Span("placeholder"), placeholder);
options.add(new Div());
options.add(new NativeButton("Set renderer", event -> {
if (select.getItemRenderer() == null) {
select.setRenderer(componentRenderer);
} else {
select.setRenderer(null);
}
}), new NativeButton("Add HR 0", event -> addHrInBeginning()), new NativeButton("Remove HR 0", event -> removeHrInBeginning()), new NativeButton("Add HR 2", event -> addHrAfterIndexTwo()), new NativeButton("Remove HR 2", event -> removeHrAfterIndexTwo()), new NativeButton("Add HR LAST", event -> addHrLast()), new NativeButton("Remove HR LAST", event -> removeHrLast()));
options.add(new Div());
enabled = new Checkbox("Enabled");
enabled.setValue(select.isEnabled());
enabled.addValueChangeListener(event -> select.setEnabled(event.getValue()));
readOnly = new Checkbox("ReadOnly");
readOnly.setValue(select.isReadOnly());
readOnly.addValueChangeListener(event -> select.setReadOnly(event.getValue()));
visible = new Checkbox("Visible");
visible.setValue(select.isVisible());
visible.addValueChangeListener(event -> select.setVisible(event.getValue()));
helperText = new Checkbox("HelperText");
helperText.setValue(false);
helperText.addValueChangeListener(event -> {
if (event.getValue())
select.setHelperText("Helper text");
else
select.setHelperText(null);
});
options.add(enabled, readOnly, visible, helperText);
add(options);
}
use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.
the class DisabledGridPage method createCheckBox.
private Checkbox createCheckBox(String item) {
Checkbox checkbox = new Checkbox();
checkbox.addValueChangeListener(event -> reportError());
return checkbox;
}
use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.
the class AbstractLayout method createToggleThemeCheckbox.
public static Checkbox createToggleThemeCheckbox(String themeName, Consumer<Boolean> toggleAction, boolean defaultValue) {
Checkbox toggleButton = new Checkbox(themeName);
toggleButton.setValue(defaultValue);
toggleButton.addValueChangeListener(event -> toggleAction.accept(event.getValue()));
toggleButton.setId(String.format("toggle-%s", themeName));
return toggleButton;
}
use of com.vaadin.flow.component.checkbox.Checkbox in project furms by unity-idm.
the class AlarmFormView method prepareValidator.
private void prepareValidator(TextField nameField, ComboBox<String> allocationComboBox, IntegerField thresholdField, Checkbox checkbox, MultiselectComboBox<String> multiselectComboBox) {
binder.forField(nameField).withValidator(value -> Objects.nonNull(value) && !value.isBlank(), getTranslation("view.project-admin.alarms.form.error.name")).bind(model -> model.name, (model, name) -> model.name = name);
binder.forField(allocationComboBox).withValidator(Objects::nonNull, getTranslation("view.project-admin.alarms.form.error.allocation")).bind(model -> model.allocationId, (model, id) -> model.allocationId = id);
binder.forField(thresholdField).withValidator(threshold -> threshold >= 1.0 && threshold <= 100.0, getTranslation("view.project-admin.alarms.form.error.threshold")).bind(model -> model.threshold, (model, threshold) -> model.threshold = threshold);
binder.forField(checkbox).bind(model -> model.allUsers, (model, value) -> model.allUsers = value);
binder.forField(multiselectComboBox).withValidator(emails -> emails.stream().noneMatch(email -> emailValidator.apply(email, new ValueContext()).isError()), getTranslation("view.project-admin.alarms.form.error.emails")).bind(model -> model.users, (model, policyFile) -> model.users = multiselectComboBox.getSelectedItems());
}
use of com.vaadin.flow.component.checkbox.Checkbox in project furms by unity-idm.
the class PendingRequestsView method createPendingMessagesGrid.
private Grid<PendingMessageGridModel> createPendingMessagesGrid(Map<CorrelationId, Checkbox> checkboxes, Component mainContextMenu) {
Grid<PendingMessageGridModel> grid;
grid = new DenseGrid<>(PendingMessageGridModel.class);
grid.addComponentColumn(pendingMessageGridModel -> {
Checkbox checkbox = new Checkbox();
checkboxes.put(pendingMessageGridModel.id, checkbox);
HorizontalLayout horizontalLayout = new HorizontalLayout(checkbox, grid.isDetailsVisible(pendingMessageGridModel) ? ANGLE_DOWN.create() : ANGLE_RIGHT.create(), new Paragraph(getTranslationOrDefault("view.site-admin.pending-requests.page.grid.operation-type." + pendingMessageGridModel.operationType, pendingMessageGridModel.operationType)));
horizontalLayout.setAlignItems(CENTER);
return horizontalLayout;
}).setHeader(new HorizontalLayout(mainContextMenu, new Label(getTranslation("view.site-admin.pending-requests.page.grid.1")))).setFlexGrow(2);
grid.addColumn(model -> model.status).setHeader(getTranslation("view.site-admin.pending-requests.page.grid.2")).setSortable(true);
grid.addColumn(model -> model.sentAt.format(dateTimeFormatter)).setHeader(getTranslation("view.site-admin.pending-requests.page.grid.3")).setSortable(true);
grid.addColumn(model -> Optional.ofNullable(model.ackAt).map(ackTime -> ackTime.format(dateTimeFormatter)).orElse("")).setHeader(getTranslation("view.site-admin.pending-requests.page.grid.4")).setSortable(true);
grid.addColumn(model -> model.retryAmount).setHeader(getTranslation("view.site-admin.pending-requests.page.grid.5")).setSortable(true);
grid.addComponentColumn(this::createContextMenu).setHeader(getTranslation("view.site-admin.pending-requests.page.grid.6")).setTextAlign(ColumnTextAlign.END);
grid.setItemDetailsRenderer(new ComponentRenderer<>(data -> {
Paragraph json = new Paragraph(data.json);
json.getStyle().set("font-family", "monospace");
json.getStyle().set("word-wrap", "break-word");
json.getElement().getStyle().set("white-space", "pre-wrap");
return json;
}));
return grid;
}
Aggregations