Search in sources :

Example 36 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

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()));
        ((WebWindow) screen.getWindow()).setResolvedState(requestedState);
    }
    screen.show();
    return !hasNestedRoute;
}
Also used : UrlParamsChangedEvent(com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent) Screen(com.haulmont.cuba.gui.screen.Screen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) UrlChangeHandler(com.haulmont.cuba.web.sys.navigation.UrlChangeHandler) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 37 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class ScreensHelper method getAvailableScreensMap.

protected Map<String, Object> getAvailableScreensMap(Class entityClass, ScreenType filterScreenType) {
    String key = getScreensCacheKey(entityClass.getName(), getUserLocale(), filterScreenType);
    Map<String, Object> screensMap = availableScreensCache.get(key);
    if (screensMap != null) {
        return screensMap;
    }
    Collection<WindowInfo> windowInfoCollection = windowConfig.getWindows();
    screensMap = new TreeMap<>();
    Set<String> visitedWindowIds = new HashSet<>();
    for (WindowInfo windowInfo : windowInfoCollection) {
        String windowId = windowInfo.getId();
        // just skip for now, we assume all versions of screen can operate with the same entity
        if (visitedWindowIds.contains(windowId)) {
            continue;
        }
        String src = windowInfo.getTemplate();
        if (StringUtils.isNotEmpty(src)) {
            try {
                Element windowElement = getWindowElement(src);
                if (windowElement != null) {
                    if (isEntityAvailable(windowElement, entityClass, filterScreenType)) {
                        String caption = getScreenCaption(windowElement, src);
                        caption = getDetailedScreenCaption(caption, windowId);
                        screensMap.put(caption, windowId);
                    }
                } else {
                    screensMap.put(windowId, windowId);
                }
            } catch (FileNotFoundException e) {
                log.error(e.getMessage());
            }
        }
        visitedWindowIds.add(windowId);
    }
    screensMap = Collections.unmodifiableMap(screensMap);
    cacheScreens(key, screensMap);
    return screensMap;
}
Also used : Element(org.dom4j.Element) FileNotFoundException(java.io.FileNotFoundException) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 38 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class ScreensHelper method getDefaultBrowseScreen.

@Nullable
public WindowInfo getDefaultBrowseScreen(MetaClass metaClass) {
    WindowInfo browseWindow = windowConfig.findWindowInfo(windowConfig.getBrowseScreenId(metaClass));
    if (browseWindow != null && userSessionSource.getUserSession().isScreenPermitted(browseWindow.getId())) {
        return browseWindow;
    }
    WindowInfo lookupWindow = windowConfig.findWindowInfo(windowConfig.getLookupScreenId(metaClass));
    if (lookupWindow != null && userSessionSource.getUserSession().isScreenPermitted(lookupWindow.getId())) {
        return lookupWindow;
    }
    return null;
}
Also used : WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) Nullable(javax.annotation.Nullable)

Example 39 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class WindowDelegate method openFrame.

public Frame openFrame(Component parent, String windowAlias, Map<String, Object> params) {
    WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
    Frame wrappedFrame = ((Frame.Wrapper) wrapper).getWrappedFrame();
    return window.getWindowManager().openFrame(wrappedFrame, parent, windowInfo, params);
}
Also used : WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 40 with WindowInfo

use of com.haulmont.cuba.gui.config.WindowInfo in project cuba by cuba-platform.

the class WebFrame method openLookup.

@Override
public Window.Lookup openLookup(Class<? extends Entity> entityClass, Window.Lookup.Handler handler, WindowManager.OpenType openType, Map<String, Object> params) {
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    WindowInfo lookupScreen = windowConfig.getLookupScreen(entityClass);
    WebWindowManager wm = App.getInstance().getWindowManager();
    return wm.openLookup(lookupScreen, handler, openType, params);
}
Also used : WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindowManager(com.haulmont.cuba.web.WebWindowManager) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Aggregations

WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)74 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)43 WebWindowManager (com.haulmont.cuba.web.WebWindowManager)15 WindowManager (com.haulmont.cuba.gui.WindowManager)9 Element (org.dom4j.Element)8 Window (com.haulmont.cuba.gui.components.Window)7 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)5 HashMap (java.util.HashMap)5 Screens (com.haulmont.cuba.gui.Screens)3 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)3 LayoutLoader (com.haulmont.cuba.gui.xml.layout.LayoutLoader)3 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)2 DetachedFrame (com.haulmont.cuba.desktop.DetachedFrame)2 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)2 Notifications (com.haulmont.cuba.gui.Notifications)2 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)2 Filter (com.haulmont.cuba.gui.components.Filter)2 Fragment (com.haulmont.cuba.gui.components.Fragment)2 RelatedAction (com.haulmont.cuba.gui.components.actions.RelatedAction)2 AddConditionWindow (com.haulmont.cuba.gui.components.filter.addcondition.AddConditionWindow)2