use of io.jmix.ui.navigation.NavigationState in project jmix by jmix-framework.
the class AppWorkAreaImpl 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();
WindowImpl windowImpl = (WindowImpl) selectedWindow;
if (windowImpl != null) {
NavigationState resolvedState = windowImpl.getResolvedState();
if (resolvedState != null) {
int stateMark = generateUrlStateMark();
NavigationState newState = new NavigationState(resolvedState.getRoot(), String.valueOf(stateMark), resolvedState.getNestedRoute(), resolvedState.getParams());
windowImpl.setResolvedState(newState);
Screen screen = selectedWindow.getFrameOwner();
UrlRouting urlRouting = UiControllerUtils.getScreenContext(screen).getUrlRouting();
urlRouting.pushState(screen, newState.getParams());
}
}
}
use of io.jmix.ui.navigation.NavigationState in project jmix by jmix-framework.
the class ParamsNavigationHandler method doHandle.
@Override
public boolean doHandle(NavigationState requestedState, AppUI ui) {
UrlChangeHandler urlChangeHandler = ui.getUrlChangeHandler();
if (urlChangeHandler.isEmptyState(requestedState)) {
return false;
}
Screen screen = urlChangeHandler.getActiveScreen();
if (screen == null) {
log.debug("Unable to find a screen for state: '{}", requestedState);
return false;
}
Map<String, String> params = requestedState.getParams() != null ? requestedState.getParams() : Collections.emptyMap();
WindowImpl window = (WindowImpl) screen.getWindow();
NavigationState resolvedState = window.getResolvedState();
if (resolvedState == null || params.equals(resolvedState.getParams())) {
return false;
}
NavigationState newState = new NavigationState(resolvedState.getRoot(), resolvedState.getStateMark(), resolvedState.getNestedRoute(), params);
window.setResolvedState(newState);
UiControllerUtils.fireEvent(screen, UrlParamsChangedEvent.class, new UrlParamsChangedEvent(screen, params));
return true;
}
use of io.jmix.ui.navigation.NavigationState in project jmix by jmix-framework.
the class ScreensImpl method afterScreenRemove.
protected void afterScreenRemove(Screen screen) {
if (screen.getWindow() instanceof RootWindow) {
return;
}
Screen currentScreen = getAnyCurrentScreen();
if (currentScreen != null) {
NavigationState resolvedState = ((WindowImpl) currentScreen.getWindow()).getResolvedState();
if (resolvedState != null) {
String currentScreenRoute = resolvedState.asRoute();
urlTools.replaceState(currentScreenRoute, ui);
}
}
}
Aggregations