use of com.haulmont.cuba.gui.navigation.NavigationState in project cuba by cuba-platform.
the class AppUI method init.
@Override
protected void init(VaadinRequest request) {
log.trace("Initializing UI {}", this);
NavigationState requestedState = getUrlRouting().getState();
try {
this.testMode = globalConfig.getTestMode();
this.performanceTestMode = globalConfig.getPerformanceTestMode();
// init error handlers
setErrorHandler(this);
// do not grab focus
setTabIndex(-1);
initJsLibraries();
initInternalComponents();
if (!App.isBound()) {
App app = createApplication();
app.init(request.getLocale());
this.app = app;
publishAppInitializedEvent(app);
} else {
this.app = App.getInstance();
}
// check that middleware is accessible before calling other services
trustedClientService.healthCheck();
Connection connection = app.getConnection();
if (connection != null && !isUserSessionAlive(connection)) {
connection.logout();
Notification.show(messages.getMainMessage("app.sessionExpiredCaption"), messages.getMainMessage("app.sessionExpiredMessage"), Notification.Type.HUMANIZED_MESSAGE);
}
if (connection != null) {
setUserSession(connection.getSession());
}
setupUI();
} catch (Exception e) {
log.error("Unable to init ui", e);
// unable to connect to middle ware
showCriticalExceptionMessage(e);
return;
}
processExternalLink(request, requestedState);
}
use of com.haulmont.cuba.gui.navigation.NavigationState in project cuba by cuba-platform.
the class WebUrlRouting method getStateMark.
protected String getStateMark(Screen screen) {
WebWindow webWindow = (WebWindow) screen.getWindow();
NavigationState resolvedState = webWindow.getResolvedState();
return resolvedState != null ? resolvedState.getStateMark() : NavigationState.EMPTY.getStateMark();
}
use of com.haulmont.cuba.gui.navigation.NavigationState in project cuba by cuba-platform.
the class WebUrlRouting method buildNavState.
protected NavigationState buildNavState(Screen screen, Map<String, String> urlParams) {
NavigationState state;
if (screen.getWindow() instanceof RootWindow) {
state = new NavigationState(getRoute(screen), "", "", urlParams);
} else {
String rootRoute = getRoute(ui.getScreens().getOpenedScreens().getRootScreen());
String stateMark = getStateMark(screen);
String nestedRoute = buildNestedRoute(screen);
Map<String, String> params = buildParams(screen, urlParams);
state = new NavigationState(rootRoute, stateMark, nestedRoute, params);
}
return state;
}
use of com.haulmont.cuba.gui.navigation.NavigationState in project cuba by cuba-platform.
the class RedirectHandler method redirect.
public void redirect() {
UrlHandlingMode urlHandlingMode = webConfig.getUrlHandlingMode();
if (UrlHandlingMode.URL_ROUTES != urlHandlingMode) {
log.debug("RedirectHandler is disabled for {} URL handling mode", urlHandlingMode);
return;
}
String nestedRoute = redirect.getNestedRoute();
Map<String, String> params = redirect.getParams();
String redirectTarget = null;
if (StringUtils.isNotEmpty(nestedRoute)) {
redirectTarget = nestedRoute;
} else if (MapUtils.isNotEmpty(params) && params.containsKey(REDIRECT_PARAM)) {
redirectTarget = params.remove(REDIRECT_PARAM);
}
if (StringUtils.isEmpty(redirectTarget)) {
return;
}
NavigationState currentState = ui.getUrlRouting().getState();
NavigationState newState = new NavigationState(currentState.getRoot(), "", redirectTarget, params);
ui.getUrlChangeHandler().getScreenNavigator().handleScreenNavigation(newState);
redirect = null;
}
use of com.haulmont.cuba.gui.navigation.NavigationState in project cuba by cuba-platform.
the class WebAppWorkArea method reflectTabChangeToUrl.
protected void reflectTabChangeToUrl(boolean userOriginated) {
if (!userOriginated) {
return;
}
Component selectedTab = tabbedContainer.getTabSheetBehaviour().getSelectedTab();
if (selectedTab == null) {
return;
}
Window selectedWindow = ((TabWindowContainer) selectedTab).getBreadCrumbs().getCurrentWindow();
WebWindow webWindow = (WebWindow) selectedWindow;
NavigationState resolvedState = webWindow.getResolvedState();
if (resolvedState != null) {
int stateMark = generateUrlStateMark();
NavigationState newState = new NavigationState(resolvedState.getRoot(), String.valueOf(stateMark), resolvedState.getNestedRoute(), resolvedState.getParams());
webWindow.setResolvedState(newState);
Screen screen = selectedWindow.getFrameOwner();
UrlRouting urlRouting = UiControllerUtils.getScreenContext(screen).getUrlRouting();
urlRouting.pushState(screen, newState.getParams());
}
}
Aggregations