Search in sources :

Example 1 with InputDialog

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();
}
Also used : InputDialog(io.jmix.ui.app.inputdialog.InputDialog) Subscribe(io.jmix.ui.screen.Subscribe)

Example 2 with InputDialog

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);
        }
    }
}
Also used : Window(io.jmix.ui.component.Window) InputDialog(io.jmix.ui.app.inputdialog.InputDialog) Component(io.jmix.ui.component.Component)

Example 3 with InputDialog

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);
}
Also used : InputDialog(io.jmix.ui.app.inputdialog.InputDialog) Form(io.jmix.ui.component.Form) FilterConfiguration(io.jmix.uidata.entity.FilterConfiguration) UiDataFilterConfigurationModelFragment(io.jmix.uidata.app.filter.configuration.UiDataFilterConfigurationModelFragment) LogicalFilterConditionEdit(io.jmix.ui.app.filter.condition.LogicalFilterConditionEdit)

Aggregations

InputDialog (io.jmix.ui.app.inputdialog.InputDialog)3 LogicalFilterConditionEdit (io.jmix.ui.app.filter.condition.LogicalFilterConditionEdit)1 Component (io.jmix.ui.component.Component)1 Form (io.jmix.ui.component.Form)1 Window (io.jmix.ui.component.Window)1 Subscribe (io.jmix.ui.screen.Subscribe)1 UiDataFilterConfigurationModelFragment (io.jmix.uidata.app.filter.configuration.UiDataFilterConfigurationModelFragment)1 FilterConfiguration (io.jmix.uidata.entity.FilterConfiguration)1