Search in sources :

Example 21 with WebAppWorkArea

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

the class WebScreens method getConfiguredWorkAreaOrNull.

@Nullable
protected WebAppWorkArea getConfiguredWorkAreaOrNull() {
    RootWindow topLevelWindow = ui.getTopLevelWindow();
    if (topLevelWindow == null) {
        throw new IllegalStateException("There is no root screen opened");
    }
    Screen controller = topLevelWindow.getFrameOwner();
    if (controller instanceof HasWorkArea) {
        AppWorkArea workArea = ((HasWorkArea) controller).getWorkArea();
        if (workArea != null) {
            return (WebAppWorkArea) workArea;
        }
    }
    return null;
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) HasWorkArea(com.haulmont.cuba.gui.components.Window.HasWorkArea) Screen(com.haulmont.cuba.gui.screen.Screen) WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) AppWorkArea(com.haulmont.cuba.gui.components.mainwindow.AppWorkArea) Nullable(javax.annotation.Nullable)

Example 22 with WebAppWorkArea

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

the class WebScreens method removeAll.

@Override
public void removeAll() {
    List<Screen> dialogScreens = getDialogScreensStream().collect(Collectors.toList());
    for (Screen dialogScreen : dialogScreens) {
        remove(dialogScreen);
    }
    WebAppWorkArea workArea = getConfiguredWorkAreaOrNull();
    if (workArea != null) {
        Collection<WindowStack> workAreaStacks = getWorkAreaStacks(workArea);
        for (WindowStack workAreaStack : workAreaStacks) {
            Collection<Screen> tabScreens = workAreaStack.getBreadcrumbs();
            for (Screen screen : tabScreens) {
                remove(screen);
            }
        }
    }
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) Screen(com.haulmont.cuba.gui.screen.Screen)

Example 23 with WebAppWorkArea

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

the class WebScreens method selectWindowTab.

@Override
public void selectWindowTab(Window window) {
    WebAppWorkArea workArea = getConfiguredWorkArea();
    Collection<WindowStack> workAreaStacks = getWorkAreaStacks(workArea);
    Screen screen = window.getFrameOwner();
    workAreaStacks.stream().filter(ws -> ws.getBreadcrumbs().contains(screen)).findFirst().ifPresent(WindowStack::select);
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) Screen(com.haulmont.cuba.gui.screen.Screen)

Example 24 with WebAppWorkArea

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

the class WebScreens method showThisTabWindow.

protected void showThisTabWindow(Screen screen) {
    WebAppWorkArea workArea = getConfiguredWorkArea();
    workArea.switchTo(AppWorkArea.State.WINDOW_CONTAINER);
    TabWindowContainer windowContainer;
    if (workArea.getMode() == Mode.TABBED) {
        TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
        windowContainer = (TabWindowContainer) tabSheet.getSelectedTab();
    } else {
        windowContainer = (TabWindowContainer) workArea.getSingleWindowContainer().getWindowContainer();
    }
    if (windowContainer == null || windowContainer.getBreadCrumbs() == null) {
        throw new IllegalStateException("BreadCrumbs not found");
    }
    WindowBreadCrumbs breadCrumbs = windowContainer.getBreadCrumbs();
    Window currentWindow = breadCrumbs.getCurrentWindow();
    windowContainer.removeComponent(currentWindow.unwrapComposition(Layout.class));
    Window newWindow = screen.getWindow();
    com.vaadin.ui.Component newWindowComposition = newWindow.unwrapComposition(com.vaadin.ui.Component.class);
    windowContainer.addComponent(newWindowComposition);
    breadCrumbs.addWindow(newWindow);
    WebWindow webWindow = (WebWindow) screen.getWindow();
    webWindow.setResolvedState(createOrUpdateState(webWindow.getResolvedState(), getConfiguredWorkArea().generateUrlStateMark()));
    if (workArea.getMode() == Mode.TABBED) {
        TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
        String tabId = tabSheet.getTab(windowContainer);
        TabWindow tabWindow = (TabWindow) newWindow;
        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(newWindow.getIcon()));
        tabSheet.setTabClosable(tabId, newWindow.isCloseable());
        ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(tabWindow.getContentSwitchMode().name());
        tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
    } else {
        windowContainer.markAsDirtyRecursive();
    }
}
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) CssLayout(com.vaadin.ui.CssLayout) Layout(com.vaadin.ui.Layout) WebTabWindow(com.haulmont.cuba.web.gui.components.WebTabWindow)

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