use of io.jmix.ui.app.inputdialog.InputDialog in project jmix-docs by Haulmont.
the class DialogsScreen method onInpDlgActionsBtnClick.
// end::create-input-dialog-params[]
// tag::create-input-dialog-actions[]
@Subscribe("inpDlgActionsBtn")
public void onInpDlgActionsBtnClick(Button.ClickEvent event) {
dialogs.createInputDialog(this).withCaption("Enter some values").withParameters(InputParameter.stringParameter("name").withCaption("Name")).withActions(InputDialogAction.action("confirm").withCaption("Confirm").withPrimary(true).withHandler(actionEvent -> {
InputDialog dialog = actionEvent.getInputDialog();
// <2>
String name = dialog.getValue("name");
// <3>
dialog.closeWithDefaultAction();
// process entered values...
}), InputDialogAction.action("refuse").withCaption("Refuse").withValidationRequired(false).withHandler(actionEvent -> actionEvent.getInputDialog().closeWithDefaultAction())).show();
}
use of io.jmix.ui.app.inputdialog.InputDialog in project jmix by jmix-framework.
the class InputDialogAction method actionPerform.
@Override
public void actionPerform(Component component) {
if (eventHub != null) {
InputDialog inputDialog = null;
if (component instanceof Component.BelongToFrame) {
Window window = ComponentsHelper.getWindow((Component.BelongToFrame) component);
if (window != null) {
inputDialog = (InputDialog) window.getFrameOwner();
}
}
if (!validationRequired || (inputDialog != null && inputDialog.isValid())) {
InputDialogActionPerformed event = new InputDialogActionPerformed(this, component, inputDialog);
eventHub.publish(InputDialogActionPerformed.class, event);
}
}
}
use of io.jmix.ui.app.inputdialog.InputDialog in project jmix by jmix-framework.
the class FilterSaveAsAction method openInputDialog.
protected void openInputDialog() {
if (filter.getFrame() == null) {
throw new IllegalStateException("Filter component is not attached to the Frame");
}
InputDialog inputDialog = dialogs.createInputDialog(filter.getFrame().getFrameOwner()).withCaption(messages.getMessage(FilterSaveAction.class, "saveFilterConfigurationInputDialog.caption")).withParameters(InputParameter.stringParameter("nameField").withCaption(messages.getMessage(FilterConfiguration.class, "FilterConfiguration.name")).withRequired(true), InputParameter.booleanParameter("generatedIdField").withCaption(messages.getMessage(UiDataFilterConfigurationModelFragment.class, "uiDataFilterConfigurationModelFragment.generatedIdField")).withDefaultValue(true), InputParameter.stringParameter("idField").withRequired(true).withCaption(messages.getMessage(FilterConfiguration.class, "FilterConfiguration.configurationId"))).withActions(DialogActions.OK_CANCEL).withValidator(validationContext -> {
String id = validationContext.getValue("idField");
if (Strings.isNullOrEmpty(id)) {
return ValidationErrors.of(messages.getMessage(FilterSaveAsAction.class, "saveFilterConfigurationInputDialog.idField.emptyValue"));
}
if (filter.getConfiguration(id) != null) {
return ValidationErrors.of(messages.getMessage(LogicalFilterConditionEdit.class, "logicalFilterConditionEdit.uniqueConfigurationId"));
}
return ValidationErrors.none();
}).withCloseListener(inputDialogCloseListener).show();
Form form = (Form) inputDialog.getWindow().getComponentNN("form");
initInputDialogFormFields(form);
}
Aggregations