Search in sources :

Example 21 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

the class WebUrlRouting method buildDialogRoute.

protected String buildDialogRoute(Screen dialog) {
    RouteDefinition dialogRouteDefinition = getRouteDef(dialog);
    Iterator<Screen> currentTabScreens = ui.getScreens().getOpenedScreens().getCurrentBreadcrumbs().iterator();
    Screen currentScreen = currentTabScreens.hasNext() ? currentTabScreens.next() : null;
    String currentScreenRoute = currentScreen != null ? buildScreenRoute(currentScreen) : "";
    if (dialogRouteDefinition == null) {
        return currentScreenRoute;
    }
    String dialogRoute = dialogRouteDefinition.getPath();
    if (dialogRoute == null || dialogRoute.isEmpty()) {
        return currentScreenRoute;
    }
    String parentPrefix = dialogRouteDefinition.getParentPrefix();
    if (StringUtils.isNotEmpty(parentPrefix) && dialogRoute.startsWith(parentPrefix + '/') && currentScreenRoute.endsWith(parentPrefix)) {
        dialogRoute = dialogRoute.substring(parentPrefix.length() + 1);
    }
    return currentScreenRoute == null || currentScreenRoute.isEmpty() ? dialogRoute : currentScreenRoute + '/' + dialogRoute;
}
Also used : EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) NotFoundScreen(io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen) Preconditions.checkNotEmptyString(io.jmix.core.common.util.Preconditions.checkNotEmptyString)

Example 22 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

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();
    WindowImpl window = (WindowImpl) 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(io.jmix.ui.navigation.UrlParamsChangedEvent) WindowImpl(io.jmix.ui.component.impl.WindowImpl) Screen(io.jmix.ui.screen.Screen) NavigationState(io.jmix.ui.navigation.NavigationState) UrlChangeHandler(io.jmix.ui.navigation.UrlChangeHandler)

Example 23 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

the class RootNavigationHandler method doHandle.

@Override
public boolean doHandle(NavigationState requestedState, AppUI ui) {
    UrlChangeHandler urlChangeHandler = ui.getUrlChangeHandler();
    if (urlChangeHandler.isEmptyState(requestedState)) {
        urlChangeHandler.revertNavigationState();
        return false;
    }
    if (!rootChanged(requestedState, ui)) {
        return false;
    }
    String rootRoute = requestedState.getRoot();
    WindowInfo windowInfo = windowConfig.findWindowInfoByRoute(rootRoute);
    if (windowInfo == null) {
        log.info("No registered screen found for route: '{}'", rootRoute);
        urlChangeHandler.revertNavigationState();
        handle404(rootRoute, ui);
        return true;
    }
    if (urlChangeHandler.shouldRedirect(windowInfo)) {
        urlChangeHandler.redirect(requestedState);
        return true;
    }
    if (!urlChangeHandler.isPermittedToNavigate(requestedState, windowInfo)) {
        return true;
    }
    Screen screen = ui.getScreens().create(windowInfo.getId(), OpenMode.ROOT);
    boolean hasNestedRoute = StringUtils.isNotEmpty(requestedState.getNestedRoute());
    if (!hasNestedRoute && MapUtils.isNotEmpty(requestedState.getParams())) {
        UiControllerUtils.fireEvent(screen, UrlParamsChangedEvent.class, new UrlParamsChangedEvent(screen, requestedState.getParams()));
        ((WindowImpl) screen.getWindow()).setResolvedState(requestedState);
    }
    screen.show();
    return !hasNestedRoute;
}
Also used : UrlParamsChangedEvent(io.jmix.ui.navigation.UrlParamsChangedEvent) WindowImpl(io.jmix.ui.component.impl.WindowImpl) Screen(io.jmix.ui.screen.Screen) NotFoundScreen(io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen) UrlChangeHandler(io.jmix.ui.navigation.UrlChangeHandler) WindowInfo(io.jmix.ui.WindowInfo)

Example 24 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

the class RootNavigationHandler method rootChanged.

protected boolean rootChanged(NavigationState requestedState, AppUI ui) {
    Screen rootScreen = ui.getScreens().getOpenedScreens().getRootScreenOrNull();
    if (rootScreen == null) {
        return false;
    }
    String rootRoute = ((WindowImpl) rootScreen.getWindow()).getResolvedState().getRoot();
    return !StringUtils.equals(rootRoute, requestedState.getRoot());
}
Also used : Screen(io.jmix.ui.screen.Screen) NotFoundScreen(io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen)

Example 25 with Screen

use of io.jmix.ui.screen.Screen in project jmix by jmix-framework.

the class UrlChangeHandler method redirect.

public void redirect(NavigationState navigationState) {
    String loginScreenId = uiProperties.getLoginScreenId();
    Screen loginScreen = ui.getScreens().create(loginScreenId, OpenMode.ROOT);
    loginScreen.show();
    RedirectHandler redirectHandler = applicationContext.getBean(RedirectHandler.class, ui);
    redirectHandler.schedule(navigationState);
    setRedirectHandler(redirectHandler);
}
Also used : Screen(io.jmix.ui.screen.Screen)

Aggregations

Screen (io.jmix.ui.screen.Screen)82 EditorScreen (io.jmix.ui.screen.EditorScreen)20 LookupScreen (io.jmix.ui.screen.LookupScreen)15 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)11 Nullable (javax.annotation.Nullable)9 Messages (io.jmix.core.Messages)6 WindowImpl (io.jmix.ui.component.impl.WindowImpl)6 Screens (io.jmix.ui.Screens)5 io.jmix.ui.component (io.jmix.ui.component)5 NavigationState (io.jmix.ui.navigation.NavigationState)5 FrameOwner (io.jmix.ui.screen.FrameOwner)5 UiControllerUtils (io.jmix.ui.screen.UiControllerUtils)5 java.util (java.util)5 Collectors (java.util.stream.Collectors)5 LoggerFactory (org.slf4j.LoggerFactory)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)4 ScreenEditorWrapper (com.haulmont.cuba.gui.screen.compatibility.ScreenEditorWrapper)4 MetaClass (io.jmix.core.metamodel.model.MetaClass)4 BaseAction (io.jmix.ui.action.BaseAction)4