Search in sources :

Example 11 with MapScreenOptions

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

the class CubaScreens method openFrame.

@Override
public Frame openFrame(Frame parentFrame, Component parent, @Nullable String id, WindowInfo windowInfo, Map<String, Object> params) {
    ScreenFragment screenFragment;
    Fragments fragments = ui.getFragments();
    if (params != null && !params.isEmpty()) {
        screenFragment = fragments.create(parentFrame.getFrameOwner(), windowInfo.getId(), new MapScreenOptions(params));
    } else {
        screenFragment = fragments.create(parentFrame.getFrameOwner(), windowInfo.getId());
    }
    if (id != null) {
        screenFragment.getFragment().setId(id);
    }
    fragments.init(screenFragment);
    if (parent instanceof ComponentContainer) {
        ComponentContainer container = (ComponentContainer) parent;
        for (Component c : container.getComponents()) {
            if (c instanceof Component.Disposable) {
                Component.Disposable disposable = (Component.Disposable) c;
                if (!disposable.isDisposed()) {
                    disposable.dispose();
                }
            }
            container.remove(c);
        }
        container.add(screenFragment.getFragment());
    }
    if (screenFragment instanceof LegacyFragmentAdapter) {
        return ((LegacyFragmentAdapter) screenFragment).getRealScreen();
    }
    return screenFragment instanceof Frame ? (Frame) screenFragment : new ScreenFragmentWrapper(screenFragment);
}
Also used : LegacyFrame(com.haulmont.cuba.gui.screen.compatibility.LegacyFrame) ScreenFragment(io.jmix.ui.screen.ScreenFragment) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) LegacyFragmentAdapter(com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter) ScreenFragmentWrapper(com.haulmont.cuba.gui.screen.compatibility.ScreenFragmentWrapper)

Example 12 with MapScreenOptions

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

the class CubaScreens method openLookup.

@Override
public com.haulmont.cuba.gui.components.Window.Lookup openLookup(WindowInfo windowInfo, com.haulmont.cuba.gui.components.Window.Lookup.Handler handler, OpenType openType, Map<String, Object> params) {
    params = createParametersMap(windowInfo, params);
    MapScreenOptions options = new MapScreenOptions(params);
    Screen screen = createScreen(windowInfo, openType.getOpenMode(), options);
    applyOpenTypeParameters(screen.getWindow(), openType);
    ((LookupScreen) screen).setSelectHandler(new SelectHandlerAdapter(handler));
    show(screen);
    return screen instanceof com.haulmont.cuba.gui.components.Window.Lookup ? (com.haulmont.cuba.gui.components.Window.Lookup) screen : new ScreenLookupWrapper(screen);
}
Also used : LookupScreen(io.jmix.ui.screen.LookupScreen) LookupScreen(io.jmix.ui.screen.LookupScreen) EditorScreen(io.jmix.ui.screen.EditorScreen) Screen(io.jmix.ui.screen.Screen) ScreenLookupWrapper(com.haulmont.cuba.gui.screen.compatibility.ScreenLookupWrapper) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) SelectHandlerAdapter(com.haulmont.cuba.gui.components.compatibility.SelectHandlerAdapter)

Example 13 with MapScreenOptions

use of io.jmix.ui.screen.MapScreenOptions 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 14 with MapScreenOptions

use of io.jmix.ui.screen.MapScreenOptions 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 15 with MapScreenOptions

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

the class CanvasUiComponentsFactory method createCanvasWidgetLayout.

@Override
public CanvasWidgetLayout createCanvasWidgetLayout(CanvasFragment canvasFragment, WidgetLayout widgetLayout) {
    Widget widget = widgetLayout.getWidget();
    Optional<WidgetTypeInfo> widgetTypeOpt = widgetRepository.getWidgetTypesInfo().stream().filter(widgetType -> StringUtils.equals(widget.getFragmentId(), widgetType.getFragmentId())).findFirst();
    if (!widgetTypeOpt.isPresent()) {
        CanvasWidgetLayout layout = components.create(CanvasWidgetLayout.class).init(widgetLayout);
        Label<String> label = components.create(Label.class);
        String message = messages.formatMessage(CanvasUiComponentsFactory.class, "widgetNotFound", widget.getCaption(), widget.getName());
        label.setValue(message);
        layout.addComponent(label);
        log.error(message);
        return layout;
    }
    widget.setDashboard(canvasFragment.getDashboardModel());
    String fragmentId = widgetTypeOpt.get().getFragmentId();
    Map<String, Object> params = new HashMap<>(ParamsMap.of(WIDGET, widget, DASHBOARD_MODEL, canvasFragment.getDashboardModel(), DASHBOARD, canvasFragment.getDashboard()));
    params.putAll(widgetRepository.getWidgetParams(widget));
    ScreenFragment screenFragment = AppUI.getCurrent().getFragments().create(canvasFragment, fragmentId, new MapScreenOptions(params)).init();
    Fragment fragment = screenFragment.getFragment();
    fragment.setSizeFull();
    Component widgetComponent = fragment;
    if (BooleanUtils.isTrue(widget.getShowWidgetCaption())) {
        VBoxLayout vBoxLayout = components.create(VBoxLayout.class);
        vBoxLayout.setSpacing(true);
        vBoxLayout.setMargin(true);
        vBoxLayout.setSizeFull();
        Label<String> label = components.create(Label.class);
        label.setValue(widget.getCaption());
        label.setStyleName("h2");
        vBoxLayout.add(label);
        vBoxLayout.add(fragment);
        vBoxLayout.expand(fragment);
        widgetComponent = vBoxLayout;
    } else {
        fragment.setMargin(true);
    }
    CanvasWidgetLayout layout = components.create(CanvasWidgetLayout.class).init(widgetLayout);
    layout.setUuid(UUID.randomUUID());
    layout.addComponent(widgetComponent);
    layout.setWidgetComponent(screenFragment);
    layout.setInnerLayout(widgetComponent);
    layout.setWidget(widget);
    layout.getDelegate().expand(widgetComponent);
    layout.setSizeFull();
    return layout;
}
Also used : ScreenFragment(io.jmix.ui.screen.ScreenFragment) Dashboard(io.jmix.dashboardsui.component.Dashboard) Fragment(io.jmix.ui.component.Fragment) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ParamsMap(io.jmix.core.common.util.ParamsMap) BooleanUtils(org.apache.commons.lang3.BooleanUtils) HashMap(java.util.HashMap) Widget(io.jmix.dashboards.model.Widget) StringUtils(org.apache.commons.lang3.StringUtils) Messages(io.jmix.core.Messages) WidgetRepository(io.jmix.dashboardsui.repository.WidgetRepository) Component(io.jmix.ui.component.Component) CanvasComponentsFactory(io.jmix.dashboardsui.dashboard.tools.factory.CanvasComponentsFactory) UiComponents(io.jmix.ui.UiComponents) VBoxLayout(io.jmix.ui.component.VBoxLayout) Map(java.util.Map) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) Logger(org.slf4j.Logger) UUID(java.util.UUID) io.jmix.dashboards.model.visualmodel(io.jmix.dashboards.model.visualmodel) CanvasLayout(io.jmix.dashboardsui.component.CanvasLayout) Label(io.jmix.ui.component.Label) AppUI(io.jmix.ui.AppUI) Optional(java.util.Optional) io.jmix.dashboardsui.component.impl(io.jmix.dashboardsui.component.impl) CanvasFragment(io.jmix.dashboardsui.screen.dashboard.editor.canvas.CanvasFragment) WidgetTypeInfo(io.jmix.dashboardsui.repository.WidgetTypeInfo) VBoxLayout(io.jmix.ui.component.VBoxLayout) HashMap(java.util.HashMap) Widget(io.jmix.dashboards.model.Widget) WidgetTypeInfo(io.jmix.dashboardsui.repository.WidgetTypeInfo) ScreenFragment(io.jmix.ui.screen.ScreenFragment) Fragment(io.jmix.ui.component.Fragment) CanvasFragment(io.jmix.dashboardsui.screen.dashboard.editor.canvas.CanvasFragment) ScreenFragment(io.jmix.ui.screen.ScreenFragment) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) Component(io.jmix.ui.component.Component)

Aggregations

MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)20 Screen (io.jmix.ui.screen.Screen)11 EditorScreen (io.jmix.ui.screen.EditorScreen)9 LookupScreen (io.jmix.ui.screen.LookupScreen)8 MetaClass (io.jmix.core.metamodel.model.MetaClass)4 HashMap (java.util.HashMap)4 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)3 ScreenEditorWrapper (com.haulmont.cuba.gui.screen.compatibility.ScreenEditorWrapper)3 AbstractEditor (com.haulmont.cuba.gui.components.AbstractEditor)2 SelectHandlerAdapter (com.haulmont.cuba.gui.components.compatibility.SelectHandlerAdapter)2 ScreenLookupWrapper (com.haulmont.cuba.gui.screen.compatibility.ScreenLookupWrapper)2 ScreenWrapper (com.haulmont.cuba.gui.screen.compatibility.ScreenWrapper)2 Screens (io.jmix.ui.Screens)2 ScreenFragment (io.jmix.ui.screen.ScreenFragment)2 EntityLoadInfo (com.haulmont.cuba.core.global.EntityLoadInfo)1 WindowManager (com.haulmont.cuba.gui.WindowManager)1 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)1 Filter (com.haulmont.cuba.gui.components.Filter)1 LegacyFragmentAdapter (com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter)1 DsContextImplementation (com.haulmont.cuba.gui.data.impl.DsContextImplementation)1