Search in sources :

Example 6 with Dialogs

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

the class ShowPivotAction method execute.

private void execute() {
    if (target == null) {
        throw new IllegalStateException("ShowPivotAction target is not set");
    }
    if (needShowAll()) {
        showPivotTable(ShowPivotMode.ALL_ROWS);
    } else {
        Action[] actions = new Action[] { new BaseAction("actions.showPivotAction.SELECTED_ROWS").withCaption(messages.getMessage("actions.showPivotAction.SELECTED_ROWS")).withPrimary(true).withHandler(event -> showPivotTable(ShowPivotMode.SELECTED_ROWS)), new BaseAction("actions.showPivotAction.ALL_ROWS").withCaption(messages.getMessage("actions.showPivotAction.ALL_ROWS")).withHandler(event -> showPivotTable(ShowPivotMode.ALL_ROWS)), new DialogAction(DialogAction.Type.CANCEL) };
        Dialogs dialogs = ComponentsHelper.getScreenContext(target).getDialogs();
        dialogs.createOptionDialog().withCaption(messages.getMessage("actions.showPivotAction.dialogTitle")).withMessage(messages.getMessage("actions.showPivotAction.dialogMessage")).withActions(actions).show();
    }
}
Also used : StudioAction(io.jmix.ui.meta.StudioAction) Dialogs(io.jmix.ui.Dialogs)

Example 7 with Dialogs

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

the class ExportAction method execute.

protected void execute() {
    if (tableExporter == null) {
        throw new IllegalStateException("Table exporter is not defined");
    }
    if (needExportAll()) {
        doExport(ExportMode.ALL);
    } else {
        AbstractAction exportSelectedAction = new AbstractAction("actions.export.SELECTED_ROWS", Status.PRIMARY) {

            @Override
            public void actionPerform(Component component) {
                doExport(ExportMode.SELECTED);
            }
        };
        exportSelectedAction.setCaption(getMessage(exportSelectedAction.getId()));
        AbstractAction exportAllAction = new AbstractAction("actions.export.ALL_ROWS") {

            @Override
            public void actionPerform(Component component) {
                doExport(ExportMode.ALL);
            }
        };
        exportAllAction.setCaption(getMessage(exportAllAction.getId()));
        Action[] actions = new Action[] { exportSelectedAction, exportAllAction, new DialogAction(DialogAction.Type.CANCEL) };
        Dialogs dialogs = ComponentsHelper.getScreenContext(target).getDialogs();
        dialogs.createOptionDialog().withCaption(getMessage("actions.exportSelectedTitle")).withMessage(getMessage("actions.exportSelectedCaption")).withActions(actions).show();
    }
}
Also used : ListAction(io.jmix.ui.action.ListAction) AbstractAction(io.jmix.ui.action.AbstractAction) Action(io.jmix.ui.action.Action) DialogAction(io.jmix.ui.action.DialogAction) Dialogs(io.jmix.ui.Dialogs) DialogAction(io.jmix.ui.action.DialogAction) AbstractAction(io.jmix.ui.action.AbstractAction)

Example 8 with Dialogs

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

the class LocalizedTaskWrapper method showExecutionError.

protected void showExecutionError(Exception ex) {
    Screen ownerFrame = wrappedTask.getOwnerScreen();
    if (ownerFrame != null) {
        Dialogs dialogs = getScreenContext().getDialogs();
        dialogs.createExceptionDialog().withThrowable(ex).withCaption(messages.getMessage(LocalizedTaskWrapper.class, "backgroundWorkProgress.executionError")).withMessage(ex.getLocalizedMessage()).show();
    }
}
Also used : Dialogs(io.jmix.ui.Dialogs) Screen(io.jmix.ui.screen.Screen)

Example 9 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