use of io.jmix.ui.util.OperationResult in project jmix by jmix-framework.
the class UrlChangeHandler method closeWindowStack.
protected boolean closeWindowStack(Screens.WindowStack windowStack) {
boolean closed = true;
for (Screen screen : windowStack.getBreadcrumbs()) {
if (isNotCloseable(screen.getWindow()) || isWindowClosePrevented(screen.getWindow())) {
closed = false;
windowStack.select();
break;
}
OperationResult closeResult = screen.close(FrameOwner.WINDOW_CLOSE_ACTION);
if (closeResult.getStatus() != OperationResult.Status.SUCCESS) {
closed = false;
windowStack.select();
break;
}
}
return closed;
}
use of io.jmix.ui.util.OperationResult in project jmix by jmix-framework.
the class ScreensImpl method showFromNavigation.
@Override
public OperationResult showFromNavigation(Screen screen) {
OpenMode openMode = screen.getWindow().getContext().getOpenMode();
if (openMode == OpenMode.NEW_TAB || openMode == OpenMode.NEW_WINDOW) {
AppWorkAreaImpl workArea = getConfiguredWorkArea();
if (workArea.getMode() == Mode.SINGLE) {
Collection<Screen> currentBreadcrumbs = workArea.getCurrentBreadcrumbs();
if (!currentBreadcrumbs.isEmpty()) {
Iterator<Screen> iterator = currentBreadcrumbs.iterator();
OperationResult result = OperationResult.success();
// close all
while (result.getStatus() == OperationResult.Status.SUCCESS && iterator.hasNext()) {
Screen previousScreen = iterator.next();
result = previousScreen.close(NAVIGATION_CLOSE_ACTION);
}
if (result.getStatus() != OperationResult.Status.SUCCESS) {
// if unsaved changes dialog is shown, we can continue later
return result.compose(() -> showFromNavigation(screen));
}
}
} else {
if (isMaxTabCountExceeded(screen)) {
showTooManyOpenTabsMessage();
return OperationResult.fail();
}
if (!UiControllerUtils.isMultipleOpen(screen)) {
Screen sameScreen = getTabbedScreensStacks(workArea).filter(// never close non-top active screens
windowStack -> windowStack.getBreadcrumbs().size() == 1).map(windowStack -> windowStack.getBreadcrumbs().iterator().next()).filter(tabScreen -> isAlreadyOpened(screen, tabScreen)).findFirst().orElse(null);
if (sameScreen != null) {
OperationResult result = sameScreen.close(NAVIGATION_CLOSE_ACTION);
if (result.getStatus() != OperationResult.Status.SUCCESS) {
// if unsaved changes dialog is shown, we can continue later
return result.compose(() -> showFromNavigation(screen));
}
}
}
}
}
return show(screen);
}
Aggregations