use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebWindowManager method closeAll.
/**
* Close all screens in the main window (browser tab) this WindowManager belongs to.
*/
public void closeAll() {
List<Map.Entry<Window, WindowOpenInfo>> entries = new ArrayList<>(windowOpenMode.entrySet());
for (int i = entries.size() - 1; i >= 0; i--) {
WebWindow window = (WebWindow) entries.get(i).getKey();
if (window instanceof WebWindow.Editor) {
((WebWindow.Editor) window).releaseLock();
}
closeWindow(window, entries.get(i).getValue());
}
disableSavingScreenHistory = false;
windowOpenMode.clear();
windows.clear();
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebWindowManager method isCloseWithCloseButtonPrevented.
protected boolean isCloseWithCloseButtonPrevented(Window currentWindow) {
WebWindow webWindow = (WebWindow) ComponentsHelper.getWindowImplementation(currentWindow);
if (webWindow != null) {
BeforeCloseWithCloseButtonEvent event = new BeforeCloseWithCloseButtonEvent(webWindow);
webWindow.fireBeforeCloseWithCloseButton(event);
return event.isClosePrevented();
}
return false;
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebWindowManager method isCloseWithShortcutPrevented.
protected boolean isCloseWithShortcutPrevented(Window currentWindow) {
WebWindow webWindow = (WebWindow) ComponentsHelper.getWindowImplementation(currentWindow);
if (webWindow != null) {
BeforeCloseWithShortcutEvent event = new BeforeCloseWithShortcutEvent(webWindow);
webWindow.fireBeforeCloseWithShortcut(event);
return event.isClosePrevented();
}
return false;
}
use of com.haulmont.cuba.web.gui.WebWindow 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());
}
}
use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.
the class WebScreens method createNewTabLayout.
protected void createNewTabLayout(Screen screen) {
WindowBreadCrumbs breadCrumbs = createWindowBreadCrumbs(screen);
breadCrumbs.setWindowNavigateHandler(this::handleWindowBreadCrumbsNavigate);
breadCrumbs.addWindow(screen.getWindow());
WebWindow webWindow = (WebWindow) screen.getWindow();
webWindow.setResolvedState(createOrUpdateState(webWindow.getResolvedState(), getConfiguredWorkArea().generateUrlStateMark()));
TabWindowContainer windowContainer = new TabWindowContainerImpl();
windowContainer.setPrimaryStyleName("c-app-window-wrap");
windowContainer.setSizeFull();
windowContainer.setBreadCrumbs(breadCrumbs);
windowContainer.addComponent(breadCrumbs);
Window window = screen.getWindow();
com.vaadin.ui.Component windowComposition = window.unwrapComposition(com.vaadin.ui.Component.class);
windowContainer.addComponent(windowComposition);
WebAppWorkArea workArea = getConfiguredWorkArea();
if (workArea.getMode() == Mode.TABBED) {
windowContainer.addStyleName("c-app-tabbed-window");
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
String tabId = "tab_" + uuidSource.createUuid();
tabSheet.addTab(windowContainer, tabId);
if (ui.isTestMode()) {
String id = "tab_" + window.getId();
tabSheet.setTabTestId(tabId, ui.getTestIdManager().getTestId(id));
tabSheet.setTabCubaId(tabId, id);
}
TabWindow tabWindow = (TabWindow) window;
String windowContentSwitchMode = tabWindow.getContentSwitchMode().name();
ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(windowContentSwitchMode);
tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
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(window.getIcon()));
tabSheet.setTabClosable(tabId, window.isCloseable());
tabSheet.setTabCloseHandler(windowContainer, this::handleTabWindowClose);
tabSheet.setSelectedTab(windowContainer);
} else {
windowContainer.addStyleName("c-app-single-window");
CubaSingleModeContainer mainLayout = workArea.getSingleWindowContainer();
if (mainLayout.getWindowContainer() != null) {
// remove all windows from single stack
TabWindowContainer oldWindowContainer = (TabWindowContainer) mainLayout.getWindowContainer();
Deque<Window> windows = oldWindowContainer.getBreadCrumbs().getWindows();
Iterator<Window> iterator = windows.descendingIterator();
while (iterator.hasNext()) {
Window oldWindow = iterator.next();
remove(oldWindow.getFrameOwner());
}
// after last window closed we need to switch back to window container
workArea.switchTo(AppWorkArea.State.WINDOW_CONTAINER);
}
mainLayout.setWindowContainer(windowContainer);
}
}
Aggregations