use of com.vaadin.flow.component.combobox.ComboBox in project flow-components by vaadin.
the class ComboBoxPage method setLabelGeneratorAfterValue.
private void setLabelGeneratorAfterValue() {
ComboBox<SimpleBean> combo = new ComboBox<>();
SimpleBean foo = new SimpleBean("foo");
combo.setItems(foo);
combo.setId("label-generator-after-value");
combo.setValue(foo);
combo.setItemLabelGenerator(SimpleBean::getName);
add(combo);
}
use of com.vaadin.flow.component.combobox.ComboBox in project flow-components by vaadin.
the class RefreshDataProviderPage method createRefreshItem.
private void createRefreshItem() {
SimpleBean item1 = new SimpleBean("foo");
SimpleBean item2 = new SimpleBean("bar");
ComboBox<SimpleBean> comboBox = new ComboBox<>();
comboBox.setItemLabelGenerator(SimpleBean::getName);
comboBox.setId("refresh-item-combo-box");
comboBox.setItems(item1, item2);
NativeButton button = new NativeButton("Change both items, refresh only the second one", e -> {
item1.setName("foo updated");
item2.setName("bar updated");
comboBox.getDataProvider().refreshItem(item2);
});
button.setId("refresh-item");
add(comboBox, button);
}
use of com.vaadin.flow.component.combobox.ComboBox in project flow-components by vaadin.
the class ClientSideFilterPage method createBackEndComboBox.
private void createBackEndComboBox() {
ComboBox<String> backendComboBox = new ComboBox<>("Backend");
backendComboBox.setId(BACKEND_COMBO_BOX);
ComboBoxLazyDataView<String> lazyDataView = backendComboBox.setItems(query -> IntStream.range(0, 30).mapToObj(index -> "Item " + index).filter(item -> item.contains(query.getFilter().orElse(""))).skip(query.getOffset()).limit(query.getLimit()), query -> (int) IntStream.range(0, 30).mapToObj(index -> "Item " + index).filter(item -> item.contains(query.getFilter().orElse(""))).count());
Span itemCountSpan = new Span("0");
itemCountSpan.setId(BACKEND_COMBO_BOX_ITEM_COUNT_SPAN_ID);
this.add(itemCountSpan);
addListener(itemCountSpan, lazyDataView);
this.add(backendComboBox);
}
use of com.vaadin.flow.component.combobox.ComboBox 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.combobox.ComboBox in project furms by unity-idm.
the class DashboardResourceAllocateFormView method resourceCreditField.
private ComboBox<ResourceCreditComboBoxModel> resourceCreditField(Label availableAmountLabel) {
final ComboBox<ResourceCreditComboBoxModel> resourceCreditComboBox = new ComboBox<>();
resourceCreditComboBox.setItemLabelGenerator(resourceType -> resourceType.name);
resourceCreditComboBox.setReadOnly(true);
ResourceCreditComboBoxModel resourceCredit = binder.getBean().getResourceCredit();
resourceCreditComboBox.setItems(resourceCredit);
availableAmount = communityAllocationService.getAvailableAmountForNew(resourceCredit.id);
availableAmountLabel.setText(createAvailableLabelContent(resourceCredit.split));
binder.forField(resourceCreditComboBox).bind(CommunityAllocationViewModel::getResourceCredit, CommunityAllocationViewModel::setResourceCredit);
return resourceCreditComboBox;
}
Aggregations