Search in sources :

Example 1 with HasWorkArea

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

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

Aggregations

HasWorkArea (com.haulmont.cuba.gui.components.Window.HasWorkArea)2 AppWorkArea (com.haulmont.cuba.gui.components.mainwindow.AppWorkArea)2 Screen (com.haulmont.cuba.gui.screen.Screen)2 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)2 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1