use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebScreens method showThisTabWindow.
protected void showThisTabWindow(Screen screen) {
WebAppWorkArea workArea = getConfiguredWorkArea();
workArea.switchTo(AppWorkArea.State.WINDOW_CONTAINER);
TabWindowContainer windowContainer;
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
windowContainer = (TabWindowContainer) tabSheet.getSelectedTab();
} else {
windowContainer = (TabWindowContainer) workArea.getSingleWindowContainer().getWindowContainer();
}
if (windowContainer == null || windowContainer.getBreadCrumbs() == null) {
throw new IllegalStateException("BreadCrumbs not found");
}
WindowBreadCrumbs breadCrumbs = windowContainer.getBreadCrumbs();
Window currentWindow = breadCrumbs.getCurrentWindow();
windowContainer.removeComponent(currentWindow.unwrapComposition(Layout.class));
Window newWindow = screen.getWindow();
com.vaadin.ui.Component newWindowComposition = newWindow.unwrapComposition(com.vaadin.ui.Component.class);
windowContainer.addComponent(newWindowComposition);
breadCrumbs.addWindow(newWindow);
WebWindow webWindow = (WebWindow) screen.getWindow();
webWindow.setResolvedState(createOrUpdateState(webWindow.getResolvedState(), getConfiguredWorkArea().generateUrlStateMark()));
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
String tabId = tabSheet.getTab(windowContainer);
TabWindow tabWindow = (TabWindow) newWindow;
String formattedCaption = tabWindow.formatTabCaption();
String formattedDescription = tabWindow.formatTabDescription();
tabSheet.setTabCaption(tabId, formattedCaption);
if (!Objects.equals(formattedCaption, formattedDescription)) {
tabSheet.setTabDescription(tabId, formattedDescription);
} else {
tabSheet.setTabDescription(tabId, null);
}
tabSheet.setTabIcon(tabId, iconResolver.getIconResource(newWindow.getIcon()));
tabSheet.setTabClosable(tabId, newWindow.isCloseable());
ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(tabWindow.getContentSwitchMode().name());
tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
} else {
windowContainer.markAsDirtyRecursive();
}
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class UrlChangeHandler 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.web.gui.WebWindow in project cuba by cuba-platform.
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();
WebWindow window = (WebWindow) 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 com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class ScreenNavigationHandler method handle404.
protected void handle404(String route, AppUI ui) {
MapScreenOptions options = new MapScreenOptions(ParamsMap.of("requestedRoute", route));
NotFoundScreen notFoundScreen = ui.getScreens().create(NotFoundScreen.class, OpenMode.NEW_TAB, options);
NavigationState state = new NavigationState(ui.getUrlRouting().getState().getRoot(), "", route, Collections.emptyMap());
((WebWindow) notFoundScreen.getWindow()).setResolvedState(state);
notFoundScreen.show();
}
Aggregations