Search in sources :

Example 6 with Screens

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

the class LocalizedTaskWrapper method done.

@Override
public void done(V result) {
    Screens screens = getScreenContext().getScreens();
    screens.remove(screen);
    try {
        wrappedTask.done(result);
    } catch (Exception ex) {
        // we should show exception messages immediately
        showExecutionError(ex);
    }
}
Also used : Screens(com.haulmont.cuba.gui.Screens)

Example 7 with Screens

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

the class MainScreen method onAfterShow.

@Subscribe
protected void onAfterShow(AfterShowEvent event) {
    Screens screens = UiControllerUtils.getScreenContext(this).getScreens();
    getBeanLocator().get(ScreenTools.class).openDefaultScreen(screens);
}
Also used : ScreenTools(com.haulmont.cuba.gui.ScreenTools) Screens(com.haulmont.cuba.gui.Screens)

Example 8 with Screens

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

the class App method removeAllWindows.

/**
 * Removes all windows in the given {@code uis}.
 *
 * @param uis {@link AppUI} instances
 */
protected void removeAllWindows(List<AppUI> uis) {
    log.debug("Closing all windows in all UIs");
    try {
        for (AppUI ui : uis) {
            Screens screens = ui.getScreens();
            if (screens != null) {
                Screen rootScreen = screens.getOpenedScreens().getRootScreenOrNull();
                if (rootScreen != null) {
                    screens.removeAll();
                    screens.remove(rootScreen);
                }
            }
            // also remove all native Vaadin windows, that is not under CUBA control
            Window[] windows = ui.getWindows().toArray(new Window[0]);
            for (com.vaadin.ui.Window win : windows) {
                ui.removeWindow(win);
            }
            List<Notification> notifications = ui.getExtensions().stream().filter(ext -> ext instanceof Notification).map(ext -> (Notification) ext).collect(Collectors.toList());
            notifications.forEach(Notification::close);
        }
    } catch (Throwable e) {
        log.error("Error closing all windows", e);
    }
}
Also used : Window(com.vaadin.ui.Window) RootWindow(com.haulmont.cuba.gui.components.RootWindow) java.util(java.util) WebAuthConfig(com.haulmont.cuba.web.auth.WebAuthConfig) OperationResult(com.haulmont.cuba.gui.util.OperationResult) UI(com.vaadin.ui.UI) LoggerFactory(org.slf4j.LoggerFactory) CubaIcon(com.haulmont.cuba.gui.icons.CubaIcon) Screen(com.haulmont.cuba.gui.screen.Screen) Window(com.vaadin.ui.Window) LoginException(com.haulmont.cuba.security.global.LoginException) Icons(com.haulmont.cuba.gui.icons.Icons) StringUtils(org.apache.commons.lang3.StringUtils) Dialogs(com.haulmont.cuba.gui.Dialogs) com.haulmont.cuba.core.global(com.haulmont.cuba.core.global) IllegalConcurrentAccessException(com.haulmont.cuba.gui.executors.IllegalConcurrentAccessException) UserSession(com.haulmont.cuba.security.global.UserSession) Inject(javax.inject.Inject) ThemeConstantsRepository(com.haulmont.cuba.gui.theme.ThemeConstantsRepository) UnknownOperationResult(com.haulmont.cuba.gui.util.UnknownOperationResult) AbstractClientConnector(com.vaadin.server.AbstractClientConnector) Future(java.util.concurrent.Future) AppLog(com.haulmont.cuba.web.log.AppLog) Notification(com.vaadin.ui.Notification) SettingsClient(com.haulmont.cuba.gui.settings.SettingsClient) Screens(com.haulmont.cuba.gui.Screens) UserSessionService(com.haulmont.cuba.security.app.UserSessionService) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) OpenMode(com.haulmont.cuba.gui.screen.OpenMode) Nullable(javax.annotation.Nullable) Frame(com.haulmont.cuba.gui.components.Frame) RootWindow(com.haulmont.cuba.gui.components.RootWindow) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) Logger(org.slf4j.Logger) ExceptionHandlers(com.haulmont.cuba.web.exception.ExceptionHandlers) com.haulmont.cuba.web.sys(com.haulmont.cuba.web.sys) ControllerUtils(com.haulmont.cuba.web.controllers.ControllerUtils) UserManagementService(com.haulmont.cuba.security.app.UserManagementService) Collectors(java.util.stream.Collectors) NoUserSessionException(com.haulmont.cuba.security.global.NoUserSessionException) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) VaadinSession(com.vaadin.server.VaadinSession) WebSettingsClient(com.haulmont.cuba.web.settings.WebSettingsClient) ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) SessionHeartbeatEvent(com.haulmont.cuba.web.security.events.SessionHeartbeatEvent) DialogAction(com.haulmont.cuba.gui.components.DialogAction) Action(com.haulmont.cuba.gui.components.Action) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) Screen(com.haulmont.cuba.gui.screen.Screen) Window(com.vaadin.ui.Window) Screens(com.haulmont.cuba.gui.Screens) Notification(com.vaadin.ui.Notification)

Example 9 with Screens

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

the class WebScreenFacet method createScreen.

protected S createScreen(FrameOwner frameOwner) {
    S screen;
    Screens screens = UiControllerUtils.getScreenContext(frameOwner).getScreens();
    if (screenId != null) {
        screen = (S) screens.create(screenId, launchMode, getScreenOptions());
    } else if (screenClass != null) {
        screen = screens.create(screenClass, launchMode, getScreenOptions());
    } else {
        throw new DevelopmentException("Unable to open screen because no screen id or screen class are specified");
    }
    return screen;
}
Also used : Screens(com.haulmont.cuba.gui.Screens) DevelopmentException(com.haulmont.cuba.core.global.DevelopmentException)

Example 10 with Screens

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

the class ScreenBuilderProcessor method buildScreen.

@SuppressWarnings("unchecked")
public Screen buildScreen(ScreenBuilder builder) {
    FrameOwner origin = builder.getOrigin();
    Screens screens = getScreenContext(origin).getScreens();
    Screen screen;
    if (builder instanceof ScreenClassBuilder) {
        ScreenClassBuilder screenClassBuilder = (ScreenClassBuilder) builder;
        Class screenClass = screenClassBuilder.getScreenClass();
        if (screenClass == null) {
            throw new IllegalArgumentException("Screen class is not set");
        }
        screen = screens.create(screenClass, builder.getLaunchMode(), builder.getOptions());
        @SuppressWarnings("unchecked") Consumer<AfterScreenCloseEvent> closeListener = screenClassBuilder.getCloseListener();
        if (closeListener != null) {
            screen.addAfterCloseListener(new AfterCloseListenerAdapter(closeListener));
        }
    } else {
        if (builder.getScreenId() == null) {
            throw new IllegalArgumentException("Screen id is not set");
        }
        screen = screens.create(builder.getScreenId(), builder.getLaunchMode(), builder.getOptions());
    }
    return screen;
}
Also used : FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) Screen(com.haulmont.cuba.gui.screen.Screen) Screens(com.haulmont.cuba.gui.Screens)

Aggregations

Screens (com.haulmont.cuba.gui.Screens)15 Screen (com.haulmont.cuba.gui.screen.Screen)5 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)4 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)3 HashMap (java.util.HashMap)3 Dialogs (com.haulmont.cuba.gui.Dialogs)2 WindowManager (com.haulmont.cuba.gui.WindowManager)2 DialogAction (com.haulmont.cuba.gui.components.DialogAction)2 RootWindow (com.haulmont.cuba.gui.components.RootWindow)2 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)2 ContainerDataUnit (com.haulmont.cuba.gui.components.data.meta.ContainerDataUnit)2 IllegalConcurrentAccessException (com.haulmont.cuba.gui.executors.IllegalConcurrentAccessException)2 Icons (com.haulmont.cuba.gui.icons.Icons)2 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)2 UnknownOperationResult (com.haulmont.cuba.gui.util.UnknownOperationResult)2 LoginException (com.haulmont.cuba.security.global.LoginException)2 NoUserSessionException (com.haulmont.cuba.security.global.NoUserSessionException)2 MetaClass (com.haulmont.chile.core.model.MetaClass)1 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)1 DevelopmentException (com.haulmont.cuba.core.global.DevelopmentException)1