Search in sources :

Example 56 with AppUI

use of io.jmix.ui.AppUI in project jmix by jmix-framework.

the class ScreenNavigationHandler method doHandle.

@Override
public boolean doHandle(NavigationState requestedState, AppUI ui) {
    UrlChangeHandler urlChangeHandler = ui.getUrlChangeHandler();
    if (urlChangeHandler.isEmptyState(requestedState) || !isScreenChanged(requestedState, ui)) {
        return false;
    }
    String requestedRoute = requestedState.getNestedRoute();
    if (StringUtils.isEmpty(requestedRoute)) {
        log.info("Unable to handle state with empty route '{}'", requestedState);
        urlChangeHandler.revertNavigationState();
        return true;
    }
    String[] routeParts = { requestedRoute };
    if (windowConfig.findWindowInfoByRoute(requestedRoute) == null) {
        routeParts = requestedRoute.split("/");
    }
    if (routeParts.length > MAX_SUB_ROUTES) {
        log.info("Unable to perform navigation to requested state '{}'. Only {} sub routes are supported", requestedRoute, MAX_SUB_ROUTES);
        urlChangeHandler.revertNavigationState();
        return true;
    }
    List<Pair<String, WindowInfo>> routeWindowInfos = Arrays.stream(routeParts).map(subRoute -> new Pair<>(subRoute, windowConfig.findWindowInfoByRoute(subRoute))).collect(Collectors.toList());
    for (Pair<String, WindowInfo> entry : routeWindowInfos) {
        WindowInfo routeWindowInfo = entry.getSecond();
        if (routeWindowInfo == null) {
            log.info("No registered screen found for route: '{}'", entry.getFirst());
            urlChangeHandler.revertNavigationState();
            handle404(entry.getFirst(), ui);
            return true;
        }
        if (urlChangeHandler.shouldRedirect(routeWindowInfo)) {
            urlChangeHandler.redirect(requestedState);
            return true;
        }
        if (urlChangeHandler.isRootRoute(routeWindowInfo)) {
            log.info("Unable navigate to '{}' as nested screen", routeWindowInfo.getId());
            urlChangeHandler.revertNavigationState();
            return true;
        }
    }
    return navigate(requestedState, ui, routeWindowInfos);
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) java.util(java.util) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) io.jmix.core(io.jmix.core) ParamsMap(io.jmix.core.common.util.ParamsMap) StringUtils(org.apache.commons.lang3.StringUtils) Scope(org.springframework.context.annotation.Scope) WindowConfig(io.jmix.ui.WindowConfig) AccessDeniedException(io.jmix.core.security.AccessDeniedException) NEW_ENTITY_ID(io.jmix.ui.navigation.WebUrlRouting.NEW_ENTITY_ID) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) io.jmix.ui.navigation(io.jmix.ui.navigation) Nullable(javax.annotation.Nullable) MapUtils(org.apache.commons.collections4.MapUtils) Order(org.springframework.core.annotation.Order) Logger(org.slf4j.Logger) WindowImpl(io.jmix.ui.component.impl.WindowImpl) Pair(io.jmix.core.common.datastruct.Pair) UiEntityContext(io.jmix.ui.accesscontext.UiEntityContext) Collectors(java.util.stream.Collectors) Component(org.springframework.stereotype.Component) io.jmix.ui.screen(io.jmix.ui.screen) AppUI(io.jmix.ui.AppUI) WindowInfo(io.jmix.ui.WindowInfo) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) NotFoundScreen(io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen) Pair(io.jmix.core.common.datastruct.Pair) WindowInfo(io.jmix.ui.WindowInfo)

Aggregations

AppUI (io.jmix.ui.AppUI)56 TestIdManager (io.jmix.ui.sys.TestIdManager)8 Component (com.vaadin.ui.Component)5 UiEventsMulticaster (io.jmix.ui.sys.event.UiEventsMulticaster)4 ApplicationListener (org.springframework.context.ApplicationListener)4 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)3 Notifications (io.jmix.ui.Notifications)3 Folder (com.haulmont.cuba.core.entity.Folder)2 Internal (io.jmix.core.annotation.Internal)2 Screen (io.jmix.ui.screen.Screen)2 StandardCloseAction (io.jmix.ui.screen.StandardCloseAction)2 Subscribe (io.jmix.ui.screen.Subscribe)2 JmixButton (io.jmix.ui.widget.JmixButton)2 Nullable (javax.annotation.Nullable)2 Strings (com.google.common.base.Strings)1 AbstractSearchFolder (com.haulmont.cuba.core.entity.AbstractSearchFolder)1 AppFolder (com.haulmont.cuba.core.entity.AppFolder)1 AppFolderEditWindow (com.haulmont.cuba.web.app.folders.AppFolderEditWindow)1 FolderEditWindow (com.haulmont.cuba.web.app.folders.FolderEditWindow)1 KeyCode (com.vaadin.event.ShortcutAction.KeyCode)1