@Override public OperationResult compose(Supplier<OperationResult> nextStep) { if (status == Status.SUCCESS) { return nextStep.get(); } if (status == Status.FAIL) { return OperationResult.fail(); } UnknownOperationResult operationResult = new UnknownOperationResult(); then(() -> { OperationResult resultNested = nextStep.get(); operationResult.resolveWith(resultNested); }); otherwise(operationResult::fail); return operationResult; }
UnknownOperationResult result = new UnknownOperationResult(); ui.getPage().open(url, "_self"); return new UnknownOperationResult();
UnknownOperationResult result = new UnknownOperationResult();
protected void preventUnsavedChanges(BeforeCloseEvent event) { CloseAction action = event.getCloseAction(); if (action instanceof ChangeTrackerCloseAction && ((ChangeTrackerCloseAction) action).isCheckForUnsavedChanges() && hasUnsavedChanges()) { Configuration configuration = getBeanLocator().get(Configuration.NAME); ClientConfig clientConfig = configuration.getConfig(ClientConfig.class); ScreenValidation screenValidation = getBeanLocator().get(ScreenValidation.NAME); UnknownOperationResult result = new UnknownOperationResult(); if (clientConfig.getUseSaveConfirmation()) { screenValidation.showSaveConfirmationDialog(this, action) .onCommit(() -> result.resolveWith(closeWithCommit())) .onDiscard(() -> result.resolveWith(closeWithDiscard())) .onCancel(result::fail); } else { screenValidation.showUnsavedChangesDialog(this, action) .onDiscard(() -> result.resolveWith(closeWithDiscard())) .onCancel(result::fail); } event.preventWindowClose(result); } }
/** * Check modifications and close all screens in all main windows excluding root screens. * * @return operation result */ public OperationResult checkModificationsAndCloseAll() { if (hasUnsavedChanges()) { UnknownOperationResult result = new UnknownOperationResult(); ui.getDialogs().createOptionDialog() .withCaption(messages.getMainMessage("closeUnsaved.caption")) .withMessage(messages.getMainMessage("discardChangesOnClose")) .withActions( new BaseAction("closeApplication") .withCaption(messages.getMainMessage("closeApplication")) .withIcon(icons.get(CubaIcon.DIALOG_OK)) .withHandler(event -> { closeWindowsInternal(); result.success(); }), new DialogAction(DialogAction.Type.CANCEL, Action.Status.PRIMARY) .withHandler(event -> result.fail()) ) .show(); return result; } else { closeWindowsInternal(); return OperationResult.success(); } }