Package io.jmix.ui.sys
Class DialogsImpl.InputDialogBuilderImpl
java.lang.Object
io.jmix.ui.sys.DialogsImpl.InputDialogBuilderImpl
- All Implemented Interfaces:
Dialogs.DialogBuilder<Dialogs.InputDialogBuilder>
,Dialogs.HasCaption<Dialogs.InputDialogBuilder>
,Dialogs.HasSize<Dialogs.InputDialogBuilder>
,Dialogs.InputDialogBuilder
- Enclosing class:
- DialogsImpl
public class DialogsImpl.InputDialogBuilderImpl
extends Object
implements Dialogs.InputDialogBuilder
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the input dialog.float
float
getWidth()
show()
Shows the dialog.withActions
(DialogActions actions) Sets predefined dialog actions.withActions
(DialogActions actions, Consumer<InputDialog.InputDialogResult> resultHandler) Sets dialog actions and result handler.withActions
(InputDialogAction... actions) Sets dialog actions.withCaption
(String caption) Sets caption text.Add close listener to the dialog.withHeight
(String height) Sets dialog height.withParameter
(InputParameter parameter) Adds input parameter to the dialog.withParameters
(InputParameter... parameters) Sets input parameters.Sets additional handler for field validation.Sets dialog width.
-
Field Details
-
inputDialog
-
-
Constructor Details
-
InputDialogBuilderImpl
-
-
Method Details
-
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) .withCaption("User field") .withRequired(true) ) .show();
- 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") .withCaption("Name field caption") .withDefaultValue("default value"), intParameter("countField") .withCaption("Count field caption") .withRequired(true)) .show();
- Specified by:
withParameters
in interfaceDialogs.InputDialogBuilder
- Parameters:
parameters
- input parameters- Returns:
- builder
- See Also:
-
getParameters
-
withCloseListener
public Dialogs.InputDialogBuilder withCloseListener(Consumer<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.InputDialogAction
provides access to input dialog inInputDialogAction.InputDialogActionPerformed
where it is possible to get values form the fields and implement logic to close dialog.Note, if there is no actions are set input dialog will use
Example:DialogActions.OK_CANCEL
by default.dialogs.createInputDialog(this) .withCaption("Dialog caption") .withParameter(parameter("nameField").withCaption("Name")) .withActions( action("okAction") .withCaption("OK") .withIcon(JmixIcon.DIALOG_OK) .withHandler(event -> { InputDialog inputDialog = event.getInputDialog(); String name = inputDialog.getValue("nameField"); // do logic inputDialog.close(InputDialog.INPUT_DIALOG_OK_ACTION); }), action("cancelAction") .withCaption("Cancel") .withIcon(JmixIcon.DIALOG_CANCEL) .withValidationRequired(false) .withHandler(event -> { InputDialog inputDialog = event.getInputDialog(); inputDialog.close(InputDialog.INPUT_DIALOG_CANCEL_ACTION); })) .show();
- 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(Consumer)
. Exampledialogs.createInputDialog(this) .withCaption("Dialog caption") .withParameter(parameter("nameField").withCaption("Name")) .withActions(DialogActions.OK_CANCEL, result -> { switch (result.getCloseActionType()) { case OK: String name = result.getValue("nameField"); // do logic break; case CANCEL: // do logic break; } }) .show();
- 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").withCaption("Phone"), stringParameter("addressField").withCaption("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(); }) .show();
- Specified by:
withValidator
in interfaceDialogs.InputDialogBuilder
- Parameters:
validator
- validator- Returns:
- builder
-
getValidator
-
withCaption
Description copied from interface:Dialogs.HasCaption
Sets caption text.- Specified by:
withCaption
in interfaceDialogs.HasCaption<Dialogs.InputDialogBuilder>
- Parameters:
caption
- caption text- Returns:
- builder
-
withWidth
Description copied from interface:Dialogs.HasSize
Sets dialog width.- Specified by:
withWidth
in interfaceDialogs.HasSize<Dialogs.InputDialogBuilder>
- Parameters:
width
- width- Returns:
- builder
-
getWidth
public float getWidth()- Specified by:
getWidth
in interfaceDialogs.HasSize<Dialogs.InputDialogBuilder>
- Returns:
- dialog width value
-
getWidthSizeUnit
- Specified by:
getWidthSizeUnit
in interfaceDialogs.HasSize<Dialogs.InputDialogBuilder>
- Returns:
- dialog width unit
-
withHeight
Description copied from interface:Dialogs.HasSize
Sets dialog height.- Specified by:
withHeight
in interfaceDialogs.HasSize<Dialogs.InputDialogBuilder>
- Parameters:
height
- height- Returns:
- builder
-
getHeight
public float getHeight()- Specified by:
getHeight
in interfaceDialogs.HasSize<Dialogs.InputDialogBuilder>
- Returns:
- dialog height value
-
getHeightSizeUnit
- Specified by:
getHeightSizeUnit
in interfaceDialogs.HasSize<Dialogs.InputDialogBuilder>
- Returns:
- dialog height unit
-
getCaption
- Specified by:
getCaption
in interfaceDialogs.HasCaption<Dialogs.InputDialogBuilder>
- Returns:
- caption text
-
show
Description copied from interface:Dialogs.InputDialogBuilder
Shows the dialog.- Specified by:
show
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
-