/** * 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 */ @Deprecated public void checkModificationsAndCloseAll(Runnable runIfOk) { checkModificationsAndCloseAll() .then(runIfOk); }
/** * Try to perform logout. If there are unsaved changes in opened windows then logout will not be performed and * unsaved changes dialog will appear. * * @deprecated Use {@link #logout()} instead. * * @param runWhenLoggedOut runnable that will be invoked if user decides to logout */ @Deprecated public void logout(@Nullable Runnable runWhenLoggedOut) { logout().then(runWhenLoggedOut); }
protected void commit(@SuppressWarnings("unused") Action.ActionPerformedEvent event) { commitChanges() .then(() -> commitActionPerformed = true); }
/** * 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); }
protected void select(Collection<T> items) { boolean valid = true; if (selectValidator != null) { valid = selectValidator.test(new ValidationContext<>(this, items)); } if (valid) { OperationResult result = close(LOOKUP_SELECT_CLOSE_ACTION); if (selectHandler != null) { result.then(() -> selectHandler.accept(items)); } } }
/** * INTERNAL. Don't call from application code. * * @deprecated Use {@link #getFrameOwner()} and trigger {@link Screen#close(CloseAction)} instead. */ @Deprecated default void closeAndRun(String actionId, Runnable runnable) { getFrameOwner().close(new StandardCloseAction(actionId)) .then(runnable); }
@Override public void actionPerform(Component component) { if (window.getSelectHandler() == null) { // window opened not as Lookup return; } if (!validate()) return; window.getFrameOwner() .close(LookupScreen.LOOKUP_SELECT_CLOSE_ACTION) .then(this::handleSelection); }
@Override public void run() { Window currentWindow = breadCrumbs.getCurrentWindow(); if (!currentWindow.isCloseable()) { return; } if (window != currentWindow) { if (!isWindowClosePrevented(currentWindow, CloseOriginType.BREADCRUMBS)) { currentWindow.getFrameOwner() .close(WINDOW_CLOSE_ACTION) .then(this); } } } };
@Override public void run() { Window windowToClose = breadCrumbs.getCurrentWindow(); if (windowToClose != null) { if (!getConfiguredWorkArea().isNotCloseable(breadCrumbs.getCurrentWindow()) && !isWindowClosePrevented(windowToClose, CloseOriginType.CLOSE_BUTTON)) { windowToClose.getFrameOwner() .close(WINDOW_CLOSE_ACTION) .then(new TabCloseTask(breadCrumbs)); } } } }
currentWindow.getFrameOwner() .close(FrameOwner.WINDOW_CLOSE_ACTION) .then(() -> tabSheet.setSelectedTab(previousTab)); } else { currentWindow.getFrameOwner()
@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); }
.getWindow().getFrameOwner() .close(FrameOwner.WINDOW_CLOSE_ACTION) .then(() -> proceedHistoryBackward(_requestedState));