Search in sources :

Example 26 with Screen

use of com.haulmont.cuba.gui.screen.Screen in project cuba by cuba-platform.

the class ScreenNavigationHandler method createScreen.

protected Screen createScreen(NavigationState requestedState, String screenRoute, WindowInfo windowInfo, AppUI ui) {
    Screen screen;
    if (isEditor(windowInfo)) {
        screen = createEditor(windowInfo, screenRoute, requestedState, ui);
    } else {
        OpenMode openMode = getScreenOpenMode(requestedState.getNestedRoute(), screenRoute, ui);
        screen = ui.getScreens().create(windowInfo.getId(), openMode);
    }
    return screen;
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) OpenMode(com.haulmont.cuba.gui.screen.OpenMode)

Example 27 with Screen

use of com.haulmont.cuba.gui.screen.Screen in project cuba by cuba-platform.

the class ScreenNavigationHandler method createEditor.

protected Screen createEditor(WindowInfo windowInfo, String screenRoute, NavigationState requestedState, AppUI ui) {
    Map<String, Object> options = createEditorScreenOptions(windowInfo, requestedState, ui);
    if (MapUtils.isEmpty(options)) {
        log.info("Unable to load entity for editor: '{}'. " + "Subscribe for 'UrlParamsChangedEvent' to obtain its serialized id", windowInfo.getId());
    }
    Screen editor;
    OpenMode openMode = getScreenOpenMode(requestedState.getNestedRoute(), screenRoute, ui);
    if (isLegacyScreen(windowInfo.getControllerClass())) {
        editor = ui.getScreens().create(windowInfo.getId(), openMode, new MapScreenOptions(options));
    } else {
        editor = ui.getScreens().create(windowInfo.getId(), openMode);
    }
    if (MapUtils.isNotEmpty(options)) {
        Entity entity = (Entity) options.get(WindowParams.ITEM.name());
        // noinspection unchecked
        ((EditorScreen<Entity>) editor).setEntityToEdit(entity);
    }
    return editor;
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) Screen(com.haulmont.cuba.gui.screen.Screen) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) MapScreenOptions(com.haulmont.cuba.gui.screen.MapScreenOptions) OpenMode(com.haulmont.cuba.gui.screen.OpenMode)

Example 28 with Screen

use of com.haulmont.cuba.gui.screen.Screen in project cuba by cuba-platform.

the class ScreenNavigationHandler method openScreen.

protected void openScreen(NavigationState requestedState, String screenRoute, WindowInfo windowInfo, AppUI ui) {
    UrlChangeHandler urlChangeHandler = ui.getUrlChangeHandler();
    if (!urlChangeHandler.isPermittedToNavigate(requestedState, windowInfo)) {
        return;
    }
    Screen screen = createScreen(requestedState, screenRoute, windowInfo, ui);
    if (screen == null) {
        log.info("Unable to open screen '{}' for requested route '{}'", windowInfo.getId(), requestedState.getNestedRoute());
        urlChangeHandler.revertNavigationState();
        return;
    }
    if (requestedState.getNestedRoute().endsWith(screenRoute)) {
        Map<String, String> params = requestedState.getParams();
        if (MapUtils.isNotEmpty(params)) {
            UiControllerUtils.fireEvent(screen, UrlParamsChangedEvent.class, new UrlParamsChangedEvent(screen, params));
        }
        ((WebWindow) screen.getWindow()).setResolvedState(requestedState);
    } else {
        ((WebWindow) screen.getWindow()).setResolvedState(getNestedScreenState(screenRoute, requestedState));
    }
    screen.show();
}
Also used : UrlParamsChangedEvent(com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent) Screen(com.haulmont.cuba.gui.screen.Screen) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) UrlChangeHandler(com.haulmont.cuba.web.sys.navigation.UrlChangeHandler) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 29 with Screen

use of com.haulmont.cuba.gui.screen.Screen in project cuba by cuba-platform.

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 : java.util(java.util) PermissionType(com.haulmont.cuba.security.entity.PermissionType) LoggerFactory(org.slf4j.LoggerFactory) ParamsMap(com.haulmont.bali.util.ParamsMap) Screen(com.haulmont.cuba.gui.screen.Screen) StringUtils(org.apache.commons.lang3.StringUtils) MetaClass(com.haulmont.chile.core.model.MetaClass) Scope(org.springframework.context.annotation.Scope) com.haulmont.cuba.core.global(com.haulmont.cuba.core.global) Inject(javax.inject.Inject) Pair(com.haulmont.bali.datastruct.Pair) UrlChangeHandler(com.haulmont.cuba.web.sys.navigation.UrlChangeHandler) AppUI(com.haulmont.cuba.web.AppUI) MapScreenOptions(com.haulmont.cuba.gui.screen.MapScreenOptions) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) OpenMode(com.haulmont.cuba.gui.screen.OpenMode) Nullable(javax.annotation.Nullable) LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) MapUtils(org.apache.commons.collections4.MapUtils) Order(org.springframework.core.annotation.Order) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) UrlIdSerializer(com.haulmont.cuba.web.sys.navigation.UrlIdSerializer) Logger(org.slf4j.Logger) MetaProperty(com.haulmont.chile.core.model.MetaProperty) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) Collectors(java.util.stream.Collectors) NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) NEW_ENTITY_ID(com.haulmont.cuba.web.sys.WebUrlRouting.NEW_ENTITY_ID) WindowParams(com.haulmont.cuba.gui.WindowParams) Component(org.springframework.stereotype.Component) UrlParamsChangedEvent(com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent) EntityOp(com.haulmont.cuba.security.entity.EntityOp) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindow(com.haulmont.cuba.web.gui.WebWindow) EditorTypeExtractor(com.haulmont.cuba.web.sys.navigation.EditorTypeExtractor) Entity(com.haulmont.cuba.core.entity.Entity) UiControllerUtils(com.haulmont.cuba.gui.screen.UiControllerUtils) UrlChangeHandler(com.haulmont.cuba.web.sys.navigation.UrlChangeHandler) Pair(com.haulmont.bali.datastruct.Pair) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 30 with Screen

use of com.haulmont.cuba.gui.screen.Screen in project cuba by cuba-platform.

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 = ((WebWindow) rootScreen.getWindow()).getResolvedState().getRoot();
    return !StringUtils.equals(rootRoute, requestedState.getRoot());
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)

Aggregations

Screen (com.haulmont.cuba.gui.screen.Screen)66 WebWindow (com.haulmont.cuba.web.gui.WebWindow)18 NotFoundScreen (com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)11 GuiDialogWindow (com.haulmont.cuba.web.gui.components.WebDialogWindow.GuiDialogWindow)10 WebTabWindow (com.haulmont.cuba.web.gui.components.WebTabWindow)10 EditorScreen (com.haulmont.cuba.gui.screen.EditorScreen)9 NavigationState (com.haulmont.cuba.gui.navigation.NavigationState)8 Nullable (javax.annotation.Nullable)8 Screens (com.haulmont.cuba.gui.Screens)6 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)6 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)6 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)5 AppUI (com.haulmont.cuba.web.AppUI)5 Entity (com.haulmont.cuba.core.entity.Entity)4 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)4 SelectHandlerAdapter (com.haulmont.cuba.gui.components.compatibility.SelectHandlerAdapter)4 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)4 OpenMode (com.haulmont.cuba.gui.screen.OpenMode)4 ScreenFragment (com.haulmont.cuba.gui.screen.ScreenFragment)4 UiControllerUtils (com.haulmont.cuba.gui.screen.UiControllerUtils)4