protected void showExecutionError(Exception ex) { Screen ownerFrame = wrappedTask.getOwnerScreen(); if (ownerFrame != null) { Dialogs dialogs = getScreenContext().getDialogs(); Messages messages = AppBeans.get(Messages.class); dialogs.createExceptionDialog() .withThrowable(ex) .withCaption(messages.getMessage(LocalizedTaskWrapper.class, "backgroundWorkProgress.executionError")) .withMessage(ex.getLocalizedMessage()) .show(); } } }
return UiControllerUtils.getScreenContext(frameOwner).getDialogs();
protected void confirmAndRemove(Set<Entity> selected) { Dialogs dialogs = ComponentsHelper.getScreenContext(target.getFrame()).getDialogs(); dialogs.createOptionDialog() .withCaption(getConfirmationTitle()) .withMessage(getConfirmationMessage()) .withActions( new 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(Type.CANCEL).withHandler(event -> { // move focus to owner if (target instanceof Component.Focusable) { ((Component.Focusable) target).focus(); } })) .show(); }
Dialogs dialogs = getScreenContext(this).getDialogs();
@SuppressWarnings("CodeBlock2Expr") protected <E extends Entity> 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.getMainMessage("dialogs.Confirmation"); String message = builder.getConfirmationTitle() != null ? builder.getConfirmationTitle() : messages.getMainMessage("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(); }
exportAllAction.setCaption(messages.getMainMessage(exportAllAction.getId())); Dialogs dialogs = getScreenContext(listComponent).getDialogs();
/** * 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.getMainMessage("closeUnsaved.caption")) .withMessage(messages.getMainMessage("closeUnsaved")) .withType(Dialogs.MessageType.WARNING) .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; }
ActionOwner owner = getOwner(); if (owner instanceof Component.BelongToFrame) { Dialogs dialogs = getScreenContext((Component.BelongToFrame) owner).getDialogs();
}; Dialogs dialogs = ComponentsHelper.getScreenContext(target).getDialogs();
new ScreenContextImpl(windowInfo, parentContext.getOptions(), hostScreenContext.getScreens(), hostScreenContext.getDialogs(), hostScreenContext.getNotifications(), hostScreenContext.getFragments(),
new ScreenContextImpl(windowInfo, parentContext.getOptions(), hostScreenContext.getScreens(), hostScreenContext.getDialogs(), hostScreenContext.getNotifications(), hostScreenContext.getFragments(),
SaveChangesDialogResult result = new SaveChangesDialogResult(); Dialogs dialogs = getScreenContext(origin).getDialogs(); dialogs.createOptionDialog() .withCaption(messages.getMainMessage("closeUnsaved.caption"))