Search in sources :

Example 1 with BigDecimalField

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

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

the class HasLabelTest method bigDecimalField.

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

Example 3 with BigDecimalField

use of com.vaadin.flow.component.textfield.BigDecimalField in project furms by unity-idm.

the class DashboardResourceAllocateFormView method amountField.

private BigDecimalField amountField() {
    final BigDecimalField amountField = new BigDecimalField();
    amountField.setValueChangeMode(EAGER);
    amountField.setReadOnly(!binder.getBean().getResourceCredit().split);
    createUnitLabel(amountField, binder.getBean().getResourceType().unit);
    binder.forField(amountField).withValidator(Objects::nonNull, getTranslation("view.fenix-admin.resource-credits-allocation.form.error.validation.field.amount")).withValidator(this::isAmountCorrect, getTranslation("view.fenix-admin.resource-credits-allocation.form.error.validation.field.amount.range")).bind(CommunityAllocationViewModel::getAmount, CommunityAllocationViewModel::setAmount);
    amountField.setValue(availableAmount);
    return amountField;
}
Also used : CommunityAllocationViewModel(io.imunity.furms.ui.community.allocations.CommunityAllocationViewModel) Objects(java.util.Objects) BigDecimalField(com.vaadin.flow.component.textfield.BigDecimalField)

Example 4 with BigDecimalField

use of com.vaadin.flow.component.textfield.BigDecimalField in project furms by unity-idm.

the class ProjectAllocationDashboardFormView method amountField.

private BigDecimalField amountField() {
    final BigDecimalField amountField = new BigDecimalField();
    amountField.setValueChangeMode(EAGER);
    Optional<AllocationCommunityComboBoxModel> communityAlloc = Optional.ofNullable(binder.getBean().getAllocationCommunity());
    amountField.setReadOnly(!communityAlloc.map(alloc -> alloc.split).orElse(true));
    createUnitLabel(amountField, binder.getBean().getResourceType().unit);
    binder.forField(amountField).withValidator(Objects::nonNull, getTranslation("view.community-admin.project-allocation.form.error.validation.field.amount")).withValidator(this::isAmountCorrect, getTranslation("view.community-admin.project-allocation.form.error.validation.field.amount.range")).bind(ProjectAllocationViewModel::getAmount, ProjectAllocationViewModel::setAmount);
    amountField.setValue(availableAmount);
    return amountField;
}
Also used : ProjectHasMoreThenOneResourceTypeAllocationInGivenTimeException(io.imunity.furms.api.validation.exceptions.ProjectHasMoreThenOneResourceTypeAllocationInGivenTimeException) DefaultNameField(io.imunity.furms.ui.components.DefaultNameField) DashboardView(io.imunity.furms.ui.views.community.DashboardView) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) ValueProvider(com.vaadin.flow.function.ValueProvider) ComponentUtil(com.vaadin.flow.component.ComponentUtil) Binder(com.vaadin.flow.data.binder.Binder) Label(com.vaadin.flow.component.html.Label) PageTitle(io.imunity.furms.ui.components.PageTitle) ComboBox(com.vaadin.flow.component.combobox.ComboBox) FurmsFormLayout(io.imunity.furms.ui.components.FurmsFormLayout) Route(com.vaadin.flow.router.Route) BigDecimal(java.math.BigDecimal) ResourceMeasureUnit(io.imunity.furms.domain.resource_types.ResourceMeasureUnit) LUMO_TERTIARY(com.vaadin.flow.component.button.ButtonVariant.LUMO_TERTIARY) ProjectAllocationService(io.imunity.furms.api.project_allocation.ProjectAllocationService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) BeanValidationBinder(com.vaadin.flow.data.binder.BeanValidationBinder) Setter(com.vaadin.flow.data.binder.Setter) UI(com.vaadin.flow.component.UI) ProjectAllocation(io.imunity.furms.domain.project_allocation.ProjectAllocation) CommunityAdminMenu(io.imunity.furms.ui.views.community.CommunityAdminMenu) EAGER(com.vaadin.flow.data.value.ValueChangeMode.EAGER) Collectors.toSet(java.util.stream.Collectors.toSet) FormButtons(io.imunity.furms.ui.components.FormButtons) AllocationCommunityComboBoxModel(io.imunity.furms.ui.components.support.models.allocation.AllocationCommunityComboBoxModel) BigDecimalField(com.vaadin.flow.component.textfield.BigDecimalField) Set(java.util.Set) ZERO(java.math.BigDecimal.ZERO) FormLayout(com.vaadin.flow.component.formlayout.FormLayout) Objects(java.util.Objects) Button(com.vaadin.flow.component.button.Button) ProjectService(io.imunity.furms.api.projects.ProjectService) Optional(java.util.Optional) ESCAPE(com.vaadin.flow.component.Key.ESCAPE) ResourceTypeComboBoxModel(io.imunity.furms.ui.components.support.models.allocation.ResourceTypeComboBoxModel) ResourceAllocationsGridItem(io.imunity.furms.ui.components.resource_allocations.ResourceAllocationsGridItem) LUMO_PRIMARY(com.vaadin.flow.component.button.ButtonVariant.LUMO_PRIMARY) AllocationCommunityComboBoxModel(io.imunity.furms.ui.components.support.models.allocation.AllocationCommunityComboBoxModel) Objects(java.util.Objects) BigDecimalField(com.vaadin.flow.component.textfield.BigDecimalField)

Example 5 with BigDecimalField

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

the class BigDecimalFieldTest method init.

@Before
public void init() {
    field = new BigDecimalField();
    field.setLocale(Locale.US);
}
Also used : BigDecimalField(com.vaadin.flow.component.textfield.BigDecimalField) Before(org.junit.Before)

Aggregations

BigDecimalField (com.vaadin.flow.component.textfield.BigDecimalField)5 Objects (java.util.Objects)2 ComponentUtil (com.vaadin.flow.component.ComponentUtil)1 HasLabel (com.vaadin.flow.component.HasLabel)1 ESCAPE (com.vaadin.flow.component.Key.ESCAPE)1 UI (com.vaadin.flow.component.UI)1 Button (com.vaadin.flow.component.button.Button)1 LUMO_PRIMARY (com.vaadin.flow.component.button.ButtonVariant.LUMO_PRIMARY)1 LUMO_TERTIARY (com.vaadin.flow.component.button.ButtonVariant.LUMO_TERTIARY)1 ComboBox (com.vaadin.flow.component.combobox.ComboBox)1 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)1 Div (com.vaadin.flow.component.html.Div)1 Label (com.vaadin.flow.component.html.Label)1 EmailField (com.vaadin.flow.component.textfield.EmailField)1 IntegerField (com.vaadin.flow.component.textfield.IntegerField)1 NumberField (com.vaadin.flow.component.textfield.NumberField)1 PasswordField (com.vaadin.flow.component.textfield.PasswordField)1 TextArea (com.vaadin.flow.component.textfield.TextArea)1 TextField (com.vaadin.flow.component.textfield.TextField)1 BeanValidationBinder (com.vaadin.flow.data.binder.BeanValidationBinder)1