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();
}
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();
}
}
}
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();
}
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();
}
}
Aggregations