/** * Resolve this result depending on the passed result. * * @param result dependency */ public void resolveWith(OperationResult result) { result.then(this::success) .otherwise(this::fail); }
/** * Check modifications and close all screens in all main windows. * * @param runIfOk a closure to run after all screens are closed * @param runIfCancel a closure to run if there were modifications and a user canceled the operation */ @Deprecated public void checkModificationsAndCloseAll(Runnable runIfOk, Runnable runIfCancel) { checkModificationsAndCloseAll() .then(runIfOk) .otherwise(runIfCancel); }
@Override public void actionPerform(com.haulmont.cuba.gui.components.Component component) { AppUI ui = AppUI.getCurrent(); WebScreens screens = (WebScreens) ui.getScreens(); screens.checkModificationsAndCloseAll() .then(() -> { App app = ui.getApp(); try { app.getConnection().substituteUser(user); doAfterChangeUser(); } catch (javax.persistence.NoResultException e) { Messages messages = AppBeans.get(Messages.NAME); app.getWindowManager().showNotification( messages.formatMainMessage("substitutionNotPerformed", user.getName()), Frame.NotificationType.WARNING ); doRevert(); } }) .otherwise(this::doRevert); }