use of com.haulmont.cuba.gui.components.Component.Disposable in project cuba by cuba-platform.
the class WebScreens method openFrame.
@SuppressWarnings({ "deprecation", "IncorrectCreateGuiComponent" })
@Override
public Frame openFrame(Frame parentFrame, com.haulmont.cuba.gui.components.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 (com.haulmont.cuba.gui.components.Component c : container.getComponents()) {
if (c instanceof com.haulmont.cuba.gui.components.Component.Disposable) {
com.haulmont.cuba.gui.components.Component.Disposable disposable = (com.haulmont.cuba.gui.components.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);
}
use of com.haulmont.cuba.gui.components.Component.Disposable in project cuba by cuba-platform.
the class WebScreens method remove.
@Override
public void remove(Screen screen) {
checkNotNullArgument(screen);
checkOpened(screen);
WindowImplementation windowImpl = (WindowImplementation) screen.getWindow();
if (windowImpl instanceof Disposable) {
((Disposable) windowImpl).dispose();
}
LaunchMode launchMode = windowImpl.getContext().getLaunchMode();
if (launchMode instanceof OpenMode) {
OpenMode openMode = (OpenMode) launchMode;
switch(openMode) {
case DIALOG:
removeDialogWindow(screen);
break;
case NEW_TAB:
case NEW_WINDOW:
removeNewTabWindow(screen);
break;
case ROOT:
removeRootWindow(screen);
break;
case THIS_TAB:
removeThisTabWindow(screen);
break;
default:
throw new UnsupportedOperationException("Unsupported OpenMode");
}
}
fireEvent(screen, AfterDetachEvent.class, new AfterDetachEvent(screen));
events.publish(new ScreenClosedEvent(screen));
afterScreenRemove(screen);
}
Aggregations