Search in sources :

Example 56 with Screen

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

the class WebScreens method getConfiguredWorkArea.

/**
 * @return workarea instance of the root screen
 * @throws IllegalStateException if there is no root screen or root screen does not have {@link AppWorkArea}
 */
@Nonnull
protected WebAppWorkArea getConfiguredWorkArea() {
    RootWindow topLevelWindow = ui.getTopLevelWindow();
    if (topLevelWindow == null) {
        throw new IllegalStateException("There is no root screen opened");
    }
    Screen controller = topLevelWindow.getFrameOwner();
    if (controller instanceof HasWorkArea) {
        AppWorkArea workArea = ((HasWorkArea) controller).getWorkArea();
        if (workArea != null) {
            return (WebAppWorkArea) workArea;
        }
    }
    throw new IllegalStateException("RootWindow does not have any configured work area");
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) HasWorkArea(com.haulmont.cuba.gui.components.Window.HasWorkArea) Screen(com.haulmont.cuba.gui.screen.Screen) WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) AppWorkArea(com.haulmont.cuba.gui.components.mainwindow.AppWorkArea) Nonnull(javax.annotation.Nonnull)

Example 57 with Screen

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

the class WebScreens method openEditor.

@SuppressWarnings({ "deprecation", "IncorrectCreateGuiComponent", "unchecked" })
@Override
public Window.Editor openEditor(WindowInfo windowInfo, Entity item, OpenType openType, @Nullable Map<String, Object> params, Datasource parentDs) {
    params = createParametersMap(windowInfo, params);
    params.put(WindowParams.ITEM.name(), item);
    MapScreenOptions options = new MapScreenOptions(params);
    Screen screen = createScreen(windowInfo, openType.getOpenMode(), options);
    applyOpenTypeParameters(screen.getWindow(), openType);
    EditorScreen editorScreen = (EditorScreen) screen;
    if (editorScreen instanceof AbstractEditor) {
        ((AbstractEditor) editorScreen).setParentDs(parentDs);
    }
    editorScreen.setEntityToEdit(item);
    show(screen);
    return screen instanceof Window.Editor ? (Window.Editor) screen : new ScreenEditorWrapper(screen);
}
Also used : GuiDialogWindow(com.haulmont.cuba.web.gui.components.WebDialogWindow.GuiDialogWindow) WebWindow(com.haulmont.cuba.web.gui.WebWindow) WebTabWindow(com.haulmont.cuba.web.gui.components.WebTabWindow) Screen(com.haulmont.cuba.gui.screen.Screen)

Example 58 with Screen

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

the class WebScreens method showFromNavigation.

@Override
public OperationResult showFromNavigation(Screen screen) {
    LaunchMode launchMode = screen.getWindow().getContext().getLaunchMode();
    if (launchMode == OpenMode.NEW_TAB || launchMode == OpenMode.NEW_WINDOW) {
        WebAppWorkArea workArea = getConfiguredWorkArea();
        if (workArea.getMode() == Mode.SINGLE) {
            Collection<Screen> currentBreadcrumbs = workArea.getCurrentBreadcrumbs();
            if (!currentBreadcrumbs.isEmpty()) {
                Iterator<Screen> iterator = currentBreadcrumbs.iterator();
                OperationResult result = OperationResult.success();
                // close all
                while (result.getStatus() == OperationResult.Status.SUCCESS && iterator.hasNext()) {
                    Screen previousScreen = iterator.next();
                    result = previousScreen.close(NAVIGATION_CLOSE_ACTION);
                }
                if (result.getStatus() != OperationResult.Status.SUCCESS) {
                    // if unsaved changes dialog is shown, we can continue later
                    return result.compose(() -> showFromNavigation(screen));
                }
            }
        } else {
            if (isMaxTabCountExceeded(screen)) {
                showTooManyOpenTabsMessage();
                return OperationResult.fail();
            }
            if (!UiControllerUtils.isMultipleOpen(screen)) {
                Screen sameScreen = getTabbedScreensStacks(workArea).filter(// never close non-top active screens
                windowStack -> windowStack.getBreadcrumbs().size() == 1).map(windowStack -> windowStack.getBreadcrumbs().iterator().next()).filter(tabScreen -> isAlreadyOpened(screen, tabScreen)).findFirst().orElse(null);
                if (sameScreen != null) {
                    OperationResult result = sameScreen.close(NAVIGATION_CLOSE_ACTION);
                    if (result.getStatus() != OperationResult.Status.SUCCESS) {
                        // if unsaved changes dialog is shown, we can continue later
                        return result.compose(() -> showFromNavigation(screen));
                    }
                }
            }
        }
    }
    return show(screen);
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) com.haulmont.cuba.gui.sys(com.haulmont.cuba.gui.sys) Datasource(com.haulmont.cuba.gui.data.Datasource) OperationResult(com.haulmont.cuba.gui.util.OperationResult) ReflectionHelper(com.haulmont.bali.util.ReflectionHelper) PermissionType(com.haulmont.cuba.security.entity.PermissionType) LoggerFactory(org.slf4j.LoggerFactory) CubaIcon(com.haulmont.cuba.gui.icons.CubaIcon) Settings(com.haulmont.cuba.gui.settings.Settings) Screen(com.haulmont.cuba.gui.screen.Screen) WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) Icons(com.haulmont.cuba.gui.icons.Icons) StringUtils(org.apache.commons.lang3.StringUtils) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) DatasourceImplementation(com.haulmont.cuba.gui.data.impl.DatasourceImplementation) IconResolver(com.haulmont.cuba.web.gui.icons.IconResolver) com.haulmont.cuba.gui(com.haulmont.cuba.gui) DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation) UrlTools(com.haulmont.cuba.web.sys.navigation.UrlTools) UIPerformanceLogger.createStopWatch(com.haulmont.cuba.gui.logging.UIPerformanceLogger.createStopWatch) AppUI(com.haulmont.cuba.web.AppUI) ScreenClosedEvent(com.haulmont.cuba.gui.screen.event.ScreenClosedEvent) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) Preconditions.checkNotNullArgument(com.haulmont.bali.util.Preconditions.checkNotNullArgument) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo) NotificationType(com.haulmont.cuba.gui.Notifications.NotificationType) LayoutLoader(com.haulmont.cuba.gui.xml.layout.LayoutLoader) com.haulmont.cuba.web.widgets(com.haulmont.cuba.web.widgets) Predicate(java.util.function.Predicate) GenericDataSupplier(com.haulmont.cuba.gui.data.impl.GenericDataSupplier) App(com.haulmont.cuba.web.App) SettingsImpl(com.haulmont.cuba.gui.settings.SettingsImpl) Collectors(java.util.stream.Collectors) WINDOW_CLOSE_ACTION(com.haulmont.cuba.gui.screen.FrameOwner.WINDOW_CLOSE_ACTION) WindowImplementation(com.haulmont.cuba.gui.components.sys.WindowImplementation) InvocationTargetException(java.lang.reflect.InvocationTargetException) ScreenXmlLoader(com.haulmont.cuba.gui.xml.layout.ScreenXmlLoader) MessageDialogBuilder(com.haulmont.cuba.gui.Dialogs.MessageDialogBuilder) WindowMode(com.haulmont.cuba.gui.components.DialogWindow.WindowMode) ComponentLoaderContext(com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext) ScreenDataImpl(com.haulmont.cuba.gui.model.impl.ScreenDataImpl) OptionDialogBuilder(com.haulmont.cuba.gui.Dialogs.OptionDialogBuilder) Stream(java.util.stream.Stream) WebConfig(com.haulmont.cuba.web.WebConfig) ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) ClientConfig(com.haulmont.cuba.client.ClientConfig) DataSupplier(com.haulmont.cuba.gui.data.DataSupplier) GuiDialogWindow(com.haulmont.cuba.web.gui.components.WebDialogWindow.GuiDialogWindow) java.util(java.util) CssLayout(com.vaadin.ui.CssLayout) com.haulmont.cuba.gui.screen.compatibility(com.haulmont.cuba.gui.screen.compatibility) com.haulmont.cuba.core.global(com.haulmont.cuba.core.global) HasWorkArea(com.haulmont.cuba.gui.components.Window.HasWorkArea) Inject(javax.inject.Inject) UnknownOperationResult(com.haulmont.cuba.gui.util.UnknownOperationResult) com.haulmont.cuba.gui.screen(com.haulmont.cuba.gui.screen) LegacyFragmentAdapter(com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter) DsContextLoader(com.haulmont.cuba.gui.xml.data.DsContextLoader) Nonnull(javax.annotation.Nonnull) DsContext(com.haulmont.cuba.gui.data.DsContext) Nullable(javax.annotation.Nullable) Mode(com.haulmont.cuba.web.widgets.CubaManagedTabSheet.Mode) ScreenOpenedEvent(com.haulmont.cuba.gui.screen.event.ScreenOpenedEvent) UserActionsLogger(com.haulmont.cuba.gui.logging.UserActionsLogger) AppWorkArea(com.haulmont.cuba.gui.components.mainwindow.AppWorkArea) NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) ComponentLoader(com.haulmont.cuba.gui.xml.layout.ComponentLoader) ConstructorUtils.invokeConstructor(org.apache.commons.lang3.reflect.ConstructorUtils.invokeConstructor) StopWatch(org.perf4j.StopWatch) Disposable(com.haulmont.cuba.gui.components.Component.Disposable) Layout(com.vaadin.ui.Layout) Mode(com.haulmont.cuba.gui.components.mainwindow.AppWorkArea.Mode) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) WebWindow(com.haulmont.cuba.web.gui.WebWindow) Element(org.dom4j.Element) SelectHandlerAdapter(com.haulmont.cuba.gui.components.compatibility.SelectHandlerAdapter) ScreenLifeCycle(com.haulmont.cuba.gui.logging.ScreenLifeCycle) ScreenProfilerImpl(com.haulmont.cuba.web.ScreenProfilerImpl) Entity(com.haulmont.cuba.core.entity.Entity) WebTabWindow(com.haulmont.cuba.web.gui.components.WebTabWindow) UiControllerUtils(com.haulmont.cuba.gui.screen.UiControllerUtils) Screen(com.haulmont.cuba.gui.screen.Screen) OperationResult(com.haulmont.cuba.gui.util.OperationResult) UnknownOperationResult(com.haulmont.cuba.gui.util.UnknownOperationResult)

Example 59 with Screen

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

the class WebScreens method getConfiguredWorkAreaOrNull.

@Nullable
protected WebAppWorkArea getConfiguredWorkAreaOrNull() {
    RootWindow topLevelWindow = ui.getTopLevelWindow();
    if (topLevelWindow == null) {
        throw new IllegalStateException("There is no root screen opened");
    }
    Screen controller = topLevelWindow.getFrameOwner();
    if (controller instanceof HasWorkArea) {
        AppWorkArea workArea = ((HasWorkArea) controller).getWorkArea();
        if (workArea != null) {
            return (WebAppWorkArea) workArea;
        }
    }
    return null;
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) HasWorkArea(com.haulmont.cuba.gui.components.Window.HasWorkArea) Screen(com.haulmont.cuba.gui.screen.Screen) WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) AppWorkArea(com.haulmont.cuba.gui.components.mainwindow.AppWorkArea) Nullable(javax.annotation.Nullable)

Example 60 with Screen

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

the class WebScreens method removeAll.

@Override
public void removeAll() {
    List<Screen> dialogScreens = getDialogScreensStream().collect(Collectors.toList());
    for (Screen dialogScreen : dialogScreens) {
        remove(dialogScreen);
    }
    WebAppWorkArea workArea = getConfiguredWorkAreaOrNull();
    if (workArea != null) {
        Collection<WindowStack> workAreaStacks = getWorkAreaStacks(workArea);
        for (WindowStack workAreaStack : workAreaStacks) {
            Collection<Screen> tabScreens = workAreaStack.getBreadcrumbs();
            for (Screen screen : tabScreens) {
                remove(screen);
            }
        }
    }
}
Also used : WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) 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