Search in sources :

Example 6 with Screen

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

the class WindowLoader method loadCrossFieldValidate.

@Deprecated
protected void loadCrossFieldValidate(Window resultComponent, Element element) {
    Screen controller = resultComponent.getFrameOwner();
    if (controller instanceof AbstractWindow) {
        String crossFieldValidate = element.attributeValue("crossFieldValidate");
        if (isNotEmpty(crossFieldValidate)) {
            if (controller instanceof Window.Editor) {
                Window.Editor editor = (Window.Editor) controller;
                editor.setCrossFieldValidate(parseBoolean(crossFieldValidate));
            } else {
                throw new GuiDevelopmentException("Window should extend Window.Editor to use crossFieldValidate attribute", context);
            }
        }
    }
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) GuiDevelopmentException(com.haulmont.cuba.gui.GuiDevelopmentException)

Example 7 with Screen

use of com.haulmont.cuba.gui.screen.Screen 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 8 with Screen

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

the class WebScreenTools method openDefaultScreen.

@Override
public void openDefaultScreen(Screens screens) {
    String defaultScreenId = webConfig.getDefaultScreenId();
    if (webConfig.getUserCanChooseDefaultScreen()) {
        String userDefaultScreen = userSettingService.loadSetting(ClientType.WEB, "userDefaultScreen");
        defaultScreenId = StringUtils.isEmpty(userDefaultScreen) ? defaultScreenId : userDefaultScreen;
    }
    if (StringUtils.isEmpty(defaultScreenId)) {
        return;
    }
    if (!windowConfig.hasWindow(defaultScreenId)) {
        log.info("Can't find default screen: {}", defaultScreenId);
        return;
    }
    Screen screen = screens.create(defaultScreenId, OpenMode.NEW_TAB);
    if (screen instanceof EditorScreen) {
        ((EditorScreen) screen).setEntityToEdit(getEntityToEdit(defaultScreenId));
    }
    screen.show();
    Window window = screen.getWindow();
    WebWindow webWindow;
    if (window instanceof Window.Wrapper) {
        webWindow = (WebWindow) ((Window.Wrapper) window).getWrappedWindow();
    } else {
        webWindow = (WebWindow) window;
    }
    webWindow.setDefaultScreenWindow(true);
    if (!webConfig.getDefaultScreenCanBeClosed()) {
        window.setCloseable(false);
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) EditorScreen(com.haulmont.cuba.gui.screen.EditorScreen) Screen(com.haulmont.cuba.gui.screen.Screen) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 9 with Screen

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

the class AttributeAccessSupport method applyAttributeAccess.

/**
 * Apply attribute access rules to a given frame. It means that all components bound to datasources will adjust
 * their visible/read-only/required state according to security state of entity instances contained in the datasources.
 *
 * @param frameOwner frame or screen
 * @param reset      whether to reset the components to the default state specified by role-based security and model
 *                   annotations. If you invoke this method to apply attribute access to already opened screen, set
 *                   the parameter to true, but keep in mind that previous programmatic changes in the components
 *                   visible/read-only/required state will be lost.
 */
public void applyAttributeAccess(FrameOwner frameOwner, boolean reset) {
    ComponentContainer componentContainer;
    if (frameOwner instanceof Screen) {
        componentContainer = ((Screen) frameOwner).getWindow();
    } else {
        componentContainer = (Window) frameOwner;
    }
    ComponentsHelper.walkComponents(componentContainer, (component, name) -> visitComponent(component, reset));
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) ComponentContainer(com.haulmont.cuba.gui.components.ComponentContainer)

Example 10 with Screen

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

the class WebSuggestionField method showSuggestions.

protected void showSuggestions(List<V> suggestions, boolean userOriginated) {
    FrameOwner frameOwner = getFrame().getFrameOwner();
    Collection<Screen> dialogScreens = UiControllerUtils.getScreenContext(frameOwner).getScreens().getOpenedScreens().getDialogScreens();
    Screen lastDialog = null;
    for (Screen dialogScreen : dialogScreens) {
        lastDialog = dialogScreen;
    }
    if (frameOwner instanceof ScreenFragment) {
        frameOwner = ComponentsHelper.getScreen((ScreenFragment) frameOwner);
    }
    if (lastDialog == null || Objects.equals(frameOwner, lastDialog)) {
        component.showSuggestions(suggestions, userOriginated);
    }
}
Also used : FrameOwner(com.haulmont.cuba.gui.screen.FrameOwner) ScreenFragment(com.haulmont.cuba.gui.screen.ScreenFragment) Screen(com.haulmont.cuba.gui.screen.Screen)

Aggregations

Screen (com.haulmont.cuba.gui.screen.Screen)66 WebWindow (com.haulmont.cuba.web.gui.WebWindow)18 NotFoundScreen (com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)11 GuiDialogWindow (com.haulmont.cuba.web.gui.components.WebDialogWindow.GuiDialogWindow)10 WebTabWindow (com.haulmont.cuba.web.gui.components.WebTabWindow)10 EditorScreen (com.haulmont.cuba.gui.screen.EditorScreen)9 NavigationState (com.haulmont.cuba.gui.navigation.NavigationState)8 Nullable (javax.annotation.Nullable)8 Screens (com.haulmont.cuba.gui.Screens)6 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)6 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)6 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)5 AppUI (com.haulmont.cuba.web.AppUI)5 Entity (com.haulmont.cuba.core.entity.Entity)4 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)4 SelectHandlerAdapter (com.haulmont.cuba.gui.components.compatibility.SelectHandlerAdapter)4 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)4 OpenMode (com.haulmont.cuba.gui.screen.OpenMode)4 ScreenFragment (com.haulmont.cuba.gui.screen.ScreenFragment)4 UiControllerUtils (com.haulmont.cuba.gui.screen.UiControllerUtils)4