Search in sources :

Example 1 with TabWindowContainer

use of com.haulmont.cuba.web.sys.TabWindowContainer in project cuba by cuba-platform.

the class WebAppWorkArea method getOpenedWorkAreaScreensStream.

public Stream<Screen> getOpenedWorkAreaScreensStream() {
    if (getMode() == Mode.TABBED) {
        TabSheetBehaviour tabSheetBehaviour = getTabbedWindowContainer().getTabSheetBehaviour();
        return tabSheetBehaviour.getTabComponentsStream().flatMap(c -> {
            TabWindowContainer windowContainer = (TabWindowContainer) c;
            Deque<Window> windows = windowContainer.getBreadCrumbs().getWindows();
            return windows.stream().map(Window::getFrameOwner);
        });
    } else {
        CubaSingleModeContainer singleWindowContainer = getSingleWindowContainer();
        TabWindowContainer windowContainer = (TabWindowContainer) singleWindowContainer.getWindowContainer();
        if (windowContainer != null) {
            Deque<Window> windows = windowContainer.getBreadCrumbs().getWindows();
            return windows.stream().map(Window::getFrameOwner);
        }
    }
    return Stream.empty();
}
Also used : TabWindowContainer(com.haulmont.cuba.web.sys.TabWindowContainer) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 2 with TabWindowContainer

use of com.haulmont.cuba.web.sys.TabWindowContainer in project cuba by cuba-platform.

the class WebAppWorkArea method closeWindowByShortcut.

protected void closeWindowByShortcut(RootWindow topLevelWindow) {
    if (getState() != AppWorkArea.State.WINDOW_CONTAINER) {
        return;
    }
    CubaUI ui = (CubaUI) this.getComponent().getUI();
    if (!ui.isAccessibleForUser(this.getComponent())) {
        LoggerFactory.getLogger(WebAppWorkArea.class).debug("Ignore close shortcut attempt because workArea is inaccessible for user");
        return;
    }
    if (getMode() == Mode.TABBED) {
        TabSheetBehaviour tabSheet = getTabbedWindowContainer().getTabSheetBehaviour();
        if (tabSheet != null) {
            TabWindowContainer layout = (TabWindowContainer) tabSheet.getSelectedTab();
            if (layout != null) {
                tabSheet.focus();
                WindowBreadCrumbs breadCrumbs = layout.getBreadCrumbs();
                Window currentWindow = breadCrumbs.getCurrentWindow();
                if (isNotCloseable(currentWindow)) {
                    return;
                }
                if (isWindowClosePrevented(currentWindow, CloseOriginType.SHORTCUT)) {
                    return;
                }
                if (breadCrumbs.getWindows().isEmpty()) {
                    com.vaadin.ui.Component previousTab = tabSheet.getPreviousTab(layout);
                    if (previousTab != null) {
                        currentWindow.getFrameOwner().close(FrameOwner.WINDOW_CLOSE_ACTION).then(() -> tabSheet.setSelectedTab(previousTab));
                    } else {
                        currentWindow.getFrameOwner().close(FrameOwner.WINDOW_CLOSE_ACTION);
                    }
                } else {
                    currentWindow.getFrameOwner().close(FrameOwner.WINDOW_CLOSE_ACTION);
                }
            }
        }
    } else {
        Iterator<WindowBreadCrumbs> it = getWindowStacks().iterator();
        if (it.hasNext()) {
            Window currentWindow = it.next().getCurrentWindow();
            if (!isWindowClosePrevented(currentWindow, CloseOriginType.SHORTCUT)) {
                ui.focus();
                currentWindow.getFrameOwner().close(FrameOwner.WINDOW_CLOSE_ACTION);
            }
        }
    }
}
Also used : TabWindowContainer(com.haulmont.cuba.web.sys.TabWindowContainer) WebWindow(com.haulmont.cuba.web.gui.WebWindow) WindowBreadCrumbs(com.haulmont.cuba.web.sys.WindowBreadCrumbs) Component(com.vaadin.ui.Component)

Example 3 with TabWindowContainer

use of com.haulmont.cuba.web.sys.TabWindowContainer in project cuba by cuba-platform.

the class WebAppWorkArea method getOpenedTabCount.

public int getOpenedTabCount() {
    if (getMode() == Mode.TABBED) {
        TabSheetBehaviour tabSheetBehaviour = getTabbedWindowContainer().getTabSheetBehaviour();
        return tabSheetBehaviour.getComponentCount();
    } else {
        CubaSingleModeContainer singleWindowContainer = getSingleWindowContainer();
        TabWindowContainer windowContainer = (TabWindowContainer) singleWindowContainer.getWindowContainer();
        return windowContainer != null ? 1 : 0;
    }
}
Also used : TabWindowContainer(com.haulmont.cuba.web.sys.TabWindowContainer)

Example 4 with TabWindowContainer

use of com.haulmont.cuba.web.sys.TabWindowContainer in project cuba by cuba-platform.

the class WebTabWindow method updateCaptionAndDescription.

protected void updateCaptionAndDescription() {
    TabSheet.Tab tabWindow = findTab();
    if (tabWindow != null) {
        String tabCaption = formatTabCaption();
        String tabDescription = formatTabDescription();
        tabWindow.setCaption(tabCaption);
        if (!Objects.equals(tabCaption, tabDescription)) {
            tabWindow.setDescription(tabDescription);
        } else {
            tabWindow.setDescription(null);
        }
        ((TabWindowContainer) tabWindow.getComponent()).getBreadCrumbs().update();
    } else {
        TabWindowContainer layout = (TabWindowContainer) asSingleWindow();
        if (layout != null) {
            layout.getBreadCrumbs().update();
        }
    }
}
Also used : TabWindowContainer(com.haulmont.cuba.web.sys.TabWindowContainer) TabSheet(com.vaadin.ui.TabSheet)

Example 5 with TabWindowContainer

use of com.haulmont.cuba.web.sys.TabWindowContainer in project cuba by cuba-platform.

the class WebAppWorkArea method getWindowStacks.

protected List<WindowBreadCrumbs> getWindowStacks() {
    if (getMode() == Mode.TABBED) {
        TabSheetBehaviour tabSheet = getTabbedWindowContainer().getTabSheetBehaviour();
        List<WindowBreadCrumbs> allBreadCrumbs = new ArrayList<>();
        for (int i = 0; i < tabSheet.getComponentCount(); i++) {
            String tabId = tabSheet.getTab(i);
            TabWindowContainer tabComponent = (TabWindowContainer) tabSheet.getTabComponent(tabId);
            allBreadCrumbs.add(tabComponent.getBreadCrumbs());
        }
        return allBreadCrumbs;
    } else {
        TabWindowContainer windowContainer = (TabWindowContainer) getSingleWindowContainer().getWindowContainer();
        if (windowContainer == null) {
            return Collections.emptyList();
        }
        return singletonList(windowContainer.getBreadCrumbs());
    }
}
Also used : TabWindowContainer(com.haulmont.cuba.web.sys.TabWindowContainer) WindowBreadCrumbs(com.haulmont.cuba.web.sys.WindowBreadCrumbs)

Aggregations

TabWindowContainer (com.haulmont.cuba.web.sys.TabWindowContainer)9 WebWindow (com.haulmont.cuba.web.gui.WebWindow)5 WindowBreadCrumbs (com.haulmont.cuba.web.sys.WindowBreadCrumbs)3 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)1 Screen (com.haulmont.cuba.gui.screen.Screen)1 Component (com.vaadin.ui.Component)1 TabSheet (com.vaadin.ui.TabSheet)1 Nullable (javax.annotation.Nullable)1