Search in sources :

Example 1 with WebWindow

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

the class WebWindowManager method closeAll.

/**
 * Close all screens in the main window (browser tab) this WindowManager belongs to.
 */
public void closeAll() {
    List<Map.Entry<Window, WindowOpenInfo>> entries = new ArrayList<>(windowOpenMode.entrySet());
    for (int i = entries.size() - 1; i >= 0; i--) {
        WebWindow window = (WebWindow) entries.get(i).getKey();
        if (window instanceof WebWindow.Editor) {
            ((WebWindow.Editor) window).releaseLock();
        }
        closeWindow(window, entries.get(i).getValue());
    }
    disableSavingScreenHistory = false;
    windowOpenMode.clear();
    windows.clear();
}
Also used : WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 2 with WebWindow

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

the class WebWindowManager method isCloseWithCloseButtonPrevented.

protected boolean isCloseWithCloseButtonPrevented(Window currentWindow) {
    WebWindow webWindow = (WebWindow) ComponentsHelper.getWindowImplementation(currentWindow);
    if (webWindow != null) {
        BeforeCloseWithCloseButtonEvent event = new BeforeCloseWithCloseButtonEvent(webWindow);
        webWindow.fireBeforeCloseWithCloseButton(event);
        return event.isClosePrevented();
    }
    return false;
}
Also used : BeforeCloseWithCloseButtonEvent(com.haulmont.cuba.gui.components.Window.BeforeCloseWithCloseButtonEvent) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 3 with WebWindow

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

the class WebWindowManager method isCloseWithShortcutPrevented.

protected boolean isCloseWithShortcutPrevented(Window currentWindow) {
    WebWindow webWindow = (WebWindow) ComponentsHelper.getWindowImplementation(currentWindow);
    if (webWindow != null) {
        BeforeCloseWithShortcutEvent event = new BeforeCloseWithShortcutEvent(webWindow);
        webWindow.fireBeforeCloseWithShortcut(event);
        return event.isClosePrevented();
    }
    return false;
}
Also used : BeforeCloseWithShortcutEvent(com.haulmont.cuba.gui.components.Window.BeforeCloseWithShortcutEvent) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 4 with WebWindow

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

the class WebAppWorkArea method reflectTabChangeToUrl.

protected void reflectTabChangeToUrl(boolean userOriginated) {
    if (!userOriginated) {
        return;
    }
    Component selectedTab = tabbedContainer.getTabSheetBehaviour().getSelectedTab();
    if (selectedTab == null) {
        return;
    }
    Window selectedWindow = ((TabWindowContainer) selectedTab).getBreadCrumbs().getCurrentWindow();
    WebWindow webWindow = (WebWindow) selectedWindow;
    NavigationState resolvedState = webWindow.getResolvedState();
    if (resolvedState != null) {
        int stateMark = generateUrlStateMark();
        NavigationState newState = new NavigationState(resolvedState.getRoot(), String.valueOf(stateMark), resolvedState.getNestedRoute(), resolvedState.getParams());
        webWindow.setResolvedState(newState);
        Screen screen = selectedWindow.getFrameOwner();
        UrlRouting urlRouting = UiControllerUtils.getScreenContext(screen).getUrlRouting();
        urlRouting.pushState(screen, newState.getParams());
    }
}
Also used : WebWindow(com.haulmont.cuba.web.gui.WebWindow) NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) Screen(com.haulmont.cuba.gui.screen.Screen) WebAbstractComponent(com.haulmont.cuba.web.gui.components.WebAbstractComponent) Component(com.vaadin.ui.Component) UrlRouting(com.haulmont.cuba.gui.UrlRouting) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 5 with WebWindow

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

the class WebScreens method createNewTabLayout.

protected void createNewTabLayout(Screen screen) {
    WindowBreadCrumbs breadCrumbs = createWindowBreadCrumbs(screen);
    breadCrumbs.setWindowNavigateHandler(this::handleWindowBreadCrumbsNavigate);
    breadCrumbs.addWindow(screen.getWindow());
    WebWindow webWindow = (WebWindow) screen.getWindow();
    webWindow.setResolvedState(createOrUpdateState(webWindow.getResolvedState(), getConfiguredWorkArea().generateUrlStateMark()));
    TabWindowContainer windowContainer = new TabWindowContainerImpl();
    windowContainer.setPrimaryStyleName("c-app-window-wrap");
    windowContainer.setSizeFull();
    windowContainer.setBreadCrumbs(breadCrumbs);
    windowContainer.addComponent(breadCrumbs);
    Window window = screen.getWindow();
    com.vaadin.ui.Component windowComposition = window.unwrapComposition(com.vaadin.ui.Component.class);
    windowContainer.addComponent(windowComposition);
    WebAppWorkArea workArea = getConfiguredWorkArea();
    if (workArea.getMode() == Mode.TABBED) {
        windowContainer.addStyleName("c-app-tabbed-window");
        TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
        String tabId = "tab_" + uuidSource.createUuid();
        tabSheet.addTab(windowContainer, tabId);
        if (ui.isTestMode()) {
            String id = "tab_" + window.getId();
            tabSheet.setTabTestId(tabId, ui.getTestIdManager().getTestId(id));
            tabSheet.setTabCubaId(tabId, id);
        }
        TabWindow tabWindow = (TabWindow) window;
        String windowContentSwitchMode = tabWindow.getContentSwitchMode().name();
        ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(windowContentSwitchMode);
        tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
        String formattedCaption = tabWindow.formatTabCaption();
        String formattedDescription = tabWindow.formatTabDescription();
        tabSheet.setTabCaption(tabId, formattedCaption);
        if (!Objects.equals(formattedCaption, formattedDescription)) {
            tabSheet.setTabDescription(tabId, formattedDescription);
        } else {
            tabSheet.setTabDescription(tabId, null);
        }
        tabSheet.setTabIcon(tabId, iconResolver.getIconResource(window.getIcon()));
        tabSheet.setTabClosable(tabId, window.isCloseable());
        tabSheet.setTabCloseHandler(windowContainer, this::handleTabWindowClose);
        tabSheet.setSelectedTab(windowContainer);
    } else {
        windowContainer.addStyleName("c-app-single-window");
        CubaSingleModeContainer mainLayout = workArea.getSingleWindowContainer();
        if (mainLayout.getWindowContainer() != null) {
            // remove all windows from single stack
            TabWindowContainer oldWindowContainer = (TabWindowContainer) mainLayout.getWindowContainer();
            Deque<Window> windows = oldWindowContainer.getBreadCrumbs().getWindows();
            Iterator<Window> iterator = windows.descendingIterator();
            while (iterator.hasNext()) {
                Window oldWindow = iterator.next();
                remove(oldWindow.getFrameOwner());
            }
            // after last window closed we need to switch back to window container
            workArea.switchTo(AppWorkArea.State.WINDOW_CONTAINER);
        }
        mainLayout.setWindowContainer(windowContainer);
    }
}
Also used : GuiDialogWindow(com.haulmont.cuba.web.gui.components.WebDialogWindow.GuiDialogWindow) WebWindow(com.haulmont.cuba.web.gui.WebWindow) WebTabWindow(com.haulmont.cuba.web.gui.components.WebTabWindow) WebWindow(com.haulmont.cuba.web.gui.WebWindow) WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) com.haulmont.cuba.gui(com.haulmont.cuba.gui) WebTabWindow(com.haulmont.cuba.web.gui.components.WebTabWindow)

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