Search in sources :

Example 1 with Dialogs

use of io.jmix.ui.Dialogs in project jmix by jmix-framework.

the class ShowLinkAction method actionPerform.

@Override
public void actionPerform(io.jmix.ui.component.Component component) {
    if (ds == null) {
        return;
    }
    Messages messages = AppBeans.get(Messages.class);
    Dialogs dialogs = AppUI.getCurrent().getDialogs();
    dialogs.createMessageDialog().withCaption(messages.getMessage("table.showLinkAction")).withMessage(compileLink(ds)).show();
}
Also used : Messages(io.jmix.core.Messages) Dialogs(io.jmix.ui.Dialogs)

Example 2 with Dialogs

use of io.jmix.ui.Dialogs in project jmix by jmix-framework.

the class ScreenValidation method showUnsavedChangesDialog.

/**
 * Shows standard unsaved changes dialog with Discard and Cancel actions.
 *
 * @param origin screen controller
 * @param closeAction close action
 * @return result
 */
public UnsavedChangesDialogResult showUnsavedChangesDialog(FrameOwner origin, @SuppressWarnings("unused") CloseAction closeAction) {
    UnsavedChangesDialogResult result = new UnsavedChangesDialogResult();
    Dialogs dialogs = getScreenContext(origin).getDialogs();
    dialogs.createOptionDialog().withCaption(messages.getMessage("closeUnsaved.caption")).withMessage(messages.getMessage("closeUnsaved")).withActions(new DialogAction(DialogAction.Type.YES).withHandler(e -> {
        result.discard();
    }), new DialogAction(DialogAction.Type.NO, Action.Status.PRIMARY).withHandler(e -> {
        Frame frame = UiControllerUtils.getFrame(origin);
        ComponentsHelper.focusChildComponent(frame);
        result.cancel();
    })).show();
    return result;
}
Also used : Dialogs(io.jmix.ui.Dialogs) DialogAction(io.jmix.ui.action.DialogAction)

Example 3 with Dialogs

use of io.jmix.ui.Dialogs in project jmix by jmix-framework.

the class FilterRemoveAction method execute.

@Override
public void execute() {
    ScreenContext screenContext = ComponentsHelper.getScreenContext(filter);
    Dialogs dialogs = screenContext.getDialogs();
    dialogs.createOptionDialog().withCaption(messages.getMessage(FilterRemoveAction.class, "confirmationDialog.caption")).withMessage(messages.getMessage(FilterRemoveAction.class, "confirmationDialog.message")).withActions(new DialogAction(DialogAction.Type.YES).withHandler(actionPerformedEvent -> filterSupport.removeCurrentFilterConfiguration(filter)), new DialogAction(DialogAction.Type.NO)).show();
}
Also used : ScreenContext(io.jmix.ui.screen.ScreenContext) Dialogs(io.jmix.ui.Dialogs) DialogAction(io.jmix.ui.action.DialogAction)

Example 4 with Dialogs

use of io.jmix.ui.Dialogs in project jmix by jmix-framework.

the class ListPrintFormAction method actionPerform.

@Override
public void actionPerform(Component component) {
    DialogAction cancelAction = new DialogAction(DialogAction.Type.CANCEL);
    ScreenContext screenContext = ComponentsHelper.getScreenContext(target);
    Preconditions.checkState(screenContext != null, "Component is not attached to window");
    Dialogs dialogs = screenContext.getDialogs();
    Set selected = target.getSelected();
    if (CollectionUtils.isNotEmpty(selected)) {
        if (selected.size() > 1) {
            Action printSelectedAction = new AbstractAction("actions.printSelected", Status.PRIMARY) {

                @Override
                public void actionPerform(Component component) {
                    printSelected(selected);
                }
            };
            printSelectedAction.setIcon(JmixIcon.BARS.source());
            printSelectedAction.setCaption(messages.getMessage(getClass(), "actions.printSelected"));
            Action printAllAction = new AbstractAction("actions.printAll") {

                @Override
                public void actionPerform(Component component) {
                    printAll();
                }
            };
            printAllAction.setIcon(JmixIcon.TABLE.source());
            printAllAction.setCaption(messages.getMessage(getClass(), "actions.printAll"));
            dialogs.createOptionDialog().withCaption(messages.getMessage(getClass(), "notifications.confirmPrintSelectedHeader")).withMessage(messages.getMessage(getClass(), "notifications.confirmPrintSelected")).withActions(printAllAction, printSelectedAction, cancelAction).show();
        } else {
            printSelected(selected);
        }
    } else {
        if (isDataAvailable()) {
            Action yesAction = new DialogAction(DialogAction.Type.OK) {

                @Override
                public void actionPerform(Component component) {
                    printAll();
                }
            };
            cancelAction.setPrimary(true);
            dialogs.createOptionDialog().withCaption(messages.getMessage(getClass(), "notifications.confirmPrintAllheader")).withMessage(messages.getMessage(getClass(), "notifications.confirmPrintAll")).withActions(yesAction, cancelAction).show();
        } else {
            Notifications notifications = screenContext.getNotifications();
            notifications.create().withCaption(messages.getMessage(getClass(), "notifications.noSelectedEntity")).withType(Notifications.NotificationType.HUMANIZED).show();
        }
    }
}
Also used : Action(io.jmix.ui.action.Action) DialogAction(io.jmix.ui.action.DialogAction) AbstractPrintFormAction(io.jmix.reportsui.action.AbstractPrintFormAction) AbstractAction(io.jmix.ui.action.AbstractAction) StudioAction(io.jmix.ui.meta.StudioAction) ScreenContext(io.jmix.ui.screen.ScreenContext) HashSet(java.util.HashSet) Set(java.util.Set) Dialogs(io.jmix.ui.Dialogs) DialogAction(io.jmix.ui.action.DialogAction) ListComponent(io.jmix.ui.component.ListComponent) Component(io.jmix.ui.component.Component) AbstractAction(io.jmix.ui.action.AbstractAction) Notifications(io.jmix.ui.Notifications)

Example 5 with Dialogs

use of io.jmix.ui.Dialogs in project jmix by jmix-framework.

the class RemoveAction method confirmAndRemove.

protected void confirmAndRemove(Set<Entity> selected) {
    Dialogs dialogs = ComponentsHelper.getScreenContext(target.getFrame()).getDialogs();
    dialogs.createOptionDialog().withCaption(getConfirmationTitle()).withMessage(getConfirmationMessage()).withActions(new DialogAction(DialogAction.Type.OK, Status.PRIMARY).withHandler(event -> {
        try {
            remove(selected);
        } finally {
            if (target instanceof Component.Focusable) {
                ((Component.Focusable) target).focus();
            }
            Set<Entity> filtered = new HashSet<>(selected);
            filtered.retainAll(target.getDatasource().getItems());
            // noinspection unchecked
            target.setSelected(filtered);
        }
    }), new DialogAction(DialogAction.Type.CANCEL).withHandler(event -> {
        // move focus to owner
        if (target instanceof Component.Focusable) {
            ((Component.Focusable) target).focus();
        }
    })).show();
}
Also used : Entity(io.jmix.core.Entity) Dialogs(io.jmix.ui.Dialogs) DialogAction(io.jmix.ui.action.DialogAction) HashSet(java.util.HashSet)

Aggregations

Dialogs (io.jmix.ui.Dialogs)9 DialogAction (io.jmix.ui.action.DialogAction)6 AbstractAction (io.jmix.ui.action.AbstractAction)2 Action (io.jmix.ui.action.Action)2 StudioAction (io.jmix.ui.meta.StudioAction)2 ScreenContext (io.jmix.ui.screen.ScreenContext)2 HashSet (java.util.HashSet)2 Entity (io.jmix.core.Entity)1 Messages (io.jmix.core.Messages)1 AbstractPrintFormAction (io.jmix.reportsui.action.AbstractPrintFormAction)1 Notifications (io.jmix.ui.Notifications)1 BaseAction (io.jmix.ui.action.BaseAction)1 ListAction (io.jmix.ui.action.ListAction)1 Component (io.jmix.ui.component.Component)1 ListComponent (io.jmix.ui.component.ListComponent)1 Screen (io.jmix.ui.screen.Screen)1 Set (java.util.Set)1