Search in sources :

Example 1 with OperationResult

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;
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) OperationResult(com.haulmont.cuba.gui.util.OperationResult)

Example 2 with OperationResult

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;
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) OperationResult(com.haulmont.cuba.gui.util.OperationResult)

Example 3 with OperationResult

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);
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) com.haulmont.cuba.gui.sys(com.haulmont.cuba.gui.sys) Datasource(com.haulmont.cuba.gui.data.Datasource) OperationResult(com.haulmont.cuba.gui.util.OperationResult) ReflectionHelper(com.haulmont.bali.util.ReflectionHelper) PermissionType(com.haulmont.cuba.security.entity.PermissionType) LoggerFactory(org.slf4j.LoggerFactory) CubaIcon(com.haulmont.cuba.gui.icons.CubaIcon) Settings(com.haulmont.cuba.gui.settings.Settings) Screen(com.haulmont.cuba.gui.screen.Screen) WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) Icons(com.haulmont.cuba.gui.icons.Icons) StringUtils(org.apache.commons.lang3.StringUtils) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) DatasourceImplementation(com.haulmont.cuba.gui.data.impl.DatasourceImplementation) IconResolver(com.haulmont.cuba.web.gui.icons.IconResolver) com.haulmont.cuba.gui(com.haulmont.cuba.gui) DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) UrlTools(com.haulmont.cuba.web.sys.navigation.UrlTools) UIPerformanceLogger.createStopWatch(com.haulmont.cuba.gui.logging.UIPerformanceLogger.createStopWatch) AppUI(com.haulmont.cuba.web.AppUI) ScreenClosedEvent(com.haulmont.cuba.gui.screen.event.ScreenClosedEvent) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) Preconditions.checkNotNullArgument(com.haulmont.bali.util.Preconditions.checkNotNullArgument) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) NotificationType(com.haulmont.cuba.gui.Notifications.NotificationType) LayoutLoader(com.haulmont.cuba.gui.xml.layout.LayoutLoader) com.haulmont.cuba.web.widgets(com.haulmont.cuba.web.widgets) Predicate(java.util.function.Predicate) GenericDataSupplier(com.haulmont.cuba.gui.data.impl.GenericDataSupplier) App(com.haulmont.cuba.web.App) SettingsImpl(com.haulmont.cuba.gui.settings.SettingsImpl) Collectors(java.util.stream.Collectors) WINDOW_CLOSE_ACTION(com.haulmont.cuba.gui.screen.FrameOwner.WINDOW_CLOSE_ACTION) WindowImplementation(com.haulmont.cuba.gui.components.sys.WindowImplementation) InvocationTargetException(java.lang.reflect.InvocationTargetException) ScreenXmlLoader(com.haulmont.cuba.gui.xml.layout.ScreenXmlLoader) MessageDialogBuilder(com.haulmont.cuba.gui.Dialogs.MessageDialogBuilder) WindowMode(com.haulmont.cuba.gui.components.DialogWindow.WindowMode) ComponentLoaderContext(com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext) ScreenDataImpl(com.haulmont.cuba.gui.model.impl.ScreenDataImpl) OptionDialogBuilder(com.haulmont.cuba.gui.Dialogs.OptionDialogBuilder) Stream(java.util.stream.Stream) WebConfig(com.haulmont.cuba.web.WebConfig) ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) ClientConfig(com.haulmont.cuba.client.ClientConfig) DataSupplier(com.haulmont.cuba.gui.data.DataSupplier) GuiDialogWindow(com.haulmont.cuba.web.gui.components.WebDialogWindow.GuiDialogWindow) java.util(java.util) CssLayout(com.vaadin.ui.CssLayout) com.haulmont.cuba.gui.screen.compatibility(com.haulmont.cuba.gui.screen.compatibility) com.haulmont.cuba.core.global(com.haulmont.cuba.core.global) HasWorkArea(com.haulmont.cuba.gui.components.Window.HasWorkArea) Inject(javax.inject.Inject) UnknownOperationResult(com.haulmont.cuba.gui.util.UnknownOperationResult) com.haulmont.cuba.gui.screen(com.haulmont.cuba.gui.screen) LegacyFragmentAdapter(com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter) DsContextLoader(com.haulmont.cuba.gui.xml.data.DsContextLoader) Nonnull(javax.annotation.Nonnull) DsContext(com.haulmont.cuba.gui.data.DsContext) Nullable(javax.annotation.Nullable) Mode(com.haulmont.cuba.web.widgets.CubaManagedTabSheet.Mode) ScreenOpenedEvent(com.haulmont.cuba.gui.screen.event.ScreenOpenedEvent) UserActionsLogger(com.haulmont.cuba.gui.logging.UserActionsLogger) AppWorkArea(com.haulmont.cuba.gui.components.mainwindow.AppWorkArea) NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) ComponentLoader(com.haulmont.cuba.gui.xml.layout.ComponentLoader) ConstructorUtils.invokeConstructor(org.apache.commons.lang3.reflect.ConstructorUtils.invokeConstructor) StopWatch(org.perf4j.StopWatch) Disposable(com.haulmont.cuba.gui.components.Component.Disposable) Layout(com.vaadin.ui.Layout) Mode(com.haulmont.cuba.gui.components.mainwindow.AppWorkArea.Mode) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindow(com.haulmont.cuba.web.gui.WebWindow) Element(org.dom4j.Element) SelectHandlerAdapter(com.haulmont.cuba.gui.components.compatibility.SelectHandlerAdapter) ScreenLifeCycle(com.haulmont.cuba.gui.logging.ScreenLifeCycle) ScreenProfilerImpl(com.haulmont.cuba.web.ScreenProfilerImpl) Entity(com.haulmont.cuba.core.entity.Entity) WebTabWindow(com.haulmont.cuba.web.gui.components.WebTabWindow) UiControllerUtils(com.haulmont.cuba.gui.screen.UiControllerUtils) Screen(com.haulmont.cuba.gui.screen.Screen) OperationResult(com.haulmont.cuba.gui.util.OperationResult) UnknownOperationResult(com.haulmont.cuba.gui.util.UnknownOperationResult)

Aggregations

Screen (com.haulmont.cuba.gui.screen.Screen)3 OperationResult (com.haulmont.cuba.gui.util.OperationResult)2 Preconditions.checkNotNullArgument (com.haulmont.bali.util.Preconditions.checkNotNullArgument)1 ReflectionHelper (com.haulmont.bali.util.ReflectionHelper)1 ClientConfig (com.haulmont.cuba.client.ClientConfig)1 Entity (com.haulmont.cuba.core.entity.Entity)1 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)1 com.haulmont.cuba.gui (com.haulmont.cuba.gui)1 MessageDialogBuilder (com.haulmont.cuba.gui.Dialogs.MessageDialogBuilder)1 OptionDialogBuilder (com.haulmont.cuba.gui.Dialogs.OptionDialogBuilder)1 NotificationType (com.haulmont.cuba.gui.Notifications.NotificationType)1 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)1 Disposable (com.haulmont.cuba.gui.components.Component.Disposable)1 WindowMode (com.haulmont.cuba.gui.components.DialogWindow.WindowMode)1 HasWorkArea (com.haulmont.cuba.gui.components.Window.HasWorkArea)1 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)1 LegacyFragmentAdapter (com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter)1 SelectHandlerAdapter (com.haulmont.cuba.gui.components.compatibility.SelectHandlerAdapter)1 AppWorkArea (com.haulmont.cuba.gui.components.mainwindow.AppWorkArea)1 Mode (com.haulmont.cuba.gui.components.mainwindow.AppWorkArea.Mode)1