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