use of com.haulmont.cuba.gui.util.OperationResult in project cuba by cuba-platform.
the class WebAppWorkArea method closeWindowStack.
protected boolean closeWindowStack(WindowStack windowStack) {
boolean closed = true;
Collection<Screen> tabScreens = windowStack.getBreadcrumbs();
for (Screen screen : tabScreens) {
if (isNotCloseable(screen.getWindow())) {
continue;
}
if (isWindowClosePrevented(screen.getWindow(), CloseOriginType.CLOSE_BUTTON)) {
closed = false;
// focus tab
windowStack.select();
break;
}
OperationResult closeResult = screen.close(FrameOwner.WINDOW_CLOSE_ACTION);
if (closeResult.getStatus() != OperationResult.Status.SUCCESS) {
closed = false;
// focus tab
windowStack.select();
break;
}
}
return closed;
}
use of com.haulmont.cuba.gui.util.OperationResult in project cuba by cuba-platform.
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 com.haulmont.cuba.gui.util.OperationResult in project cuba by cuba-platform.
the class WebScreens method showFromNavigation.
@Override
public OperationResult showFromNavigation(Screen screen) {
LaunchMode launchMode = screen.getWindow().getContext().getLaunchMode();
if (launchMode == OpenMode.NEW_TAB || launchMode == OpenMode.NEW_WINDOW) {
WebAppWorkArea 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