Search in sources :

Example 11 with Screens

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

the class LocalizedTaskWrapper method handleException.

@Override
public boolean handleException(Exception ex) {
    boolean handled = wrappedTask.handleException(ex);
    if (handled || wrappedTask.getOwnerScreen() == null) {
        Screens screens = getScreenContext().getScreens();
        screens.remove(screen);
    } else {
        Screens screens = getScreenContext().getScreens();
        screens.remove(screen);
        showExecutionError(ex);
        log.error("Exception occurred in background task", ex);
        handled = true;
    }
    return handled;
}
Also used : Screens(com.haulmont.cuba.gui.Screens)

Example 12 with Screens

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

the class App method createTopLevelWindow.

/**
 * Called on each browser tab initialization.
 */
public void createTopLevelWindow(AppUI ui) {
    String topLevelWindowId = routeTopLevelWindowId();
    Screens screens = ui.getScreens();
    Screen screen = screens.create(topLevelWindowId, OpenMode.ROOT);
    screens.show(screen);
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) Screens(com.haulmont.cuba.gui.Screens)

Example 13 with Screens

use of com.haulmont.cuba.gui.Screens 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 14 with Screens

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

the class App method navigateTo.

/**
 * Initialize new TopLevelWindow and replace current.
 *
 * @param topLevelWindowId target top level window id
 * @deprecated Use {@link Screens#create(Class, Screens.LaunchMode)} with {@link OpenMode#ROOT}
 */
@Deprecated
public void navigateTo(String topLevelWindowId) {
    AppUI ui = AppUI.getCurrent();
    WindowInfo windowInfo = windowConfig.getWindowInfo(topLevelWindowId);
    Screens screens = ui.getScreens();
    Screen screen = screens.create(windowInfo.asScreen(), OpenMode.ROOT);
    screens.show(screen);
}
Also used : Screen(com.haulmont.cuba.gui.screen.Screen) Screens(com.haulmont.cuba.gui.Screens) WindowInfo(com.haulmont.cuba.gui.config.WindowInfo)

Example 15 with Screens

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

the class AddToSetAction method actionPerform.

@Override
public void actionPerform(Component component) {
    MetaClass entityMetaClass;
    if (target.getItems() instanceof EntityDataUnit) {
        entityMetaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
    } else {
        throw new UnsupportedOperationException("Unsupported data unit " + target.getItems());
    }
    String query;
    if (filter.getDatasource() != null) {
        query = filter.getDatasource().getQuery();
    } else {
        query = filter.getDataLoader().getQuery();
    }
    String[] strings = ValuePathHelper.parse(ComponentsHelper.getFilterComponentPath(filter));
    String componentId = ValuePathHelper.pathSuffix(strings);
    Set ownerSelection = target.getSelected();
    Map<String, Object> params = new HashMap<>();
    params.put("entityType", entityMetaClass.getName());
    params.put("items", ownerSelection);
    params.put("componentPath", ComponentsHelper.getFilterComponentPath(filter));
    params.put("componentId", componentId);
    params.put("foldersPane", filterHelper.getFoldersPane());
    params.put("entityClass", entityMetaClass.getJavaClass().getName());
    params.put("query", query);
    Screens screens = ComponentsHelper.getScreenContext(filter).getScreens();
    screens.create("saveSetInFolder", OpenMode.DIALOG, new MapScreenOptions(params)).show();
}
Also used : Set(java.util.Set) MetaClass(com.haulmont.chile.core.model.MetaClass) HashMap(java.util.HashMap) EntityDataUnit(com.haulmont.cuba.gui.components.data.meta.EntityDataUnit) MapScreenOptions(com.haulmont.cuba.gui.screen.MapScreenOptions) Screens(com.haulmont.cuba.gui.Screens)

Aggregations

Screens (com.haulmont.cuba.gui.Screens)15 Screen (com.haulmont.cuba.gui.screen.Screen)5 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)4 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)3 HashMap (java.util.HashMap)3 Dialogs (com.haulmont.cuba.gui.Dialogs)2 WindowManager (com.haulmont.cuba.gui.WindowManager)2 DialogAction (com.haulmont.cuba.gui.components.DialogAction)2 RootWindow (com.haulmont.cuba.gui.components.RootWindow)2 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)2 ContainerDataUnit (com.haulmont.cuba.gui.components.data.meta.ContainerDataUnit)2 IllegalConcurrentAccessException (com.haulmont.cuba.gui.executors.IllegalConcurrentAccessException)2 Icons (com.haulmont.cuba.gui.icons.Icons)2 FrameOwner (com.haulmont.cuba.gui.screen.FrameOwner)2 UnknownOperationResult (com.haulmont.cuba.gui.util.UnknownOperationResult)2 LoginException (com.haulmont.cuba.security.global.LoginException)2 NoUserSessionException (com.haulmont.cuba.security.global.NoUserSessionException)2 MetaClass (com.haulmont.chile.core.model.MetaClass)1 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)1 DevelopmentException (com.haulmont.cuba.core.global.DevelopmentException)1