Search in sources :

Example 6 with ScreenContext

use of io.jmix.ui.screen.ScreenContext in project jmix by jmix-framework.

the class RemoveOperation method performActionWithConfirmation.

@SuppressWarnings("CodeBlock2Expr")
protected <E> void performActionWithConfirmation(RemoveBuilder<E> builder, List<E> selectedItems) {
    ScreenContext screenContext = getScreenContext(builder.getOrigin());
    Dialogs dialogs = screenContext.getDialogs();
    String title = builder.getConfirmationTitle() != null ? builder.getConfirmationTitle() : messages.getMessage("dialogs.Confirmation");
    String message = builder.getConfirmationMessage() != null ? builder.getConfirmationMessage() : messages.getMessage("dialogs.Confirmation.Remove");
    dialogs.createOptionDialog().withCaption(title).withMessage(message).withActions(new DialogAction(DialogAction.Type.YES).withHandler(e -> {
        performAction(builder, selectedItems);
    }), new DialogAction(DialogAction.Type.NO).withHandler(e -> {
        focusListComponent(builder);
        if (builder.getActionCancelledHandler() != null) {
            ActionCancelledEvent<E> event = new ActionCancelledEvent<>(builder.getOrigin(), selectedItems);
            builder.getActionCancelledHandler().accept(event);
        }
    })).show();
}
Also used : ScreenContext(io.jmix.ui.screen.ScreenContext) UiControllerUtils.getScreenContext(io.jmix.ui.screen.UiControllerUtils.getScreenContext) DialogAction(io.jmix.ui.action.DialogAction)

Example 7 with ScreenContext

use of io.jmix.ui.screen.ScreenContext 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 8 with ScreenContext

use of io.jmix.ui.screen.ScreenContext in project jmix by jmix-framework.

the class PivotExcelExporter method initNotifications.

protected void initNotifications(PivotTable pivotTable) {
    ScreenContext screenContext = ComponentsHelper.getScreenContext(pivotTable);
    notifications = screenContext.getNotifications();
}
Also used : ScreenContext(io.jmix.ui.screen.ScreenContext)

Example 9 with ScreenContext

use of io.jmix.ui.screen.ScreenContext in project jmix by jmix-framework.

the class MainTabSheetActionHandler method analyzeLayout.

protected void analyzeLayout(Object target) {
    Screen screen = findScreen((Layout) target);
    if (screen == null) {
        return;
    }
    LayoutAnalyzer analyzer = new LayoutAnalyzer();
    List<LayoutTip> layoutTips = analyzer.analyze(screen);
    ScreenContext screenContext = UiControllerUtils.getScreenContext(screen);
    if (layoutTips.isEmpty()) {
        Notifications notifications = screenContext.getNotifications();
        notifications.create(NotificationType.HUMANIZED).withCaption("No layout problems found").show();
    } else {
        Screens screens = screenContext.getScreens();
        LayoutAnalyzerScreen analyzerScreen = screens.create(LayoutAnalyzerScreen.class, OpenMode.DIALOG);
        analyzerScreen.setLayoutTips(layoutTips);
        analyzerScreen.show();
    }
}
Also used : ScreenContext(io.jmix.ui.screen.ScreenContext) LayoutAnalyzerScreen(io.jmix.ui.app.core.dev.LayoutAnalyzerScreen) LayoutTip(io.jmix.ui.app.core.dev.LayoutTip) Screen(io.jmix.ui.screen.Screen) LayoutAnalyzerScreen(io.jmix.ui.app.core.dev.LayoutAnalyzerScreen) LayoutAnalyzer(io.jmix.ui.app.core.dev.LayoutAnalyzer) Notifications(io.jmix.ui.Notifications) Screens(io.jmix.ui.Screens)

Aggregations

ScreenContext (io.jmix.ui.screen.ScreenContext)9 Screen (io.jmix.ui.screen.Screen)4 Notifications (io.jmix.ui.Notifications)3 DialogAction (io.jmix.ui.action.DialogAction)3 MetaClass (io.jmix.core.metamodel.model.MetaClass)2 Dialogs (io.jmix.ui.Dialogs)2 UiControllerUtils.getScreenContext (io.jmix.ui.screen.UiControllerUtils.getScreenContext)2 Entity (io.jmix.core.Entity)1 Messages (io.jmix.core.Messages)1 Metadata (io.jmix.core.Metadata)1 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 AbstractPrintFormAction (io.jmix.reportsui.action.AbstractPrintFormAction)1 SearchContext (io.jmix.search.searching.SearchContext)1 SearchResult (io.jmix.search.searching.SearchResult)1 SearchResultsScreen (io.jmix.searchui.screen.result.SearchResultsScreen)1 ScreenBuilders (io.jmix.ui.ScreenBuilders)1 Screens (io.jmix.ui.Screens)1 AbstractAction (io.jmix.ui.action.AbstractAction)1 Action (io.jmix.ui.action.Action)1