Search in sources :

Example 16 with WebWindow

use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.

the class WebWindowManager method closeWindow.

protected void closeWindow(Window window, WindowOpenInfo openInfo) {
    if (!disableSavingScreenHistory) {
        screenHistorySupport.saveScreenHistory(window, openInfo.getOpenMode());
    }
    WebWindow webWindow = (WebWindow) window;
    webWindow.stopTimers();
    switch(openInfo.getOpenMode()) {
        case DIALOG:
            {
                final CubaWindow cubaDialogWindow = (CubaWindow) openInfo.getData();
                cubaDialogWindow.forceClose();
                fireListeners(window, tabs.size() != 0);
                break;
            }
        case NEW_WINDOW:
        case NEW_TAB:
            {
                final Layout layout = (Layout) openInfo.getData();
                layout.removeComponent(WebComponentsHelper.getComposition(window));
                WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));
                if (workArea.getMode() == Mode.TABBED) {
                    TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
                    tabSheet.silentCloseTabAndSelectPrevious(layout);
                    tabSheet.removeComponent(layout);
                } else {
                    VerticalLayout singleLayout = workArea.getSingleWindowContainer();
                    singleLayout.removeComponent(layout);
                }
                WindowBreadCrumbs windowBreadCrumbs = tabs.get(layout);
                if (windowBreadCrumbs != null) {
                    windowBreadCrumbs.clearListeners();
                    windowBreadCrumbs.removeWindow();
                }
                tabs.remove(layout);
                stacks.remove(windowBreadCrumbs);
                fireListeners(window, !tabs.isEmpty());
                if (tabs.isEmpty() && app.getConnection().isConnected()) {
                    workArea.switchTo(AppWorkArea.State.INITIAL_LAYOUT);
                }
                break;
            }
        case THIS_TAB:
            {
                final Layout layout = (Layout) openInfo.getData();
                final WindowBreadCrumbs breadCrumbs = tabs.get(layout);
                if (breadCrumbs == null) {
                    throw new IllegalStateException("Unable to close screen: breadCrumbs not found");
                }
                breadCrumbs.removeWindow();
                Window currentWindow = breadCrumbs.getCurrentWindow();
                if (!getStack(breadCrumbs).empty()) {
                    Pair<Window, Integer> entry = getStack(breadCrumbs).pop();
                    putToWindowMap(entry.getFirst(), entry.getSecond());
                }
                Component component = WebComponentsHelper.getComposition(currentWindow);
                component.setSizeFull();
                WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));
                layout.removeComponent(WebComponentsHelper.getComposition(window));
                if (app.getConnection().isConnected()) {
                    layout.addComponent(component);
                    if (workArea.getMode() == Mode.TABBED) {
                        TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
                        String tabId = tabSheet.getTab(layout);
                        String formattedCaption = formatTabCaption(currentWindow.getCaption(), currentWindow.getDescription());
                        tabSheet.setTabCaption(tabId, formattedCaption);
                        String formattedDescription = formatTabDescription(currentWindow.getCaption(), currentWindow.getDescription());
                        if (!Objects.equals(formattedCaption, formattedDescription)) {
                            tabSheet.setTabDescription(tabId, formattedDescription);
                        } else {
                            tabSheet.setTabDescription(tabId, null);
                        }
                        tabSheet.setTabIcon(tabId, iconResolver.getIconResource(currentWindow.getIcon()));
                        ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(currentWindow.getContentSwitchMode().name());
                        tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
                    }
                }
                fireListeners(window, !tabs.isEmpty());
                if (tabs.isEmpty() && app.getConnection().isConnected()) {
                    workArea.switchTo(AppWorkArea.State.INITIAL_LAYOUT);
                }
                break;
            }
        default:
            {
                throw new UnsupportedOperationException();
            }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) WebWindow(com.haulmont.cuba.web.gui.WebWindow) WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) CssLayout(com.vaadin.ui.CssLayout) WindowBreadCrumbs(com.haulmont.cuba.web.sys.WindowBreadCrumbs) WebAbstractComponent(com.haulmont.cuba.web.gui.components.WebAbstractComponent) Component(com.vaadin.ui.Component) Pair(com.haulmont.bali.datastruct.Pair)

Example 17 with WebWindow

use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.

the class WebUrlRouting method updateState.

protected void updateState(Screen screen, Map<String, String> urlParams, boolean pushState) {
    NavigationState currentState = getState();
    NavigationState newState = buildNavState(screen, urlParams);
    // do not push copy-pasted requested state to avoid double state pushing into browser history
    if (!pushState || externalNavigation(currentState, newState) || isNotFoundScreen(screen)) {
        urlTools.replaceState(newState.asRoute(), ui);
        lastHistoryOperation = CubaUIConstants.HISTORY_REPLACE_OP;
    } else {
        urlTools.pushState(newState.asRoute(), ui);
        lastHistoryOperation = CubaUIConstants.HISTORY_PUSH_OP;
    }
    ((WebWindow) screen.getWindow()).setResolvedState(newState);
    if (pushState) {
        ui.getHistory().forward(newState);
    } else {
        ui.getHistory().replace(newState);
    }
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 18 with WebWindow

use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.

the class WebScreens method changeUrl.

protected void changeUrl(Screen screen) {
    WebWindow webWindow = (WebWindow) screen.getWindow();
    Map<String, String> params = webWindow.getResolvedState() != null ? webWindow.getResolvedState().getParams() : Collections.emptyMap();
    ui.getUrlRouting().pushState(screen, params);
}
Also used : WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 19 with WebWindow

use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.

the class WebAppWorkArea method moveFocus.

protected void moveFocus(TabSheetBehaviour tabSheet, String tabId) {
    TabWindowContainer windowContainer = (TabWindowContainer) tabSheet.getTabComponent(tabId);
    Window window = windowContainer.getBreadCrumbs().getCurrentWindow();
    if (window != null) {
        boolean focused = false;
        String focusComponentId = window.getFocusComponent();
        if (focusComponentId != null) {
            com.haulmont.cuba.gui.components.Component focusComponent = window.getComponent(focusComponentId);
            if (focusComponent instanceof com.haulmont.cuba.gui.components.Component.Focusable && focusComponent.isEnabledRecursive() && focusComponent.isVisibleRecursive()) {
                ((com.haulmont.cuba.gui.components.Component.Focusable) focusComponent).focus();
                focused = true;
            }
        }
        if (!focused && window instanceof Window.Wrapper) {
            Window.Wrapper wrapper = (Window.Wrapper) window;
            focused = ((WebWindow) wrapper.getWrappedWindow()).findAndFocusChildComponent();
        }
        if (!focused) {
            tabSheet.focus();
        }
    }
}
Also used : TabWindowContainer(com.haulmont.cuba.web.sys.TabWindowContainer) WebWindow(com.haulmont.cuba.web.gui.WebWindow) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components)

Example 20 with WebWindow

use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.

the class WebScreens method showDialogWindow.

protected void showDialogWindow(Screen screen) {
    DialogWindow window = (DialogWindow) screen.getWindow();
    WebAppWorkArea workArea = getConfiguredWorkAreaOrNull();
    if (workArea != null) {
        WebWindow webWindow = (WebWindow) screen.getWindow();
        webWindow.setResolvedState(createOrUpdateState(webWindow.getResolvedState(), getConfiguredWorkArea().generateUrlStateMark()));
    }
    window.withUnwrappedComposition(CubaWindow.class, vWindow -> {
        vWindow.setErrorHandler(ui);
        String cubaId = "dialog_" + window.getId();
        if (ui.isTestMode()) {
            vWindow.setCubaId(cubaId);
        }
        if (ui.isPerformanceTestMode()) {
            vWindow.setId(ui.getTestIdManager().getTestId(cubaId));
        }
        if (hasModalWindow()) {
            // force modal
            window.setModal(true);
        }
        ui.addWindow(vWindow);
    });
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) GuiDialogWindow(com.haulmont.cuba.web.gui.components.WebDialogWindow.GuiDialogWindow) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Aggregations

WebWindow (com.haulmont.cuba.web.gui.WebWindow)24 NavigationState (com.haulmont.cuba.gui.navigation.NavigationState)8 Window (com.haulmont.cuba.gui.components.Window)6 Screen (com.haulmont.cuba.gui.screen.Screen)6 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)4 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)3 UrlParamsChangedEvent (com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent)3 NotFoundScreen (com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)3 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)3 GuiDialogWindow (com.haulmont.cuba.web.gui.components.WebDialogWindow.GuiDialogWindow)3 UrlChangeHandler (com.haulmont.cuba.web.sys.navigation.UrlChangeHandler)3 Component (com.vaadin.ui.Component)3 com.haulmont.cuba.gui (com.haulmont.cuba.gui)2 EditorScreen (com.haulmont.cuba.gui.screen.EditorScreen)2 WebTabWindow (com.haulmont.cuba.web.gui.components.WebTabWindow)2 WindowBreadCrumbs (com.haulmont.cuba.web.sys.WindowBreadCrumbs)2 CssLayout (com.vaadin.ui.CssLayout)2 Pair (com.haulmont.bali.datastruct.Pair)1 UrlRouting (com.haulmont.cuba.gui.UrlRouting)1 BelongToFrame (com.haulmont.cuba.gui.components.Component.BelongToFrame)1