Search in sources :

Example 6 with Window

use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.

the class DesktopWindowManager method dispose.

/**
 * Release resources right before throwing away this WindowManager instance.
 */
public void dispose() {
    for (WindowOpenInfo openInfo : windowOpenMode.values()) {
        if (openInfo.getOpenMode() == OpenMode.DIALOG) {
            JDialog dialog = (JDialog) openInfo.getData();
            dialog.setVisible(false);
        }
    }
    if (isMainWindowManager) {
        // Stop background tasks
        WatchDog watchDog = AppBeans.get(WatchDog.NAME);
        watchDog.stopTasks();
    }
    // Dispose windows
    for (Window window : windowOpenMode.keySet()) {
        Frame frame = window.getFrame();
        if (frame instanceof Component.Disposable)
            ((Component.Disposable) frame).dispose();
    }
    tabs.clear();
    windowOpenMode.clear();
    stacks.clear();
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow) TopLevelFrame(com.haulmont.cuba.desktop.TopLevelFrame) Frame(com.haulmont.cuba.gui.components.Frame) DesktopAbstractComponent(com.haulmont.cuba.desktop.gui.components.DesktopAbstractComponent) Component(com.haulmont.cuba.gui.components.Component)

Example 7 with Window

use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.

the class DesktopWindowManager method getLastDialogWindow.

@Nullable
public DialogWindow getLastDialogWindow() {
    List<Window> openedWindows = new ArrayList<>(windowOpenMode.keySet());
    if (openedWindows.size() > 0) {
        Window w = openedWindows.get(openedWindows.size() - 1);
        WindowOpenInfo mode = windowOpenMode.get(w);
        if (mode.getOpenMode() == OpenMode.DIALOG && mode.getData() instanceof DialogWindow) {
            return (DialogWindow) mode.getData();
        }
    }
    return null;
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow) Nullable(javax.annotation.Nullable)

Example 8 with Window

use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.

the class DesktopWindowManager method addWindowData.

public void addWindowData(Window window, Object windowData, OpenType openType) {
    WindowOpenInfo openInfo = new WindowOpenInfo(window, openType.getOpenMode());
    openInfo.setData(windowData);
    if (window instanceof Window.Wrapper) {
        Window wrappedWindow = ((Window.Wrapper) window).getWrappedWindow();
        windowOpenMode.put(wrappedWindow, openInfo);
    } else {
        windowOpenMode.put(window, openInfo);
    }
    addShortcuts(window, openType);
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow)

Example 9 with Window

use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.

the class DesktopWindowManager method showTabPopup.

public void showTabPopup(MouseEvent e) {
    JComponent tabHeaderComponent = (JComponent) e.getComponent();
    int tabIndex = getTabIndex(tabHeaderComponent);
    JComponent tabContent = (JComponent) tabsPane.getComponentAt(tabIndex);
    WindowBreadCrumbs windowBreadCrumbs = tabs.get(tabContent);
    Window window = windowBreadCrumbs.getCurrentWindow();
    JPopupMenu popupMenu = createWindowPopupMenu(window);
    if (popupMenu.getComponentCount() > 0) {
        popupMenu.show(tabHeaderComponent, e.getX(), e.getY());
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow)

Example 10 with Window

use of com.haulmont.cuba.gui.components.Window in project cuba by cuba-platform.

the class DesktopWindowManager method showWindow.

@Override
protected void showWindow(final Window window, final String caption, final String description, OpenType openType, boolean multipleOpen) {
    OpenType targetOpenType = openType.copy();
    // for backward compatibility only
    copyDialogParamsToOpenType(targetOpenType);
    overrideOpenTypeParams(targetOpenType, window.getDialogOptions());
    boolean forciblyDialog = false;
    boolean addWindowData = true;
    if (targetOpenType.getOpenMode() != OpenMode.DIALOG && hasModalWindow()) {
        targetOpenType.setOpenMode(OpenMode.DIALOG);
        forciblyDialog = true;
    }
    if (targetOpenType.getOpenMode() == OpenMode.THIS_TAB && tabs.size() == 0) {
        targetOpenType.setOpenMode(OpenMode.NEW_TAB);
    }
    window.setCaption(caption);
    window.setDescription(description);
    Object windowData;
    switch(targetOpenType.getOpenMode()) {
        case NEW_TAB:
            if (!isMainWindowManager) {
                addWindowData = false;
                showInMainWindowManager(window, caption, description, targetOpenType, multipleOpen);
                windowData = null;
            } else {
                Integer hashCode = getWindowHashCode(window);
                JComponent tab;
                if (hashCode != null && !multipleOpen && (tab = findTab(hashCode)) != null) {
                    WindowBreadCrumbs oldBreadCrumbs = tabs.get(tab);
                    final Window oldWindow = oldBreadCrumbs.getCurrentWindow();
                    selectWindowTab(((Window.Wrapper) oldBreadCrumbs.getCurrentWindow()).getWrappedWindow());
                    final int finalTabPosition = getTabPosition(tab);
                    oldWindow.closeAndRun(MAIN_MENU_ACTION_ID, new Runnable() {

                        @Override
                        public void run() {
                            showWindow(window, caption, description, OpenType.NEW_TAB, false);
                            Window wrappedWindow = window;
                            if (window instanceof Window.Wrapper) {
                                wrappedWindow = ((Window.Wrapper) window).getWrappedWindow();
                            }
                            if (finalTabPosition >= 0 && finalTabPosition < tabsPane.getComponentCount() - 1) {
                                moveWindowTab(wrappedWindow, finalTabPosition);
                            }
                        }
                    });
                    return;
                } else {
                    windowData = showWindowNewTab(window, caption, description, null);
                }
            }
            break;
        case THIS_TAB:
            windowData = showWindowThisTab(window, caption, description);
            break;
        case DIALOG:
            windowData = showWindowDialog(window, caption, description, targetOpenType, forciblyDialog);
            break;
        case NEW_WINDOW:
            addWindowData = false;
            windowData = showNewWindow(window, targetOpenType, caption);
            break;
        default:
            throw new UnsupportedOperationException();
    }
    if (addWindowData) {
        addWindowData(window, windowData, targetOpenType);
    }
    afterShowWindow(window);
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow)

Aggregations

Window (com.haulmont.cuba.gui.components.Window)54 DesktopWindow (com.haulmont.cuba.desktop.gui.components.DesktopWindow)15 WebWindow (com.haulmont.cuba.web.gui.WebWindow)13 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)10 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)6 WindowBreadCrumbs (com.haulmont.cuba.web.sys.WindowBreadCrumbs)6 ParamsMap (com.haulmont.bali.util.ParamsMap)5 Component (com.haulmont.cuba.gui.components.Component)5 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)5 Component (com.vaadin.ui.Component)5 Entity (com.haulmont.cuba.core.entity.Entity)4 TopLevelFrame (com.haulmont.cuba.desktop.TopLevelFrame)4 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)4 CssLayout (com.vaadin.ui.CssLayout)4 Pair (com.haulmont.bali.datastruct.Pair)3 WindowManager (com.haulmont.cuba.gui.WindowManager)3 Action (com.haulmont.cuba.gui.components.Action)3 ButtonsPanel (com.haulmont.cuba.gui.components.ButtonsPanel)3 Frame (com.haulmont.cuba.gui.components.Frame)3 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)3