Search in sources :

Example 11 with WindowImpl

use of io.jmix.ui.component.impl.WindowImpl in project jmix by jmix-framework.

the class ScreensImpl method afterScreenRemove.

protected void afterScreenRemove(Screen screen) {
    if (screen.getWindow() instanceof RootWindow) {
        return;
    }
    Screen currentScreen = getAnyCurrentScreen();
    if (currentScreen != null) {
        NavigationState resolvedState = ((WindowImpl) currentScreen.getWindow()).getResolvedState();
        if (resolvedState != null) {
            String currentScreenRoute = resolvedState.asRoute();
            urlTools.replaceState(currentScreenRoute, ui);
        }
    }
}
Also used : WindowImpl(io.jmix.ui.component.impl.WindowImpl) TabWindowImpl(io.jmix.ui.component.impl.TabWindowImpl) Screen(io.jmix.ui.screen.Screen) NavigationState(io.jmix.ui.navigation.NavigationState)

Example 12 with WindowImpl

use of io.jmix.ui.component.impl.WindowImpl in project jmix by jmix-framework.

the class ScreensImpl method showThisTabWindow.

protected void showThisTabWindow(Screen screen) {
    AppWorkAreaImpl workArea = getConfiguredWorkArea();
    workArea.switchTo(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);
    WindowImpl windowImpl = (WindowImpl) screen.getWindow();
    windowImpl.setResolvedState(createOrUpdateState(windowImpl.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(io.jmix.ui.component.impl.DialogWindowImpl.GuiDialogWindow) WindowImpl(io.jmix.ui.component.impl.WindowImpl) TabWindowImpl(io.jmix.ui.component.impl.TabWindowImpl) AppWorkAreaImpl(io.jmix.ui.component.impl.AppWorkAreaImpl) io.jmix.ui(io.jmix.ui) CssLayout(com.vaadin.ui.CssLayout) Layout(com.vaadin.ui.Layout)

Example 13 with WindowImpl

use of io.jmix.ui.component.impl.WindowImpl in project jmix by jmix-framework.

the class ScreensImpl method showDialogWindow.

protected void showDialogWindow(Screen screen) {
    DialogWindow window = (DialogWindow) screen.getWindow();
    AppWorkArea workArea = getConfiguredWorkAreaOrNull();
    if (workArea != null) {
        WindowImpl windowImpl = (WindowImpl) screen.getWindow();
        windowImpl.setResolvedState(createOrUpdateState(windowImpl.getResolvedState(), getConfiguredWorkArea().generateUrlStateMark()));
    }
    window.withUnwrappedComposition(JmixWindow.class, vWindow -> {
        vWindow.setErrorHandler(ui);
        String jmixId = "dialog_" + window.getId();
        if (ui.isTestMode()) {
            vWindow.setJTestId(jmixId);
        }
        if (ui.isPerformanceTestMode()) {
            vWindow.setId(ui.getTestIdManager().getTestId(jmixId));
        }
        if (hasModalWindow()) {
            // force modal
            window.setModal(true);
        }
        ui.addWindow(vWindow);
    });
}
Also used : WindowImpl(io.jmix.ui.component.impl.WindowImpl) TabWindowImpl(io.jmix.ui.component.impl.TabWindowImpl) GuiDialogWindow(io.jmix.ui.component.impl.DialogWindowImpl.GuiDialogWindow)

Example 14 with WindowImpl

use of io.jmix.ui.component.impl.WindowImpl in project jmix by jmix-framework.

the class ScreensImpl method changeUrl.

protected void changeUrl(Screen screen) {
    WindowImpl windowImpl = (WindowImpl) screen.getWindow();
    Map<String, String> params = windowImpl.getResolvedState() != null ? windowImpl.getResolvedState().getParams() : Collections.emptyMap();
    ui.getUrlRouting().pushState(screen, params);
}
Also used : WindowImpl(io.jmix.ui.component.impl.WindowImpl) TabWindowImpl(io.jmix.ui.component.impl.TabWindowImpl)

Aggregations

WindowImpl (io.jmix.ui.component.impl.WindowImpl)14 TabWindowImpl (io.jmix.ui.component.impl.TabWindowImpl)5 Screen (io.jmix.ui.screen.Screen)4 NotFoundScreen (io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen)3 GuiDialogWindow (io.jmix.ui.component.impl.DialogWindowImpl.GuiDialogWindow)3 io.jmix.ui (io.jmix.ui)2 RootWindow (io.jmix.ui.component.RootWindow)2 AppWorkAreaImpl (io.jmix.ui.component.impl.AppWorkAreaImpl)2 NavigationState (io.jmix.ui.navigation.NavigationState)2 UrlChangeHandler (io.jmix.ui.navigation.UrlChangeHandler)2 UrlParamsChangedEvent (io.jmix.ui.navigation.UrlParamsChangedEvent)2 CssLayout (com.vaadin.ui.CssLayout)1 Layout (com.vaadin.ui.Layout)1 WindowInfo (io.jmix.ui.WindowInfo)1 Window (io.jmix.ui.component.Window)1