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