Search in sources :

Example 1 with ScreenFragmentWrapper

use of com.haulmont.cuba.gui.screen.compatibility.ScreenFragmentWrapper 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)

Aggregations

LegacyFragmentAdapter (com.haulmont.cuba.gui.components.compatibility.LegacyFragmentAdapter)1 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)1 ScreenFragmentWrapper (com.haulmont.cuba.gui.screen.compatibility.ScreenFragmentWrapper)1 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)1 ScreenFragment (io.jmix.ui.screen.ScreenFragment)1