Search in sources :

Example 11 with WebAppWorkArea

use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea 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 12 with WebAppWorkArea

use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.

the class WebWindowManager method showWindowThisTab.

protected Component showWindowThisTab(final Window window, final String caption, final String description) {
    getDialogParams().reset();
    WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));
    Layout layout;
    if (workArea.getMode() == Mode.TABBED) {
        TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
        layout = (Layout) tabSheet.getSelectedTab();
    } else {
        layout = (Layout) workArea.getSingleWindowContainer().getComponent(0);
    }
    final WindowBreadCrumbs breadCrumbs = tabs.get(layout);
    if (breadCrumbs == null) {
        throw new IllegalStateException("BreadCrumbs not found");
    }
    final Window currentWindow = breadCrumbs.getCurrentWindow();
    Set<Map.Entry<Window, Integer>> set = windows.entrySet();
    boolean pushed = false;
    for (Map.Entry<Window, Integer> entry : set) {
        if (entry.getKey().equals(currentWindow)) {
            windows.remove(currentWindow);
            getStack(breadCrumbs).push(new Pair<>(entry.getKey(), entry.getValue()));
            pushed = true;
            break;
        }
    }
    if (!pushed) {
        getStack(breadCrumbs).push(new Pair<>(currentWindow, null));
    }
    removeFromWindowMap(currentWindow);
    layout.removeComponent(WebComponentsHelper.getComposition(currentWindow));
    final Component component = WebComponentsHelper.getComposition(window);
    component.setSizeFull();
    layout.addComponent(component);
    breadCrumbs.addWindow(window);
    if (workArea.getMode() == Mode.TABBED) {
        TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
        String tabId = tabSheet.getTab(layout);
        String formattedCaption = formatTabCaption(caption, description);
        tabSheet.setTabCaption(tabId, formattedCaption);
        String formattedDescription = formatTabDescription(caption, description);
        if (!Objects.equals(formattedCaption, formattedDescription)) {
            tabSheet.setTabDescription(tabId, formattedDescription);
        } else {
            tabSheet.setTabDescription(tabId, null);
        }
        tabSheet.setTabIcon(tabId, iconResolver.getIconResource(window.getIcon()));
        ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(window.getContentSwitchMode().name());
        tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
    } else {
        layout.markAsDirtyRecursive();
    }
    return layout;
}
Also used : Window(com.haulmont.cuba.gui.components.Window) 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) ParamsMap(com.haulmont.bali.util.ParamsMap) Collections.singletonMap(java.util.Collections.singletonMap)

Example 13 with WebAppWorkArea

use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.

the class WebScreens method handleTabWindowClose.

protected void handleTabWindowClose(HasTabSheetBehaviour targetTabSheet, com.vaadin.ui.Component tabContent) {
    WindowBreadCrumbs tabBreadCrumbs = ((TabWindowContainer) tabContent).getBreadCrumbs();
    WebAppWorkArea workArea = getConfiguredWorkAreaOrNull();
    if (workArea != null && workArea.isNotCloseable(tabBreadCrumbs.getCurrentWindow())) {
        return;
    }
    Runnable closeTask = new TabCloseTask(tabBreadCrumbs);
    closeTask.run();
    // it is needed to force redraw tabSheet if it has a lot of tabs and part of them are hidden
    targetTabSheet.markAsDirty();
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)

Example 14 with WebAppWorkArea

use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.

the class WebScreens method createWindowBreadCrumbs.

protected WindowBreadCrumbs createWindowBreadCrumbs(@SuppressWarnings("unused") Screen screen) {
    WebAppWorkArea appWorkArea = getConfiguredWorkArea();
    WindowBreadCrumbs windowBreadCrumbs = new WindowBreadCrumbs(appWorkArea.getMode());
    windowBreadCrumbs.setUI(ui);
    windowBreadCrumbs.setBeanLocator(beanLocator);
    boolean showBreadCrumbs = webConfig.getShowBreadCrumbs() || appWorkArea.getMode() == Mode.SINGLE;
    windowBreadCrumbs.setVisible(showBreadCrumbs);
    return windowBreadCrumbs;
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)

Example 15 with WebAppWorkArea

use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.

the class WebScreens method getActiveWorkAreaScreensStream.

protected Stream<Screen> getActiveWorkAreaScreensStream() {
    Screen rootScreen = getRootScreenOrNull();
    if (rootScreen == null) {
        return Stream.empty();
    }
    WebAppWorkArea workArea = getConfiguredWorkAreaOrNull();
    if (workArea == null) {
        return Stream.empty();
    }
    return workArea.getActiveWorkAreaScreensStream();
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) Screen(com.haulmont.cuba.gui.screen.Screen)

Aggregations

WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)24 WebWindow (com.haulmont.cuba.web.gui.WebWindow)10 Screen (com.haulmont.cuba.gui.screen.Screen)7 CssLayout (com.vaadin.ui.CssLayout)7 com.haulmont.cuba.gui (com.haulmont.cuba.gui)6 WindowBreadCrumbs (com.haulmont.cuba.web.sys.WindowBreadCrumbs)6 Window (com.haulmont.cuba.gui.components.Window)5 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)5 GuiDialogWindow (com.haulmont.cuba.web.gui.components.WebDialogWindow.GuiDialogWindow)5 WebTabWindow (com.haulmont.cuba.web.gui.components.WebTabWindow)5 Component (com.vaadin.ui.Component)5 HasWorkArea (com.haulmont.cuba.gui.components.Window.HasWorkArea)3 AppWorkArea (com.haulmont.cuba.gui.components.mainwindow.AppWorkArea)3 Layout (com.vaadin.ui.Layout)3 Nonnull (javax.annotation.Nonnull)2 Nullable (javax.annotation.Nullable)2 Pair (com.haulmont.bali.datastruct.Pair)1 ParamsMap (com.haulmont.bali.util.ParamsMap)1 Preconditions.checkNotNullArgument (com.haulmont.bali.util.Preconditions.checkNotNullArgument)1 ReflectionHelper (com.haulmont.bali.util.ReflectionHelper)1