Search in sources :

Example 21 with WebWindow

use of com.haulmont.cuba.web.gui.WebWindow 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)

Example 22 with WebWindow

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

the class UrlChangeHandler method getStateMark.

protected String getStateMark(Screen screen) {
    WebWindow webWindow = (WebWindow) screen.getWindow();
    NavigationState resolvedState = webWindow.getResolvedState();
    return resolvedState != null ? resolvedState.getStateMark() : NavigationState.EMPTY.getStateMark();
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 23 with WebWindow

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

the class ParamsNavigationHandler method doHandle.

@Override
public boolean doHandle(NavigationState requestedState, AppUI ui) {
    UrlChangeHandler urlChangeHandler = ui.getUrlChangeHandler();
    if (urlChangeHandler.isEmptyState(requestedState)) {
        return false;
    }
    Screen screen = urlChangeHandler.getActiveScreen();
    if (screen == null) {
        log.debug("Unable to find a screen for state: '{}", requestedState);
        return false;
    }
    Map<String, String> params = requestedState.getParams() != null ? requestedState.getParams() : Collections.emptyMap();
    WebWindow window = (WebWindow) screen.getWindow();
    NavigationState resolvedState = window.getResolvedState();
    if (resolvedState == null || params.equals(resolvedState.getParams())) {
        return false;
    }
    NavigationState newState = new NavigationState(resolvedState.getRoot(), resolvedState.getStateMark(), resolvedState.getNestedRoute(), params);
    window.setResolvedState(newState);
    UiControllerUtils.fireEvent(screen, UrlParamsChangedEvent.class, new UrlParamsChangedEvent(screen, params));
    return true;
}
Also used : UrlParamsChangedEvent(com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent) Screen(com.haulmont.cuba.gui.screen.Screen) NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) UrlChangeHandler(com.haulmont.cuba.web.sys.navigation.UrlChangeHandler) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 24 with WebWindow

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

the class ScreenNavigationHandler method handle404.

protected void handle404(String route, AppUI ui) {
    MapScreenOptions options = new MapScreenOptions(ParamsMap.of("requestedRoute", route));
    NotFoundScreen notFoundScreen = ui.getScreens().create(NotFoundScreen.class, OpenMode.NEW_TAB, options);
    NavigationState state = new NavigationState(ui.getUrlRouting().getState().getRoot(), "", route, Collections.emptyMap());
    ((WebWindow) notFoundScreen.getWindow()).setResolvedState(state);
    notFoundScreen.show();
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) MapScreenOptions(com.haulmont.cuba.gui.screen.MapScreenOptions) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) 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