Search in sources :

Example 1 with IntegerField

use of com.vaadin.flow.component.textfield.IntegerField in project flow-components by vaadin.

the class ValueChangeModePage method initView.

private void initView() {
    message = new Div();
    message.setId("message");
    add(message);
    Stream.of(new TextField(), new TextArea(), new PasswordField(), new NumberField(), new EmailField(), new IntegerField(), new BigDecimalField()).forEach(this::setupTestComponent);
}
Also used : Div(com.vaadin.flow.component.html.Div) TextArea(com.vaadin.flow.component.textfield.TextArea) EmailField(com.vaadin.flow.component.textfield.EmailField) TextField(com.vaadin.flow.component.textfield.TextField) IntegerField(com.vaadin.flow.component.textfield.IntegerField) PasswordField(com.vaadin.flow.component.textfield.PasswordField) NumberField(com.vaadin.flow.component.textfield.NumberField) BigDecimalField(com.vaadin.flow.component.textfield.BigDecimalField)

Example 2 with IntegerField

use of com.vaadin.flow.component.textfield.IntegerField in project flow-components by vaadin.

the class HasLabelTest method integerField.

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

Example 3 with IntegerField

use of com.vaadin.flow.component.textfield.IntegerField in project flow-components by vaadin.

the class ComboBoxView method filteringAndSortingWithDataView.

private void filteringAndSortingWithDataView() {
    // PersonService can be found:
    // https://github.com/vaadin/vaadin-combo-box-flow/tree/master/vaadin-combo-box-flow-demo/src/main/java/com/vaadin/flow/component/combobox/demo/service/PersonService.java
    ComboBox<Person> comboBox = new ComboBox<>("Persons");
    PersonService personService = new PersonService();
    // We fetch the items to the memory and bind the obtained collection
    // to the combo box
    Collection<Person> persons = personService.fetchAll();
    ComboBoxListDataView<Person> dataView = comboBox.setItems(persons);
    /*
         * Providing a predicate item filter allows filtering by any field of
         * the business entity and apply a combo box's text filter independently
         */
    IntegerField personAgeFilter = new IntegerField(event -> dataView.setFilter(person -> event.getValue() == null || person.getAge() > event.getValue()));
    /*
         * Providing a value provider or comparator allows sorting combo box's
         * items by custom field, or combination of fields
         */
    Button sortPersons = new Button("Sort Persons by Name", event -> dataView.setSortOrder(Person::toString, SortDirection.ASCENDING));
    personAgeFilter.setLabel("Filter Persons with age more than:");
    personAgeFilter.setWidth(WIDTH_STRING);
    addCard("Filtering", "Filtering and Sorting with Data View", comboBox, personAgeFilter, sortPersons);
}
Also used : ItemFilter(com.vaadin.flow.component.combobox.ComboBox.ItemFilter) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Person(com.vaadin.flow.component.combobox.test.entity.Person) Image(com.vaadin.flow.component.html.Image) SortDirection(com.vaadin.flow.data.provider.SortDirection) Component(com.vaadin.flow.component.Component) ProjectData(com.vaadin.flow.component.combobox.test.data.ProjectData) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) ElementData(com.vaadin.flow.component.combobox.test.data.ElementData) Div(com.vaadin.flow.component.html.Div) ComboBox(com.vaadin.flow.component.combobox.ComboBox) Song(com.vaadin.flow.component.combobox.test.entity.Song) ArrayList(java.util.ArrayList) Route(com.vaadin.flow.router.Route) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) FlexLayout(com.vaadin.flow.component.orderedlayout.FlexLayout) TemplateRenderer(com.vaadin.flow.data.renderer.TemplateRenderer) IntegerField(com.vaadin.flow.component.textfield.IntegerField) ElementConstants(com.vaadin.flow.dom.ElementConstants) Department(com.vaadin.flow.component.combobox.test.entity.Department) Paragraph(com.vaadin.flow.component.html.Paragraph) Notification(com.vaadin.flow.component.notification.Notification) Ticket(com.vaadin.flow.component.combobox.test.entity.Ticket) Project(com.vaadin.flow.component.combobox.test.entity.Project) Anchor(com.vaadin.flow.component.html.Anchor) Query(com.vaadin.flow.data.provider.Query) ComboBoxLazyDataView(com.vaadin.flow.component.combobox.dataview.ComboBoxLazyDataView) Collection(java.util.Collection) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) PersonService(com.vaadin.flow.component.combobox.test.service.PersonService) H2(com.vaadin.flow.component.html.H2) Element(com.vaadin.flow.component.combobox.test.entity.Element) DepartmentData(com.vaadin.flow.component.combobox.test.data.DepartmentData) List(java.util.List) Button(com.vaadin.flow.component.button.Button) Stream(java.util.stream.Stream) ComboBoxListDataView(com.vaadin.flow.component.combobox.dataview.ComboBoxListDataView) Span(com.vaadin.flow.component.html.Span) Button(com.vaadin.flow.component.button.Button) ComboBox(com.vaadin.flow.component.combobox.ComboBox) PersonService(com.vaadin.flow.component.combobox.test.service.PersonService) IntegerField(com.vaadin.flow.component.textfield.IntegerField) Person(com.vaadin.flow.component.combobox.test.entity.Person)

Example 4 with IntegerField

use of com.vaadin.flow.component.textfield.IntegerField in project flow-components by vaadin.

the class AbstractItemCountGridPage method initDataCommunicatorOptions.

private void initDataCommunicatorOptions() {
    IntegerField pageSizeInput = new IntegerField("Page Size", event -> {
        grid.setPageSize(event.getValue());
    });
    pageSizeInput.setValue(grid.getPageSize());
    pageSizeInput.setWidthFull();
    menuBar.add("DataCommunicator Configuration");
    menuBar.add(pageSizeInput);
}
Also used : IntegerField(com.vaadin.flow.component.textfield.IntegerField)

Example 5 with IntegerField

use of com.vaadin.flow.component.textfield.IntegerField 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)

Aggregations

IntegerField (com.vaadin.flow.component.textfield.IntegerField)12 Div (com.vaadin.flow.component.html.Div)7 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)6 ComboBox (com.vaadin.flow.component.combobox.ComboBox)5 FlexLayout (com.vaadin.flow.component.orderedlayout.FlexLayout)5 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)5 Button (com.vaadin.flow.component.button.Button)4 Hr (com.vaadin.flow.component.html.Hr)4 TextField (com.vaadin.flow.component.textfield.TextField)4 AbstractBackEndDataProvider (com.vaadin.flow.data.provider.AbstractBackEndDataProvider)4 Query (com.vaadin.flow.data.provider.Query)4 Range (com.vaadin.flow.internal.Range)4 BeforeEnterObserver (com.vaadin.flow.router.BeforeEnterObserver)4 RouterLink (com.vaadin.flow.router.RouterLink)4 Logger (java.util.logging.Logger)4 IntStream (java.util.stream.IntStream)4 Stream (java.util.stream.Stream)4 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)2 Grid (com.vaadin.flow.component.grid.Grid)2 NativeButton (com.vaadin.flow.component.html.NativeButton)2