Search in sources :

Example 1 with RootWindow

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

the class WebUrlRouting method buildNavState.

protected NavigationState buildNavState(Screen screen, Map<String, String> urlParams) {
    NavigationState state;
    if (screen.getWindow() instanceof RootWindow) {
        state = new NavigationState(getRoute(screen), "", "", urlParams);
    } else {
        String rootRoute = getRoute(ui.getScreens().getOpenedScreens().getRootScreen());
        String stateMark = getStateMark(screen);
        String nestedRoute = buildNestedRoute(screen);
        Map<String, String> params = buildParams(screen, urlParams);
        state = new NavigationState(rootRoute, stateMark, nestedRoute, params);
    }
    return state;
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) RootWindow(com.haulmont.cuba.gui.components.RootWindow) Preconditions.checkNotEmptyString(com.haulmont.bali.util.Preconditions.checkNotEmptyString)

Example 2 with RootWindow

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

the class RootNavigationHandler method handle404.

protected void handle404(String route, AppUI ui) {
    RootWindow topWindow = ui.getTopLevelWindow();
    Screen rootScreen = topWindow != null ? topWindow.getFrameOwner() : null;
    if (rootScreen instanceof Window.HasWorkArea) {
        MapScreenOptions options = new MapScreenOptions(ParamsMap.of("requestedRoute", route));
        ui.getScreens().create(NotFoundScreen.class, OpenMode.NEW_TAB, options).show();
    } else {
        ui.getNotifications().create(Notifications.NotificationType.TRAY).withCaption(messages.formatMainMessage("navigation.screenNotFound", route)).show();
    }
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen) RootWindow(com.haulmont.cuba.gui.components.RootWindow) MapScreenOptions(com.haulmont.cuba.gui.screen.MapScreenOptions) NotFoundScreen(com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)

Example 3 with RootWindow

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

the class UrlChangeHandler method restoreState.

public void restoreState() {
    if (notSuitableMode()) {
        log.debug("UrlChangeHandler is disabled for '{}' URL handling mode", webConfig.getUrlHandlingMode());
        return;
    }
    NavigationState currentState = urlTools.parseState(ui.getPage().getUriFragment());
    if (currentState == null || currentState == NavigationState.EMPTY) {
        RootWindow topLevelWindow = ui.getTopLevelWindow();
        if (topLevelWindow instanceof WebWindow) {
            NavigationState topScreenState = ((WebWindow) topLevelWindow).getResolvedState();
            urlTools.replaceState(topScreenState.asRoute(), ui);
        }
    }
}
Also used : NavigationState(com.haulmont.cuba.gui.navigation.NavigationState) RootWindow(com.haulmont.cuba.gui.components.RootWindow) WebWindow(com.haulmont.cuba.web.gui.WebWindow)

Example 4 with RootWindow

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

the class App method logout.

/**
 * Try to perform logout. If there are unsaved changes in opened windows then logout will not be performed and
 * unsaved changes dialog will appear.
 *
 * @return operation result object
 */
public OperationResult logout() {
    AppUI ui = AppUI.getCurrent();
    try {
        RootWindow topLevelWindow = ui != null ? ui.getTopLevelWindow() : null;
        if (topLevelWindow != null) {
            Screens screens = ui.getScreens();
            if (!screens.hasUnsavedChanges()) {
                performStandardLogout(ui);
                return OperationResult.success();
            }
            UnknownOperationResult result = new UnknownOperationResult();
            Messages messages = beanLocator.get(Messages.NAME);
            Icons icons = beanLocator.get(Icons.NAME);
            Dialogs dialogs = ui.getDialogs();
            dialogs.createOptionDialog().withCaption(messages.getMainMessage("closeUnsaved.caption")).withMessage(messages.getMainMessage("discardChangesOnClose")).withActions(new BaseAction("closeApplication").withCaption(messages.getMainMessage("closeApplication")).withIcon(icons.get(CubaIcon.DIALOG_OK)).withHandler(event -> {
                performStandardLogout(ui);
                result.success();
            }), new DialogAction(DialogAction.Type.CANCEL, Action.Status.PRIMARY).withHandler(event -> {
                result.fail();
            })).show();
            return OperationResult.fail();
        } else {
            forceLogout();
            return OperationResult.success();
        }
    } catch (Exception e) {
        log.error("Error on logout", e);
        String url = ControllerUtils.getLocationWithoutParams() + "?restartApp";
        if (ui != null) {
            ui.getPage().open(url, "_self");
        }
        return new UnknownOperationResult();
    }
}
Also used : Dialogs(com.haulmont.cuba.gui.Dialogs) DialogAction(com.haulmont.cuba.gui.components.DialogAction) UnknownOperationResult(com.haulmont.cuba.gui.util.UnknownOperationResult) Icons(com.haulmont.cuba.gui.icons.Icons) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) RootWindow(com.haulmont.cuba.gui.components.RootWindow) Screens(com.haulmont.cuba.gui.Screens) LoginException(com.haulmont.cuba.security.global.LoginException) IllegalConcurrentAccessException(com.haulmont.cuba.gui.executors.IllegalConcurrentAccessException) NoUserSessionException(com.haulmont.cuba.security.global.NoUserSessionException)

Example 5 with RootWindow

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

the class App method getWindowManager.

/**
 * @return WindowManagerImpl instance or null if the current UI has no MainWindow
 * @deprecated Get screens API from {@link AppUI} instead.
 */
@Deprecated
@Nullable
public WebScreens getWindowManager() {
    AppUI ui = getAppUI();
    if (ui == null) {
        return null;
    }
    RootWindow topLevelWindow = ui.getTopLevelWindow();
    return topLevelWindow != null ? (WebScreens) topLevelWindow.getWindowManager() : null;
}
Also used : RootWindow(com.haulmont.cuba.gui.components.RootWindow) Nullable(javax.annotation.Nullable)

Aggregations

RootWindow (com.haulmont.cuba.gui.components.RootWindow)8 Screens (com.haulmont.cuba.gui.Screens)2 NavigationState (com.haulmont.cuba.gui.navigation.NavigationState)2 Screen (com.haulmont.cuba.gui.screen.Screen)2 NotFoundScreen (com.haulmont.cuba.web.app.ui.navigation.notfoundwindow.NotFoundScreen)2 Preconditions.checkNotEmptyString (com.haulmont.bali.util.Preconditions.checkNotEmptyString)1 Dialogs (com.haulmont.cuba.gui.Dialogs)1 DialogAction (com.haulmont.cuba.gui.components.DialogAction)1 DialogWindow (com.haulmont.cuba.gui.components.DialogWindow)1 Window (com.haulmont.cuba.gui.components.Window)1 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)1 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)1 IllegalConcurrentAccessException (com.haulmont.cuba.gui.executors.IllegalConcurrentAccessException)1 Icons (com.haulmont.cuba.gui.icons.Icons)1 EditorScreen (com.haulmont.cuba.gui.screen.EditorScreen)1 MapScreenOptions (com.haulmont.cuba.gui.screen.MapScreenOptions)1 RouteDefinition (com.haulmont.cuba.gui.sys.RouteDefinition)1 UnknownOperationResult (com.haulmont.cuba.gui.util.UnknownOperationResult)1 LoginException (com.haulmont.cuba.security.global.LoginException)1 NoUserSessionException (com.haulmont.cuba.security.global.NoUserSessionException)1