Search in sources :

Example 36 with Window

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

the class SideMenuBuilder method build.

protected void build(SideMenu menu, List<MenuItem> rootItems) {
    Window window = ComponentsHelper.getWindowImplementation(menu);
    if (window == null) {
        throw new IllegalStateException("SideMenu is not belong to Window");
    }
    for (MenuItem menuItem : rootItems) {
        // AppMenu does not support separators
        if (menuItem.isPermitted(session) && !menuItem.isSeparator()) {
            createMenuBarItem(window, menu, menuItem);
        }
    }
    removeExtraSeparators(menu);
}
Also used : Window(com.haulmont.cuba.gui.components.Window) MenuItem(com.haulmont.cuba.gui.config.MenuItem)

Example 37 with Window

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

the class MainTabSheetActionHandler method analyzeLayout.

protected void analyzeLayout(Object target) {
    Window window = findWindow((Layout) target);
    if (window != null) {
        LayoutAnalyzer analyzer = new LayoutAnalyzer();
        List<LayoutTip> tipsList = analyzer.analyze(window);
        if (tipsList.isEmpty()) {
            window.showNotification("No layout problems found", Frame.NotificationType.HUMANIZED);
        } else {
            window.openWindow("layoutAnalyzer", WindowManager.OpenType.DIALOG, ParamsMap.of("tipsList", tipsList));
        }
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) LayoutTip(com.haulmont.cuba.gui.app.core.dev.LayoutTip) LayoutAnalyzer(com.haulmont.cuba.gui.app.core.dev.LayoutAnalyzer)

Example 38 with Window

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

the class WebWindowManager method createCloseShortcut.

public ShortcutListener createCloseShortcut(Window.TopLevelWindow topLevelWindow) {
    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination combination = KeyCombination.create(closeShortcut);
    return new ShortcutListener("onClose", combination.getKey().getCode(), KeyCombination.Modifier.codes(combination.getModifiers())) {

        @Override
        public void handleAction(Object sender, Object target) {
            WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(topLevelWindow));
            if (workArea.getState() != AppWorkArea.State.WINDOW_CONTAINER) {
                return;
            }
            if (workArea.getMode() == Mode.TABBED) {
                TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
                if (tabSheet != null) {
                    Layout layout = (Layout) tabSheet.getSelectedTab();
                    if (layout != null) {
                        tabSheet.focus();
                        WindowBreadCrumbs breadCrumbs = tabs.get(layout);
                        if (!canWindowBeClosed(breadCrumbs.getCurrentWindow())) {
                            return;
                        }
                        if (isCloseWithShortcutPrevented(breadCrumbs.getCurrentWindow())) {
                            return;
                        }
                        if (stacks.get(breadCrumbs).empty()) {
                            final Component previousTab = tabSheet.getPreviousTab(layout);
                            if (previousTab != null) {
                                breadCrumbs.getCurrentWindow().closeAndRun(Window.CLOSE_ACTION_ID, () -> tabSheet.setSelectedTab(previousTab));
                            } else {
                                breadCrumbs.getCurrentWindow().close(Window.CLOSE_ACTION_ID);
                            }
                        } else {
                            breadCrumbs.getCurrentWindow().close(Window.CLOSE_ACTION_ID);
                        }
                    }
                }
            } else {
                Iterator<WindowBreadCrumbs> it = tabs.values().iterator();
                if (it.hasNext()) {
                    Window currentWindow = it.next().getCurrentWindow();
                    if (!isCloseWithShortcutPrevented(currentWindow)) {
                        ui.focus();
                        currentWindow.close(Window.CLOSE_ACTION_ID);
                    }
                }
            }
        }
    };
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) ShortcutListener(com.vaadin.event.ShortcutListener) CssLayout(com.vaadin.ui.CssLayout) WindowBreadCrumbs(com.haulmont.cuba.web.sys.WindowBreadCrumbs) WebAbstractComponent(com.haulmont.cuba.web.gui.components.WebAbstractComponent) Component(com.vaadin.ui.Component)

Example 39 with Window

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

the class WebWindowManager method showWindowNewTab.

protected Component showWindowNewTab(final Window window, final boolean multipleOpen) {
    getDialogParams().reset();
    final WindowBreadCrumbs breadCrumbs = createWindowBreadCrumbs(window);
    breadCrumbs.addListener(new WindowBreadCrumbs.Listener() {

        @Override
        public void windowClick(final Window window) {
            Runnable op = new Runnable() {

                @Override
                public void run() {
                    Window currentWindow = breadCrumbs.getCurrentWindow();
                    if (currentWindow != null && window != currentWindow) {
                        if (!isCloseWithCloseButtonPrevented(currentWindow)) {
                            currentWindow.closeAndRun(Window.CLOSE_ACTION_ID, this);
                        }
                    }
                }
            };
            op.run();
        }
    });
    breadCrumbs.addWindow(window);
    // noinspection UnnecessaryLocalVariable
    final Layout layout = createNewTabLayout(window, multipleOpen, breadCrumbs);
    return layout;
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) CssLayout(com.vaadin.ui.CssLayout) WindowBreadCrumbs(com.haulmont.cuba.web.sys.WindowBreadCrumbs)

Example 40 with Window

use of com.haulmont.cuba.gui.components.Window 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)

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