@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; }
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); } }
.onDiscard(() -> result.resolveWith(closeWithDiscard())) .onCancel(result::fail); } else { screenValidation.showUnsavedChangesDialog(this, closeAction) .onDiscard(() -> result.resolveWith(closeWithDiscard())) .onCancel(result::fail);