use of com.haulmont.cuba.gui.screen.Screen in project cuba by cuba-platform.
the class RootNavigationHandler method handle404.
protected void handle404(String route, AppUI ui) {
RootWindow topWindow = ui.getTopLevelWindow();
Screen rootScreen = topWindow != null ? topWindow.getFrameOwner() : null;
if (rootScreen instanceof Window.HasWorkArea) {
MapScreenOptions options = new MapScreenOptions(ParamsMap.of("requestedRoute", route));
ui.getScreens().create(NotFoundScreen.class, OpenMode.NEW_TAB, options).show();
} else {
ui.getNotifications().create(Notifications.NotificationType.TRAY).withCaption(messages.formatMainMessage("navigation.screenNotFound", route)).show();
}
}
use of com.haulmont.cuba.gui.screen.Screen 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.screen.Screen in project cuba by cuba-platform.
the class OpenMainScreenTest method openMainScreen.
@Test
public void openMainScreen() {
Screen screen = environment.getScreens().create(MainScreen.class, OpenMode.ROOT).show();
assertNotNull(screen);
assertTrue(screen instanceof MainScreen);
}
use of com.haulmont.cuba.gui.screen.Screen in project cuba by cuba-platform.
the class UrlChangeHandler method revertNavigationState.
public void revertNavigationState() {
Screen screen = findActiveScreenByState(ui.getHistory().getNow());
if (screen == null) {
screen = getActiveScreen();
}
urlTools.replaceState(getResolvedState(screen).asRoute(), ui);
}
use of com.haulmont.cuba.gui.screen.Screen in project cuba by cuba-platform.
the class UrlChangeHandler method redirect.
public void redirect(NavigationState navigationState) {
String loginScreenId = webConfig.getLoginScreenId();
Screen loginScreen = ui.getScreens().create(loginScreenId, OpenMode.ROOT);
loginScreen.show();
RedirectHandler redirectHandler = beanLocator.getPrototype(RedirectHandler.NAME, ui);
redirectHandler.schedule(navigationState);
setRedirectHandler(redirectHandler);
}
Aggregations