Package io.jmix.flowui.impl
Class DialogsImpl.InputDialogBuilderImpl
java.lang.Object
io.jmix.flowui.impl.DialogsImpl.InputDialogBuilderImpl
- All Implemented Interfaces:
Dialogs.DialogBuilder<Dialogs.InputDialogBuilder>
,Dialogs.Draggable<Dialogs.InputDialogBuilder>
,Dialogs.HasHeader<Dialogs.InputDialogBuilder>
,Dialogs.HasPosition<Dialogs.InputDialogBuilder>
,Dialogs.HasSize<Dialogs.InputDialogBuilder>
,Dialogs.InputDialogBuilder
- Enclosing class:
- DialogsImpl
public class DialogsImpl.InputDialogBuilderImpl
extends Object
implements Dialogs.InputDialogBuilder
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.flowui.Dialogs.InputDialogBuilder
Dialogs.InputDialogBuilder.LabelsPosition
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the input dialog.getLeft()
Gets the left position of the dialog.List<com.vaadin.flow.component.formlayout.FormLayout.ResponsiveStep>
getTop()
Gets the top position of the dialog.getWidth()
boolean
open()
Opens the dialog.withActions
(InputDialogAction... actions) Sets dialog actions.withActions
(DialogActions actions) Sets predefined dialog actions.withActions
(DialogActions actions, Consumer<InputDialog.InputDialogResult> resultHandler) Sets dialog actions and result handler.withCloseListener
(com.vaadin.flow.component.ComponentEventListener<InputDialog.InputDialogCloseEvent> listener) Add close listener to the dialog.withDraggable
(boolean draggable) Sets whether dialog is enabled to be dragged by the user or not.withDraggedListener
(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.dialog.Dialog.DialogDraggedEvent> listener) Adds a listener that is called after user finishes dragging the dialog.withHeader
(String header) Sets a header text.withHeight
(String height) Sets dialog height.withLabelsPosition
(Dialogs.InputDialogBuilder.LabelsPosition labelsPosition) Sets labels position for default responsive steps.Sets the distance of the dialog from the left of its container.withParameter
(InputParameter parameter) Adds input parameter to the dialog.withParameters
(InputParameter... parameters) Sets input parameters.withResponsiveSteps
(List<com.vaadin.flow.component.formlayout.FormLayout.ResponsiveStep> responsiveSteps) Sets responsive steps.Sets the top position of the dialog.Sets additional handler for field validation.Sets dialog width.
-
Field Details
-
inputDialog
-
dialogBuild
-
-
Constructor Details
-
InputDialogBuilderImpl
-
-
Method Details
-
withHeader
Description copied from interface:Dialogs.HasHeader
Sets a header text.- Specified by:
withHeader
in interfaceDialogs.HasHeader<Dialogs.InputDialogBuilder>
- Parameters:
header
- header text- Returns:
- builder
-
getHeader
- Specified by:
getHeader
in interfaceDialogs.HasHeader<Dialogs.InputDialogBuilder>
- Returns:
- header text
-
withWidth
Description copied from interface:Dialogs.HasSize
Sets dialog width.- Specified by:
withWidth
in interfaceDialogs.HasSize<Dialogs.InputDialogBuilder>
- Parameters:
width
- width- Returns:
- builder
-
getWidth
- Specified by:
getWidth
in interfaceDialogs.HasSize<Dialogs.InputDialogBuilder>
- Returns:
- dialog width value
-
withHeight
Description copied from interface:Dialogs.HasSize
Sets dialog height.- Specified by:
withHeight
in interfaceDialogs.HasSize<Dialogs.InputDialogBuilder>
- Parameters:
height
- height- Returns:
- builder
-
getHeight
- Specified by:
getHeight
in interfaceDialogs.HasSize<Dialogs.InputDialogBuilder>
- Returns:
- dialog height value
-
getLeft
Description copied from interface:Dialogs.HasPosition
Gets the left position of the dialog.- Specified by:
getLeft
in interfaceDialogs.HasPosition<Dialogs.InputDialogBuilder>
- Returns:
- the left position of the dialog
-
withLeft
Description copied from interface:Dialogs.HasPosition
Sets the distance of the dialog from the left of its container. If a unitless number is provided, pixels are assumed.Note that the dialog left edge may not be the same as the viewport left edge (e.g. the
Lumo
theme defines some spacing to prevent the dialog from stretching all the way to the left of the viewport).- Specified by:
withLeft
in interfaceDialogs.HasPosition<Dialogs.InputDialogBuilder>
- Parameters:
left
- the left position of the dialog- Returns:
builder
-
getTop
Description copied from interface:Dialogs.HasPosition
Gets the top position of the dialog.- Specified by:
getTop
in interfaceDialogs.HasPosition<Dialogs.InputDialogBuilder>
- Returns:
- the top position of the dialog
-
withTop
Description copied from interface:Dialogs.HasPosition
Sets the top position of the dialog. If a unitless number is provided, pixels are assumed.Note that the dialog top edge may not be the same as the viewport top edge (e.g. the
Lumo
theme defines some spacing to prevent the dialog from stretching all the way to the top of the viewport).- Specified by:
withTop
in interfaceDialogs.HasPosition<Dialogs.InputDialogBuilder>
- Parameters:
top
- the top position of the dialog- Returns:
builder
-
withDraggable
Description copied from interface:Dialogs.Draggable
Sets whether dialog is enabled to be dragged by the user or not.- Specified by:
withDraggable
in interfaceDialogs.Draggable<Dialogs.InputDialogBuilder>
- Parameters:
draggable
-true
to enable dragging of the dialog,false
otherwise- Returns:
- builder
-
isDraggable
public boolean isDraggable()- Specified by:
isDraggable
in interfaceDialogs.Draggable<Dialogs.InputDialogBuilder>
- Returns:
true
if dragging is enabled,false
otherwise
-
withDraggedListener
public Dialogs.InputDialogBuilder withDraggedListener(com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.dialog.Dialog.DialogDraggedEvent> listener) Description copied from interface:Dialogs.Draggable
Adds a listener that is called after user finishes dragging the dialog. It is called only if dragging is enabled.Note: By default, the component will sync the top/left values after every dragging.
- Specified by:
withDraggedListener
in interfaceDialogs.Draggable<Dialogs.InputDialogBuilder>
- Parameters:
listener
- the listener to add- Returns:
builder
- See Also:
-
withParameter
Description copied from interface:Dialogs.InputDialogBuilder
Adds input parameter to the dialog. InputParameter describes field which will be used in the input dialog.
Example:dialogs.createInputDialog(this) .withParameter( entityParameter("userField", User.class) .withLabel("User field") .withRequired(true) ) .open();
- Specified by:
withParameter
in interfaceDialogs.InputDialogBuilder
- Parameters:
parameter
- input parameter that will be added to the dialog- Returns:
- builder
- See Also:
-
withParameters
Description copied from interface:Dialogs.InputDialogBuilder
Sets input parameters. InputParameter describes field which will be used in the input dialog.
Example:dialogs.createInputDialog(this) .withParameters( stringParameter("nameField") .withLabel("Name field label") .withDefaultValue("Default value"), intParameter("countField") .withLabel("Count field label") .withRequired(true)) .open();
- Specified by:
withParameters
in interfaceDialogs.InputDialogBuilder
- Parameters:
parameters
- input parameters- Returns:
- builder
- See Also:
-
getParameters
-
withResponsiveSteps
public Dialogs.InputDialogBuilder withResponsiveSteps(List<com.vaadin.flow.component.formlayout.FormLayout.ResponsiveStep> responsiveSteps) Description copied from interface:Dialogs.InputDialogBuilder
Sets responsive steps. Responsive steps used in describing the responsive layouting behavior of aFormLayout
.- Specified by:
withResponsiveSteps
in interfaceDialogs.InputDialogBuilder
- Parameters:
responsiveSteps
- responsive steps- Returns:
- builder
-
getResponsiveSteps
-
withLabelsPosition
public Dialogs.InputDialogBuilder withLabelsPosition(Dialogs.InputDialogBuilder.LabelsPosition labelsPosition) Description copied from interface:Dialogs.InputDialogBuilder
Sets labels position for default responsive steps.- Specified by:
withLabelsPosition
in interfaceDialogs.InputDialogBuilder
- Parameters:
labelsPosition
- position of labels- Returns:
- builder
- See Also:
-
getLabelsPosition
-
withCloseListener
public Dialogs.InputDialogBuilder withCloseListener(com.vaadin.flow.component.ComponentEventListener<InputDialog.InputDialogCloseEvent> listener) Description copied from interface:Dialogs.InputDialogBuilder
Add close listener to the dialog. See close actions forDialogActions
inInputDialog
.- Specified by:
withCloseListener
in interfaceDialogs.InputDialogBuilder
- Parameters:
listener
- close listener to add- Returns:
- builder
-
withActions
Description copied from interface:Dialogs.InputDialogBuilder
Sets dialog actions.Note, if there is no actions are set input dialog will use
Example:DialogActions.OK_CANCEL
by default.dialogs.createInputDialog(this) .withHeader("Dialog header") .withParameter(parameter("nameField").withLabel("Name")) .withActions( action("okAction") .withText("OK") .withIcon(VaadinIcon.CHECK.create()) .withHandler(event -> { InputDialogAction inputDialogAction = ((InputDialogAction) event.getSource()); InputDialog inputDialog = inputDialogAction.getInputDialog(); // do logic inputDialog.close(InputDialog.INPUT_DIALOG_OK_ACTION); }), action("cancelAction") .withText("Cancel") .withIcon(VaadinIcon.BAN.create()) .withValidationRequired(false) .withHandler(event -> { // do logic })) .open();
- Specified by:
withActions
in interfaceDialogs.InputDialogBuilder
- Parameters:
actions
- actions- Returns:
- builder
- See Also:
-
getActions
-
withActions
Description copied from interface:Dialogs.InputDialogBuilder
Sets predefined dialog actions. "OK" and "YES" actions always check fields validation before close the dialog. By default, if there is no actions are set input dialog will useDialogActions.OK_CANCEL
.- Specified by:
withActions
in interfaceDialogs.InputDialogBuilder
- Parameters:
actions
- actions- Returns:
- builder
-
withActions
public Dialogs.InputDialogBuilder withActions(DialogActions actions, Consumer<InputDialog.InputDialogResult> resultHandler) Description copied from interface:Dialogs.InputDialogBuilder
Sets dialog actions and result handler. "OK" and "YES" actions always check fields validation before close the dialog. Handler is invoked after close event and can be used instead ofDialogs.InputDialogBuilder.withCloseListener(ComponentEventListener)
. Exampledialogs.createInputDialog(this) .withHeader("Dialog header") .withParameter(parameter("nameField").withLabel("Name")) .withActions(DialogActions.OK_CANCEL, result -> { switch (result.getCloseActionType()) { case OK -> { // do logic } case CANCEL -> { // do other logic } } }) .open();
- Specified by:
withActions
in interfaceDialogs.InputDialogBuilder
- Parameters:
actions
- dialog actionsresultHandler
- result handler- Returns:
- builder
-
getDialogActions
-
getResultHandler
-
withValidator
public Dialogs.InputDialogBuilder withValidator(Function<InputDialog.ValidationContext, ValidationErrors> validator) Description copied from interface:Dialogs.InputDialogBuilder
Sets additional handler for field validation. It receives input dialog context and must returnValidationErrors
instance. Returned validation errors will be shown with another errors from fields. Exampledialogs.createInputDialog(this) .withParameters( stringParameter("phoneField").withLabel("Phone"), stringParameter("addressField").withLabel("Address")) .withValidator(context -> { String phone = context.getValue("phoneField"); String address = context.getValue("addressField"); if (Strings.isNullOrEmpty(phone) && Strings.isNullOrEmpty(address)) { return ValidationErrors.of("Phone or Address should be filled"); } return ValidationErrors.none(); }) .open();
- Specified by:
withValidator
in interfaceDialogs.InputDialogBuilder
- Parameters:
validator
- validator- Returns:
- builder
-
getValidator
-
open
Description copied from interface:Dialogs.InputDialogBuilder
Opens the dialog.- Specified by:
open
in interfaceDialogs.InputDialogBuilder
- Returns:
- opened input dialog
-
build
Description copied from interface:Dialogs.InputDialogBuilder
Builds the input dialog.- Specified by:
build
in interfaceDialogs.InputDialogBuilder
- Returns:
- input dialog
-