Search in sources :

Example 11 with WebWindow

use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.

the class UrlChangeHandler method restoreState.

public void restoreState() {
    if (notSuitableMode()) {
        log.debug("UrlChangeHandler is disabled for '{}' URL handling mode", webConfig.getUrlHandlingMode());
        return;
    }
    NavigationState currentState = urlTools.parseState(ui.getPage().getUriFragment());
    if (currentState == null || currentState == NavigationState.EMPTY) {
        RootWindow topLevelWindow = ui.getTopLevelWindow();
        if (topLevelWindow instanceof WebWindow) {
            NavigationState topScreenState = ((WebWindow) topLevelWindow).getResolvedState();
            urlTools.replaceState(topScreenState.asRoute(), ui);
        }
    }
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) RootWindow(com.haulmont.cuba.gui.components.RootWindow) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 12 with WebWindow

use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.

the class WindowBreadCrumbs method isCloseWithCloseButtonPrevented.

protected boolean isCloseWithCloseButtonPrevented(Window currentWindow) {
    WebWindow webWindow = (WebWindow) currentWindow;
    if (webWindow != null) {
        Window.BeforeCloseEvent event = new Window.BeforeCloseEvent(webWindow, CloseOriginType.CLOSE_BUTTON);
        webWindow.fireBeforeClose(event);
        return event.isClosePrevented();
    }
    return false;
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 13 with WebWindow

use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.

the class WebWindowManager method moveFocus.

protected void moveFocus(TabSheetBehaviour tabSheet, String tabId) {
    // noinspection SuspiciousMethodCalls
    Window window = tabs.get(tabSheet.getTabComponent(tabId)).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 != null && focusComponent.isEnabled() && focusComponent.isVisible()) {
                focusComponent.requestFocus();
                focused = true;
            }
        }
        if (!focused && window instanceof Window.Wrapper) {
            Window.Wrapper wrapper = (Window.Wrapper) window;
            focused = ((WebWindow) wrapper.getWrappedWindow()).findAndFocusChildComponent();
            if (!focused) {
                tabSheet.focus();
            }
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components)

Example 14 with WebWindow

use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.

the class WebWindowManager method setWindowCaption.

@Override
public void setWindowCaption(Window window, String caption, String description) {
    Window webWindow = window;
    if (window instanceof Window.Wrapper) {
        webWindow = ((Window.Wrapper) window).getWrappedWindow();
    }
    window.setCaption(caption);
    window.setDebugId(description);
    WindowOpenInfo openInfo = windowOpenMode.get(webWindow);
    String formattedCaption;
    if (openInfo != null && (openInfo.getOpenMode() == OpenMode.NEW_TAB || openInfo.getOpenMode() == OpenMode.NEW_WINDOW || openInfo.getOpenMode() == OpenMode.THIS_TAB)) {
        formattedCaption = formatTabCaption(caption, description);
    } else {
        formattedCaption = formatTabDescription(caption, description);
    }
    if (openInfo != null) {
        if (openInfo.getOpenMode() == OpenMode.DIALOG) {
            com.vaadin.ui.Window dialog = (com.vaadin.ui.Window) openInfo.getData();
            dialog.setCaption(formattedCaption);
        } else {
            if (getConfiguredWorkArea(createWorkAreaContext(window)).getMode() == Mode.SINGLE) {
                return;
            }
            Component tabContent = (Component) openInfo.getData();
            if (tabContent == null) {
                return;
            }
            TabSheetBehaviour tabSheet = getConfiguredWorkArea(createWorkAreaContext(window)).getTabbedWindowContainer().getTabSheetBehaviour();
            String tabId = tabSheet.getTab(tabContent);
            if (tabId == null) {
                return;
            }
            tabSheet.setTabCaption(tabId, formattedCaption);
            String formattedDescription = formatTabDescription(caption, description);
            if (!Objects.equals(formattedDescription, formattedCaption)) {
                tabSheet.setTabDescription(tabId, formattedDescription);
            } else {
                tabSheet.setTabDescription(tabId, null);
            }
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) com.haulmont.cuba.web.toolkit.ui(com.haulmont.cuba.web.toolkit.ui) com.vaadin.ui(com.vaadin.ui) WebAbstractComponent(com.haulmont.cuba.web.gui.components.WebAbstractComponent) Component(com.vaadin.ui.Component)

Example 15 with WebWindow

use of com.haulmont.cuba.web.gui.WebWindow in project cuba by cuba-platform.

the class WebWindowManager method closeAllTabbedWindowsExcept.

public void closeAllTabbedWindowsExcept(@Nullable ComponentContainer keepOpened) {
    boolean modified = false;
    List<WebWindow> windowsToClose = new ArrayList<>();
    WindowBreadCrumbs keepOpenedCrumbs = tabs.get(keepOpened);
    Frame keepOpenedFrame = keepOpenedCrumbs != null ? keepOpenedCrumbs.getCurrentWindow().getFrame() : null;
    for (Window window : getOpenWindows()) {
        if (!canWindowBeClosed(window)) {
            continue;
        }
        OpenMode openMode = windowOpenMode.get(window).getOpenMode();
        WindowBreadCrumbs windowBreadCrumbs = tabs.get(windowOpenMode.get(window).getData());
        Window currentWindow = (windowBreadCrumbs != null && window != windowBreadCrumbs.getCurrentWindow()) ? windowBreadCrumbs.getCurrentWindow() : window;
        if (window.getFrame() == keepOpenedFrame || openMode == OpenMode.DIALOG || keepOpenedCrumbs == windowBreadCrumbs || isCloseWithCloseButtonPrevented(currentWindow))
            continue;
        if (window.getDsContext() != null && window.getDsContext().isModified()) {
            modified = true;
        }
        windowsToClose.add((WebWindow) window);
    }
    disableSavingScreenHistory = true;
    if (modified) {
        showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("discardChangesInTabs"), MessageType.WARNING, new Action[] { new AbstractAction(messages.getMainMessage("closeTabs")) {

            {
                icon = icons.get(CubaIcon.DIALOG_OK);
            }

            @Override
            public void actionPerform(com.haulmont.cuba.gui.components.Component component) {
                closeTabsForce(windowsToClose);
            }
        }, new DialogAction(Type.CANCEL, Status.PRIMARY) });
    } else {
        closeTabsForce(windowsToClose);
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) BelongToFrame(com.haulmont.cuba.gui.components.Component.BelongToFrame) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) WebWindow(com.haulmont.cuba.web.gui.WebWindow) WindowBreadCrumbs(com.haulmont.cuba.web.sys.WindowBreadCrumbs)

Aggregations

WebWindow (com.haulmont.cuba.web.gui.WebWindow)24 NavigationState (com.haulmont.cuba.gui.navigation.NavigationState)8 Window (com.haulmont.cuba.gui.components.Window)6 Screen (com.haulmont.cuba.gui.screen.Screen)6 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)4 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)3 UrlParamsChangedEvent (com.haulmont.cuba.gui.navigation.UrlParamsChangedEvent)3 NotFoundScreen (com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)3 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)3 GuiDialogWindow (com.haulmont.cuba.web.gui.components.WebDialogWindow.GuiDialogWindow)3 UrlChangeHandler (com.haulmont.cuba.web.sys.navigation.UrlChangeHandler)3 Component (com.vaadin.ui.Component)3 com.haulmont.cuba.gui (com.haulmont.cuba.gui)2 EditorScreen (com.haulmont.cuba.gui.screen.EditorScreen)2 WebTabWindow (com.haulmont.cuba.web.gui.components.WebTabWindow)2 WindowBreadCrumbs (com.haulmont.cuba.web.sys.WindowBreadCrumbs)2 CssLayout (com.vaadin.ui.CssLayout)2 Pair (com.haulmont.bali.datastruct.Pair)1 UrlRouting (com.haulmont.cuba.gui.UrlRouting)1 BelongToFrame (com.haulmont.cuba.gui.components.Component.BelongToFrame)1