Search in sources :

Example 31 with Window

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

the class DesktopWindowManager method isCloseWithShortcutPrevented.

protected boolean isCloseWithShortcutPrevented(Window currentWindow) {
    DesktopWindow desktopWindow = (DesktopWindow) ComponentsHelper.getWindowImplementation(currentWindow);
    if (desktopWindow != null) {
        Window.BeforeCloseWithShortcutEvent event = new Window.BeforeCloseWithShortcutEvent(desktopWindow);
        desktopWindow.fireBeforeCloseWithShortcut(event);
        return event.isClosePrevented();
    }
    return false;
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow)

Example 32 with Window

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

the class DesktopWindowManager method checkModificationsAndCloseAll.

public void checkModificationsAndCloseAll(final Runnable runIfOk, @Nullable final Runnable runIfCancel) {
    boolean modified = false;
    for (Window window : getOpenWindows()) {
        if (!disableSavingScreenHistory) {
            screenHistorySupport.saveScreenHistory(window, windowOpenMode.get(window).getOpenMode());
        }
        recursiveFramesClose = true;
        try {
            if (window instanceof WrappedWindow && ((WrappedWindow) window).getWrapper() != null) {
                ((WrappedWindow) window).getWrapper().saveSettings();
            } else {
                window.saveSettings();
            }
        } finally {
            recursiveFramesClose = false;
        }
        if (window.getDsContext() != null && window.getDsContext().isModified()) {
            modified = true;
        }
    }
    disableSavingScreenHistory = true;
    if (modified) {
        showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("discardChangesOnClose"), MessageType.WARNING, new Action[] { new com.haulmont.cuba.gui.components.AbstractAction(messages.getMainMessage("closeApplication")) {

            @Override
            public void actionPerform(com.haulmont.cuba.gui.components.Component component) {
                if (runIfOk != null)
                    runIfOk.run();
            }

            @Override
            public String getIcon() {
                return "icons/ok.png";
            }
        }, new com.haulmont.cuba.gui.components.AbstractAction(messages.getMainMessage("actions.Cancel"), Status.PRIMARY) {

            @Override
            public void actionPerform(com.haulmont.cuba.gui.components.Component component) {
                if (runIfCancel != null)
                    runIfCancel.run();
            }

            @Override
            public String getIcon() {
                return "icons/cancel.png";
            }
        } });
    } else {
        runIfOk.run();
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) AbstractAction(com.haulmont.cuba.gui.components.AbstractAction) Component(com.haulmont.cuba.gui.components.Component)

Example 33 with Window

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

the class DesktopWindowManager method cleanupAfterModalDialogClosed.

protected void cleanupAfterModalDialogClosed(@Nullable Window closingWindow) {
    WindowOpenInfo previous = null;
    for (Iterator<Window> it = windowOpenMode.keySet().iterator(); it.hasNext(); ) {
        Window w = it.next();
        // Check if there is a modal window opened before the current
        WindowOpenInfo mode = windowOpenMode.get(w);
        if (w != closingWindow && mode.getOpenMode() == OpenMode.DIALOG) {
            previous = mode;
        }
        // If there are windows opened after the current, close them
        if (w == closingWindow && it.hasNext()) {
            close(it.next());
            break;
        }
    }
    if (previous == null) {
        frame.activate();
    } else if (previous.getData() instanceof DialogWindow) {
        ((DialogWindow) previous.getData()).enableWindow();
    } else if (previous.getData() instanceof JDialog) {
        ((JDialog) previous.getData()).requestFocus();
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DesktopWindow(com.haulmont.cuba.desktop.gui.components.DesktopWindow)

Example 34 with Window

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

the class App method afterLoggedIn.

/**
 * Perform actions after success login
 */
protected void afterLoggedIn() {
    UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
    User user = sessionSource.getUserSession().getUser();
    // Change password on logon
    if (Boolean.TRUE.equals(user.getChangePasswordAtNextLogon())) {
        mainFrame.deactivate("");
        final DesktopWindowManager wm = mainFrame.getWindowManager();
        for (Window window : wm.getOpenWindows()) {
            window.setEnabled(false);
        }
        WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
        WindowInfo changePasswordDialog = windowConfig.getWindowInfo("sec$User.changePassword");
        Window changePasswordWindow = wm.openWindow(changePasswordDialog, OpenType.DIALOG.closeable(false), ParamsMap.of("cancelEnabled", false));
        changePasswordWindow.addCloseListener(actionId -> {
            for (Window window : wm.getOpenWindows()) {
                window.setEnabled(true);
            }
        });
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) User(com.haulmont.cuba.security.entity.User) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 35 with Window

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

the class MenuBuilder method build.

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

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