Search in sources :

Example 21 with ComboBox

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);
}
Also used : ComboBox(com.vaadin.flow.component.combobox.ComboBox) SimpleBean(com.vaadin.flow.component.combobox.bean.SimpleBean)

Example 22 with ComboBox

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);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) ComboBox(com.vaadin.flow.component.combobox.ComboBox) SimpleBean(com.vaadin.flow.component.combobox.bean.SimpleBean)

Example 23 with ComboBox

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);
}
Also used : IntStream(java.util.stream.IntStream) ComboBoxLazyDataView(com.vaadin.flow.component.combobox.dataview.ComboBoxLazyDataView) DataView(com.vaadin.flow.data.provider.DataView) ComboBoxListDataView(com.vaadin.flow.component.combobox.dataview.ComboBoxListDataView) Div(com.vaadin.flow.component.html.Div) Hr(com.vaadin.flow.component.html.Hr) ComboBox(com.vaadin.flow.component.combobox.ComboBox) Collectors(java.util.stream.Collectors) Span(com.vaadin.flow.component.html.Span) Route(com.vaadin.flow.router.Route) ComboBox(com.vaadin.flow.component.combobox.ComboBox) Span(com.vaadin.flow.component.html.Span)

Example 24 with ComboBox

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());
}
Also used : DuplicatedNameValidationError(io.imunity.furms.api.validation.exceptions.DuplicatedNameValidationError) Label(com.vaadin.flow.component.html.Label) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) FurmsFormLayout(io.imunity.furms.ui.components.FurmsFormLayout) Route(com.vaadin.flow.router.Route) Map(java.util.Map) Key(com.vaadin.flow.component.Key) UI(com.vaadin.flow.component.UI) TextField(com.vaadin.flow.component.textfield.TextField) FormButtons(io.imunity.furms.ui.components.FormButtons) Set(java.util.Set) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) FormLayout(com.vaadin.flow.component.formlayout.FormLayout) OptionalParameter(com.vaadin.flow.router.OptionalParameter) Objects(java.util.Objects) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) EmailNotPresentException(io.imunity.furms.api.validation.exceptions.EmailNotPresentException) AlarmAlreadyExceedThresholdException(io.imunity.furms.api.validation.exceptions.AlarmAlreadyExceedThresholdException) AlarmService(io.imunity.furms.api.alarms.AlarmService) Optional(java.util.Optional) VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) EmailValidator(com.vaadin.flow.data.validator.EmailValidator) Binder(com.vaadin.flow.data.binder.Binder) Div(com.vaadin.flow.component.html.Div) ComboBox(com.vaadin.flow.component.combobox.ComboBox) Function(java.util.function.Function) HashSet(java.util.HashSet) AlarmWithUserEmails(io.imunity.furms.domain.alarms.AlarmWithUserEmails) TextFieldVariant(com.vaadin.flow.component.textfield.TextFieldVariant) MultiselectComboBox(org.vaadin.gatanaso.MultiselectComboBox) ProjectAllocationService(io.imunity.furms.api.project_allocation.ProjectAllocationService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) IntegerField(com.vaadin.flow.component.textfield.IntegerField) BeanValidationBinder(com.vaadin.flow.data.binder.BeanValidationBinder) ValueContext(com.vaadin.flow.data.binder.ValueContext) ProjectAllocation(io.imunity.furms.domain.project_allocation.ProjectAllocation) EAGER(com.vaadin.flow.data.value.ValueChangeMode.EAGER) ProjectAdminMenu(io.imunity.furms.ui.views.project.ProjectAdminMenu) FiredAlarmThresholdReduceException(io.imunity.furms.api.validation.exceptions.FiredAlarmThresholdReduceException) ButtonVariant(com.vaadin.flow.component.button.ButtonVariant) Optional.ofNullable(java.util.Optional.ofNullable) AlarmId(io.imunity.furms.domain.alarms.AlarmId) Button(com.vaadin.flow.component.button.Button) ProjectService(io.imunity.furms.api.projects.ProjectService) ValueContext(com.vaadin.flow.data.binder.ValueContext)

Example 25 with ComboBox

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;
}
Also used : CommunityAllocationViewModel(io.imunity.furms.ui.community.allocations.CommunityAllocationViewModel) ComboBox(com.vaadin.flow.component.combobox.ComboBox) ResourceCreditComboBoxModel(io.imunity.furms.ui.components.support.models.allocation.ResourceCreditComboBoxModel)

Aggregations

ComboBox (com.vaadin.flow.component.combobox.ComboBox)69 Div (com.vaadin.flow.component.html.Div)35 Span (com.vaadin.flow.component.html.Span)21 NativeButton (com.vaadin.flow.component.html.NativeButton)20 Route (com.vaadin.flow.router.Route)18 List (java.util.List)16 H2 (com.vaadin.flow.component.html.H2)14 Collectors (java.util.stream.Collectors)14 Label (com.vaadin.flow.component.html.Label)12 ComponentRenderer (com.vaadin.flow.data.renderer.ComponentRenderer)12 Stream (java.util.stream.Stream)12 Component (com.vaadin.flow.component.Component)10 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)10 ArrayList (java.util.ArrayList)10 Button (com.vaadin.flow.component.button.Button)9 Person (com.vaadin.flow.component.combobox.test.entity.Person)9 PersonService (com.vaadin.flow.component.combobox.test.service.PersonService)9 IntStream (java.util.stream.IntStream)9 ItemFilter (com.vaadin.flow.component.combobox.ComboBox.ItemFilter)8 Paragraph (com.vaadin.flow.component.html.Paragraph)8