Search in sources :

Example 6 with EditorScreen

use of io.jmix.ui.screen.EditorScreen in project jmix by jmix-framework.

the class CubaScreens method openEditor.

@Override
public com.haulmont.cuba.gui.components.Window.Editor openEditor(WindowInfo windowInfo, Entity item, OpenType openType, Datasource parentDs) {
    Map<String, Object> params = createParametersMap(windowInfo, Collections.singletonMap(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 com.haulmont.cuba.gui.components.Window.Editor ? (com.haulmont.cuba.gui.components.Window.Editor) screen : new ScreenEditorWrapper(screen);
}
Also used : EditorScreen(io.jmix.ui.screen.EditorScreen) LookupScreen(io.jmix.ui.screen.LookupScreen) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) AbstractEditor(com.haulmont.cuba.gui.components.AbstractEditor) ScreenEditorWrapper(com.haulmont.cuba.gui.screen.compatibility.ScreenEditorWrapper)

Example 7 with EditorScreen

use of io.jmix.ui.screen.EditorScreen in project jmix by jmix-framework.

the class CubaScreens method openEditor.

@Override
public com.haulmont.cuba.gui.components.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 com.haulmont.cuba.gui.components.Window.Editor ? (com.haulmont.cuba.gui.components.Window.Editor) screen : new ScreenEditorWrapper(screen);
}
Also used : EditorScreen(io.jmix.ui.screen.EditorScreen) LookupScreen(io.jmix.ui.screen.LookupScreen) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) AbstractEditor(com.haulmont.cuba.gui.components.AbstractEditor) ScreenEditorWrapper(com.haulmont.cuba.gui.screen.compatibility.ScreenEditorWrapper)

Example 8 with EditorScreen

use of io.jmix.ui.screen.EditorScreen in project jmix by jmix-framework.

the class ScreensLinkHandlerProcessor method openWindow.

protected void openWindow(WindowInfo windowInfo, ExternalLinkContext linkContext) {
    Map<String, String> requestParams = linkContext.getRequestParams();
    App app = linkContext.getApp();
    String itemStr = requestParams.get("item");
    String openTypeParam = requestParams.get("openType");
    OpenType openType = OpenType.NEW_TAB;
    if (StringUtils.isNotEmpty(openTypeParam)) {
        try {
            openType = OpenType.valueOf(openTypeParam);
        } catch (IllegalArgumentException e) {
            log.warn("Unknown open type ({}) in request parameters", openTypeParam);
        }
    }
    Screens screens = AppUI.getCurrent().getScreens();
    if (itemStr == null) {
        Screen screen = screens.create(windowInfo.getId(), openType.getOpenMode(), new MapScreenOptions(getParamsMap(requestParams)));
        screen.show();
    } else {
        EntityLoadInfo info = EntityLoadInfo.parse(itemStr);
        if (info == null) {
            log.warn("Invalid item definition: {}", itemStr);
        } else {
            Entity entity = loadEntityInstance(info);
            if (entity == null) {
                throw new EntityAccessException();
            }
            Screen screen = screens.create(windowInfo.getId(), openType.getOpenMode(), new MapScreenOptions(getParamsMap(requestParams)));
            EditorScreen editorScreen = (EditorScreen) screen;
            editorScreen.setEntityToEdit(entity);
            screen.show();
        }
    }
}
Also used : EntityLoadInfo(com.haulmont.cuba.core.global.EntityLoadInfo) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) EditorScreen(io.jmix.ui.screen.EditorScreen) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions)

Example 9 with EditorScreen

use of io.jmix.ui.screen.EditorScreen in project jmix by jmix-framework.

the class ScreenToolsImpl method openDefaultScreen.

@Override
public void openDefaultScreen(Screens screens) {
    String defaultScreenId = uiProperties.getDefaultScreenId();
    if (StringUtils.isEmpty(defaultScreenId)) {
        return;
    }
    if (!windowConfig.hasWindow(defaultScreenId)) {
        log.info("Can't find default screen: {}", defaultScreenId);
        return;
    }
    Screen screen = screens.create(defaultScreenId, OpenMode.NEW_TAB);
    if (screen instanceof EditorScreen) {
        ((EditorScreen) screen).setEntityToEdit(getEntityToEdit(defaultScreenId));
    }
    screen.show();
    Window window = screen.getWindow();
    setDefaultScreenWindow(window);
    if (!uiProperties.isDefaultScreenCanBeClosed()) {
        window.setCloseable(false);
    }
}
Also used : Window(io.jmix.ui.component.Window) EditorScreen(io.jmix.ui.screen.EditorScreen) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen)

Example 10 with EditorScreen

use of io.jmix.ui.screen.EditorScreen in project jmix by jmix-framework.

the class WebUrlRouting method buildParams.

protected Map<String, String> buildParams(Screen screen, Map<String, String> urlParams) {
    String route = getRoute(screen);
    if (StringUtils.isEmpty(route) && (isEditor(screen) || MapUtils.isNotEmpty(urlParams))) {
        log.debug("There's no route for screen \"{}\". URL params will be ignored", screen.getId());
        return Collections.emptyMap();
    }
    if (omitParams(screen)) {
        return Collections.emptyMap();
    }
    Map<String, String> params = new LinkedHashMap<>();
    if (isEditor(screen)) {
        Object editedEntity = ((EditorScreen) screen).getEditedEntity();
        if (editedEntity != null) {
            if (!entityStates.isNew(editedEntity)) {
                Object entityId = EntityValues.getId(editedEntity);
                if (entityId != null) {
                    String serializedId = UrlIdSerializer.serializeId(entityId);
                    if (!"".equals(serializedId)) {
                        params.put("id", serializedId);
                    }
                }
            }
        }
    }
    params.putAll(urlParams != null ? urlParams : Collections.emptyMap());
    return params;
}
Also used : EditorScreen(io.jmix.ui.screen.EditorScreen) Preconditions.checkNotEmptyString(io.jmix.core.common.util.Preconditions.checkNotEmptyString)

Aggregations

EditorScreen (io.jmix.ui.screen.EditorScreen)10 Screen (io.jmix.ui.screen.Screen)8 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)5 LookupScreen (io.jmix.ui.screen.LookupScreen)4 ScreenEditorWrapper (com.haulmont.cuba.gui.screen.compatibility.ScreenEditorWrapper)3 AbstractEditor (com.haulmont.cuba.gui.components.AbstractEditor)2 EntityLoadInfo (com.haulmont.cuba.core.global.EntityLoadInfo)1 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)1 Entity (io.jmix.core.Entity)1 Messages (io.jmix.core.Messages)1 Metadata (io.jmix.core.Metadata)1 Preconditions.checkNotEmptyString (io.jmix.core.common.util.Preconditions.checkNotEmptyString)1 MetaClass (io.jmix.core.metamodel.model.MetaClass)1 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)1 EntityInfoWindow (io.jmix.datatoolsui.screen.entityinfo.EntityInfoWindow)1 ScreenBuilders (io.jmix.ui.ScreenBuilders)1 Screens (io.jmix.ui.Screens)1 Table (io.jmix.ui.component.Table)1 Window (io.jmix.ui.component.Window)1 FilterCondition (io.jmix.ui.entity.FilterCondition)1