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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations