Search in sources :

Example 11 with WindowInfo

use of io.jmix.ui.WindowInfo 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)

Example 12 with WindowInfo

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

the class ScreenNavigationHandler method navigate.

protected boolean navigate(NavigationState requestedState, AppUI ui, List<Pair<String, WindowInfo>> routeWindowInfos) {
    int subRouteIdx = 0;
    NavigationState currentState = ui.getHistory().getNow();
    for (Pair<String, WindowInfo> entry : routeWindowInfos) {
        String subRoute = entry.getFirst();
        if (skipSubRoute(requestedState, subRouteIdx, currentState, subRoute)) {
            subRouteIdx++;
            continue;
        }
        WindowInfo windowInfo = entry.getSecond();
        openScreen(requestedState, subRoute, windowInfo, ui);
        subRouteIdx++;
    }
    return true;
}
Also used : WindowInfo(io.jmix.ui.WindowInfo)

Example 13 with WindowInfo

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

the class ScreensHelper method getDefaultBrowseScreen.

@Nullable
public WindowInfo getDefaultBrowseScreen(MetaClass metaClass) {
    WindowInfo browseWindow = windowConfig.findWindowInfo(windowConfig.getBrowseScreenId(metaClass));
    if (browseWindow != null) {
        UiShowScreenContext screenContext = new UiShowScreenContext(browseWindow.getId());
        accessManager.applyRegisteredConstraints(screenContext);
        if (screenContext.isPermitted()) {
            return browseWindow;
        }
    }
    WindowInfo lookupWindow = windowConfig.findWindowInfo(windowConfig.getLookupScreenId(metaClass));
    if (lookupWindow != null) {
        UiShowScreenContext screenContext = new UiShowScreenContext(lookupWindow.getId());
        accessManager.applyRegisteredConstraints(screenContext);
        if (screenContext.isPermitted()) {
            return lookupWindow;
        }
    }
    return null;
}
Also used : UiShowScreenContext(io.jmix.ui.accesscontext.UiShowScreenContext) WindowInfo(io.jmix.ui.WindowInfo) Nullable(javax.annotation.Nullable)

Example 14 with WindowInfo

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

the class HistoryNavigator method handleRootBackNavigation.

protected void handleRootBackNavigation(NavigationState previousState) {
    WindowInfo rootWindowInfo = urlChangeHandler.windowConfig.findWindowInfoByRoute(previousState.getRoot());
    if (rootWindowInfo == null) {
        log.debug("Unable to find registered root screen with route: '{}'", previousState.getRoot());
        urlChangeHandler.revertNavigationState();
        return;
    }
    Class<? extends FrameOwner> requestedScreenClass = rootWindowInfo.getControllerClass();
    RootWindow topLevelWindow = AppUI.getCurrent().getTopLevelWindow();
    Class<? extends FrameOwner> currentScreenClass = topLevelWindow != null ? topLevelWindow.getFrameOwner().getClass() : null;
    if (currentScreenClass != null && requestedScreenClass.isAssignableFrom(currentScreenClass)) {
        if (Window.HasWorkArea.class.isAssignableFrom(requestedScreenClass)) {
            if (closeWorkAreaScreens()) {
                history.backward();
            }
        } else {
            history.backward();
        }
    } else {
        urlChangeHandler.getScreenNavigator().handleScreenNavigation(previousState);
        /*
             * Since back navigation from one root screen to another root screen
             * can be performed only via screen opening we have to trigger history
             * back twice.
             */
        history.backward();
        history.backward();
    }
}
Also used : RootWindow(io.jmix.ui.component.RootWindow) Window(io.jmix.ui.component.Window) RootWindow(io.jmix.ui.component.RootWindow) WindowInfo(io.jmix.ui.WindowInfo)

Example 15 with WindowInfo

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

the class ReportEditSecurityFragment method initScreenIdField.

protected void initScreenIdField(List<WindowInfo> windowInfoCollection) {
    Map<String, String> screens = new LinkedHashMap<>();
    for (WindowInfo windowInfo : windowInfoCollection) {
        String id = windowInfo.getId();
        String menuId = "menu-config." + id;
        String localeMsg = messages.getMessage(menuId);
        String title = menuId.equals(localeMsg) ? id : id + " ( " + localeMsg + " )";
        screens.put(title, id);
    }
    screenIdField.setOptionsMap(screens);
}
Also used : LinkedHashMap(java.util.LinkedHashMap) WindowInfo(io.jmix.ui.WindowInfo)

Aggregations

WindowInfo (io.jmix.ui.WindowInfo)24 WindowManager (com.haulmont.cuba.gui.WindowManager)7 WindowConfig (io.jmix.ui.WindowConfig)7 HashMap (java.util.HashMap)6 Element (org.dom4j.Element)5 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)3 Window (io.jmix.ui.component.Window)3 AppBeans (com.haulmont.cuba.core.global.AppBeans)2 WindowManagerProvider (com.haulmont.cuba.gui.WindowManagerProvider)2 Filter (com.haulmont.cuba.gui.components.Filter)2 Window (com.haulmont.cuba.gui.components.Window)2 AddConditionWindow (com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow)2 ConditionDescriptorsTreeBuilderAPI (com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilderAPI)2 AbstractConditionDescriptor (com.haulmont.cuba.gui.components.filter.descriptor.AbstractConditionDescriptor)2 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)2 Screens (io.jmix.ui.Screens)2 NotFoundScreen (io.jmix.ui.app.navigation.notfoundwindow.NotFoundScreen)2 Fragment (io.jmix.ui.component.Fragment)2 FragmentImplementation (io.jmix.ui.component.impl.FragmentImplementation)2 FrameImplementation (io.jmix.ui.component.impl.FrameImplementation)2