use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebWindowManager method closeWindow.
protected void closeWindow(Window window, WindowOpenInfo openInfo) {
if (!disableSavingScreenHistory) {
screenHistorySupport.saveScreenHistory(window, openInfo.getOpenMode());
}
WebWindow webWindow = (WebWindow) window;
webWindow.stopTimers();
switch(openInfo.getOpenMode()) {
case DIALOG:
{
final CubaWindow cubaDialogWindow = (CubaWindow) openInfo.getData();
cubaDialogWindow.forceClose();
fireListeners(window, tabs.size() != 0);
break;
}
case NEW_WINDOW:
case NEW_TAB:
{
final Layout layout = (Layout) openInfo.getData();
layout.removeComponent(WebComponentsHelper.getComposition(window));
WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
tabSheet.silentCloseTabAndSelectPrevious(layout);
tabSheet.removeComponent(layout);
} else {
VerticalLayout singleLayout = workArea.getSingleWindowContainer();
singleLayout.removeComponent(layout);
}
WindowBreadCrumbs windowBreadCrumbs = tabs.get(layout);
if (windowBreadCrumbs != null) {
windowBreadCrumbs.clearListeners();
windowBreadCrumbs.removeWindow();
}
tabs.remove(layout);
stacks.remove(windowBreadCrumbs);
fireListeners(window, !tabs.isEmpty());
if (tabs.isEmpty() && app.getConnection().isConnected()) {
workArea.switchTo(AppWorkArea.State.INITIAL_LAYOUT);
}
break;
}
case THIS_TAB:
{
final Layout layout = (Layout) openInfo.getData();
final WindowBreadCrumbs breadCrumbs = tabs.get(layout);
if (breadCrumbs == null) {
throw new IllegalStateException("Unable to close screen: breadCrumbs not found");
}
breadCrumbs.removeWindow();
Window currentWindow = breadCrumbs.getCurrentWindow();
if (!getStack(breadCrumbs).empty()) {
Pair<Window, Integer> entry = getStack(breadCrumbs).pop();
putToWindowMap(entry.getFirst(), entry.getSecond());
}
Component component = WebComponentsHelper.getComposition(currentWindow);
component.setSizeFull();
WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));
layout.removeComponent(WebComponentsHelper.getComposition(window));
if (app.getConnection().isConnected()) {
layout.addComponent(component);
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
String tabId = tabSheet.getTab(layout);
String formattedCaption = formatTabCaption(currentWindow.getCaption(), currentWindow.getDescription());
tabSheet.setTabCaption(tabId, formattedCaption);
String formattedDescription = formatTabDescription(currentWindow.getCaption(), currentWindow.getDescription());
if (!Objects.equals(formattedCaption, formattedDescription)) {
tabSheet.setTabDescription(tabId, formattedDescription);
} else {
tabSheet.setTabDescription(tabId, null);
}
tabSheet.setTabIcon(tabId, iconResolver.getIconResource(currentWindow.getIcon()));
ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(currentWindow.getContentSwitchMode().name());
tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
}
}
fireListeners(window, !tabs.isEmpty());
if (tabs.isEmpty() && app.getConnection().isConnected()) {
workArea.switchTo(AppWorkArea.State.INITIAL_LAYOUT);
}
break;
}
default:
{
throw new UnsupportedOperationException();
}
}
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebUrlRouting method updateState.
protected void updateState(Screen screen, Map<String, String> urlParams, boolean pushState) {
NavigationState currentState = getState();
NavigationState newState = buildNavState(screen, urlParams);
// do not push copy-pasted requested state to avoid double state pushing into browser history
if (!pushState || externalNavigation(currentState, newState) || isNotFoundScreen(screen)) {
urlTools.replaceState(newState.asRoute(), ui);
lastHistoryOperation = CubaUIConstants.HISTORY_REPLACE_OP;
} else {
urlTools.pushState(newState.asRoute(), ui);
lastHistoryOperation = CubaUIConstants.HISTORY_PUSH_OP;
}
((WebWindow) screen.getWindow()).setResolvedState(newState);
if (pushState) {
ui.getHistory().forward(newState);
} else {
ui.getHistory().replace(newState);
}
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebScreens method changeUrl.
protected void changeUrl(Screen screen) {
WebWindow webWindow = (WebWindow) screen.getWindow();
Map<String, String> params = webWindow.getResolvedState() != null ? webWindow.getResolvedState().getParams() : Collections.emptyMap();
ui.getUrlRouting().pushState(screen, params);
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebAppWorkArea method moveFocus.
protected void moveFocus(TabSheetBehaviour tabSheet, String tabId) {
TabWindowContainer windowContainer = (TabWindowContainer) tabSheet.getTabComponent(tabId);
Window window = windowContainer.getBreadCrumbs().getCurrentWindow();
if (window != null) {
boolean focused = false;
String focusComponentId = window.getFocusComponent();
if (focusComponentId != null) {
com.haulmont.cuba.gui.components.Component focusComponent = window.getComponent(focusComponentId);
if (focusComponent instanceof com.haulmont.cuba.gui.components.Component.Focusable && focusComponent.isEnabledRecursive() && focusComponent.isVisibleRecursive()) {
((com.haulmont.cuba.gui.components.Component.Focusable) focusComponent).focus();
focused = true;
}
}
if (!focused && window instanceof Window.Wrapper) {
Window.Wrapper wrapper = (Window.Wrapper) window;
focused = ((WebWindow) wrapper.getWrappedWindow()).findAndFocusChildComponent();
}
if (!focused) {
tabSheet.focus();
}
}
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebScreens method showDialogWindow.
protected void showDialogWindow(Screen screen) {
DialogWindow window = (DialogWindow) screen.getWindow();
WebAppWorkArea workArea = getConfiguredWorkAreaOrNull();
if (workArea != null) {
WebWindow webWindow = (WebWindow) screen.getWindow();
webWindow.setResolvedState(createOrUpdateState(webWindow.getResolvedState(), getConfiguredWorkArea().generateUrlStateMark()));
}
window.withUnwrappedComposition(CubaWindow.class, vWindow -> {
vWindow.setErrorHandler(ui);
String cubaId = "dialog_" + window.getId();
if (ui.isTestMode()) {
vWindow.setCubaId(cubaId);
}
if (ui.isPerformanceTestMode()) {
vWindow.setId(ui.getTestIdManager().getTestId(cubaId));
}
if (hasModalWindow()) {
// force modal
window.setModal(true);
}
ui.addWindow(vWindow);
});
}
Aggregations