@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; }
/** * Tries to validate and commit data. If data committed successfully then closes the screen with * {@link #WINDOW_COMMIT_AND_CLOSE} action. May show validation errors or open an additional dialog before closing * the screen. * * @return result of close request */ public OperationResult closeWithCommit() { if (validateAll()) { boolean committed = commitInternal(true); if (committed) { return close(WINDOW_COMMIT_AND_CLOSE_ACTION); } } return OperationResult.fail(); }
.show(); return OperationResult.fail();
/** * Validates screen and commits data context. * * @return operation result */ protected OperationResult commitChanges() { ValidationErrors validationErrors = validateScreen(); if (!validationErrors.isEmpty()) { ScreenValidation screenValidation = getBeanLocator().get(ScreenValidation.class); screenValidation.showValidationErrors(this, validationErrors); return OperationResult.fail(); } getScreenData().getDataContext().commit(); return OperationResult.success(); }
/** * Requests closing of the screen caused by the given action. * * @param action close action which is propagated to {@link BeforeCloseEvent} and {@link AfterCloseEvent} * @return result of operation */ public OperationResult close(CloseAction action) { BeforeCloseEvent beforeCloseEvent = new BeforeCloseEvent(this, action); fireEvent(BeforeCloseEvent.class, beforeCloseEvent); if (beforeCloseEvent.isClosePrevented()) { if (beforeCloseEvent.getCloseResult() != null) { return beforeCloseEvent.getCloseResult(); } return OperationResult.fail(); } // save settings right before removing if (isSaveSettingsOnClose(action)) { saveSettings(); } if (isSaveScreenHistoryOnClose(action)) { ScreenHistorySupport screenHistorySupport = beanLocator.get(ScreenHistorySupport.NAME); screenHistorySupport.saveScreenHistory(this); } screenContext.getScreens().remove(this); AfterCloseEvent afterCloseEvent = new AfterCloseEvent(this, action); fireEvent(AfterCloseEvent.class, afterCloseEvent); return OperationResult.success(); }
return OperationResult.fail(); } else { forceLogout();