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;
}
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();
}
}
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);
}
}
}
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();
}
}
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;
}
Aggregations