public class WebDialogs.InputDialogBuilderImpl extends java.lang.Object implements Dialogs.InputDialogBuilder
Modifier and Type | Field and Description |
---|---|
protected InputDialog |
inputDialog |
Constructor and Description |
---|
InputDialogBuilderImpl(FrameOwner owner) |
protected InputDialog inputDialog
public InputDialogBuilderImpl(FrameOwner owner)
public Dialogs.InputDialogBuilder withParameter(InputParameter parameter)
Dialogs.InputDialogBuilder
Example:
dialogs.createInputDialog(this)
.withParameter(
entityParameter("userField", User.class)
.withCaption("User field")
.withRequired(true)
)
.show();
withParameter
in interface Dialogs.InputDialogBuilder
parameter
- input parameter that will be added to the dialogInputParameter.entityParameter(String, Class)
public Dialogs.InputDialogBuilder withParameters(InputParameter... parameters)
Dialogs.InputDialogBuilder
Example:
dialogs.createInputDialog(this)
.withParameters(
stringParameter("nameField")
.withCaption("Name field caption")
.withDefaultValue("default value"),
intParameter("countField")
.withCaption("Count field caption")
.withRequired(true))
.show();
withParameters
in interface Dialogs.InputDialogBuilder
parameters
- input parametersInputParameter.stringParameter(String)
,
InputParameter.intParameter(String)
public java.util.Collection<InputParameter> getParameters()
public Dialogs.InputDialogBuilder withCloseListener(java.util.function.Consumer<InputDialog.InputDialogCloseEvent> listener)
Dialogs.InputDialogBuilder
DialogActions
in InputDialog
.withCloseListener
in interface Dialogs.InputDialogBuilder
listener
- close listener to addpublic java.util.function.Consumer<InputDialog.InputDialogCloseEvent> getCloseListener()
public Dialogs.InputDialogBuilder withActions(InputDialogAction... actions)
Dialogs.InputDialogBuilder
InputDialogAction
provides access to input dialog in InputDialogAction.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 DialogActions.OK_CANCEL
by default.
dialogs.createInputDialog(this)
.withCaption("Dialog caption")
.withParameter(parameter("nameField").withCaption("Name"))
.withActions(
action("okAction")
.withCaption("OK")
.withIcon(CubaIcon.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(CubaIcon.DIALOG_CANCEL)
.withValidationRequired(false)
.withHandler(event -> {
InputDialog inputDialog = event.getInputDialog();
inputDialog.close(InputDialog.INPUT_DIALOG_CANCEL_ACTION);
}))
.show();
withActions
in interface Dialogs.InputDialogBuilder
actions
- actionsInputDialogAction.action(String)
public java.util.Collection<Action> getActions()
public Dialogs.InputDialogBuilder withActions(DialogActions actions)
Dialogs.InputDialogBuilder
DialogActions.OK_CANCEL
.withActions
in interface Dialogs.InputDialogBuilder
actions
- actionspublic Dialogs.InputDialogBuilder withActions(DialogActions actions, java.util.function.Consumer<InputDialog.InputDialogResult> resultHandler)
Dialogs.InputDialogBuilder
Dialogs.InputDialogBuilder.withCloseListener(Consumer)
.
Example
dialogs.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();
withActions
in interface Dialogs.InputDialogBuilder
actions
- dialog actionsresultHandler
- result handlerpublic DialogActions getDialogActions()
@Nullable public java.util.function.Consumer<InputDialog.InputDialogResult> getResultHandler()
public Dialogs.InputDialogBuilder withValidator(java.util.function.Function<InputDialog.ValidationContext,ValidationErrors> validator)
Dialogs.InputDialogBuilder
ValidationErrors
instance. Returned validation errors will be shown with another errors from fields.
Example
dialogs.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();
withValidator
in interface Dialogs.InputDialogBuilder
validator
- validatorpublic java.util.function.Function<InputDialog.ValidationContext,ValidationErrors> getValidator()
public Dialogs.InputDialogBuilder withCaption(java.lang.String caption)
Dialogs.HasCaption
withCaption
in interface Dialogs.HasCaption<Dialogs.InputDialogBuilder>
caption
- caption textpublic Dialogs.InputDialogBuilder withWidth(java.lang.String width)
Dialogs.HasSize
withWidth
in interface Dialogs.HasSize<Dialogs.InputDialogBuilder>
width
- widthpublic float getWidth()
getWidth
in interface Dialogs.HasSize<Dialogs.InputDialogBuilder>
public SizeUnit getWidthSizeUnit()
getWidthSizeUnit
in interface Dialogs.HasSize<Dialogs.InputDialogBuilder>
public Dialogs.InputDialogBuilder withHeight(java.lang.String height)
Dialogs.HasSize
withHeight
in interface Dialogs.HasSize<Dialogs.InputDialogBuilder>
height
- heightpublic float getHeight()
getHeight
in interface Dialogs.HasSize<Dialogs.InputDialogBuilder>
public SizeUnit getHeightSizeUnit()
getHeightSizeUnit
in interface Dialogs.HasSize<Dialogs.InputDialogBuilder>
@Nullable public java.lang.String getCaption()
getCaption
in interface Dialogs.HasCaption<Dialogs.InputDialogBuilder>
public InputDialog show()
show
in interface Dialogs.InputDialogBuilder
public InputDialog build()
Dialogs.InputDialogBuilder
build
in interface Dialogs.InputDialogBuilder