use of com.haulmont.cuba.gui.Screens in project cuba by cuba-platform.
the class LocalizedTaskWrapper method done.
@Override
public void done(V result) {
Screens screens = getScreenContext().getScreens();
screens.remove(screen);
try {
wrappedTask.done(result);
} catch (Exception ex) {
// we should show exception messages immediately
showExecutionError(ex);
}
}
use of com.haulmont.cuba.gui.Screens in project cuba by cuba-platform.
the class MainScreen method onAfterShow.
@Subscribe
protected void onAfterShow(AfterShowEvent event) {
Screens screens = UiControllerUtils.getScreenContext(this).getScreens();
getBeanLocator().get(ScreenTools.class).openDefaultScreen(screens);
}
use of com.haulmont.cuba.gui.Screens in project cuba by cuba-platform.
the class App method removeAllWindows.
/**
* Removes all windows in the given {@code uis}.
*
* @param uis {@link AppUI} instances
*/
protected void removeAllWindows(List<AppUI> uis) {
log.debug("Closing all windows in all UIs");
try {
for (AppUI ui : uis) {
Screens screens = ui.getScreens();
if (screens != null) {
Screen rootScreen = screens.getOpenedScreens().getRootScreenOrNull();
if (rootScreen != null) {
screens.removeAll();
screens.remove(rootScreen);
}
}
// also remove all native Vaadin windows, that is not under CUBA control
Window[] windows = ui.getWindows().toArray(new Window[0]);
for (com.vaadin.ui.Window win : windows) {
ui.removeWindow(win);
}
List<Notification> notifications = ui.getExtensions().stream().filter(ext -> ext instanceof Notification).map(ext -> (Notification) ext).collect(Collectors.toList());
notifications.forEach(Notification::close);
}
} catch (Throwable e) {
log.error("Error closing all windows", e);
}
}
use of com.haulmont.cuba.gui.Screens in project cuba by cuba-platform.
the class WebScreenFacet method createScreen.
protected S createScreen(FrameOwner frameOwner) {
S screen;
Screens screens = UiControllerUtils.getScreenContext(frameOwner).getScreens();
if (screenId != null) {
screen = (S) screens.create(screenId, launchMode, getScreenOptions());
} else if (screenClass != null) {
screen = screens.create(screenClass, launchMode, getScreenOptions());
} else {
throw new DevelopmentException("Unable to open screen because no screen id or screen class are specified");
}
return screen;
}
use of com.haulmont.cuba.gui.Screens in project cuba by cuba-platform.
the class ScreenBuilderProcessor method buildScreen.
@SuppressWarnings("unchecked")
public Screen buildScreen(ScreenBuilder builder) {
FrameOwner origin = builder.getOrigin();
Screens screens = getScreenContext(origin).getScreens();
Screen screen;
if (builder instanceof ScreenClassBuilder) {
ScreenClassBuilder screenClassBuilder = (ScreenClassBuilder) builder;
Class screenClass = screenClassBuilder.getScreenClass();
if (screenClass == null) {
throw new IllegalArgumentException("Screen class is not set");
}
screen = screens.create(screenClass, builder.getLaunchMode(), builder.getOptions());
@SuppressWarnings("unchecked") Consumer<AfterScreenCloseEvent> closeListener = screenClassBuilder.getCloseListener();
if (closeListener != null) {
screen.addAfterCloseListener(new AfterCloseListenerAdapter(closeListener));
}
} else {
if (builder.getScreenId() == null) {
throw new IllegalArgumentException("Screen id is not set");
}
screen = screens.create(builder.getScreenId(), builder.getLaunchMode(), builder.getOptions());
}
return screen;
}
Aggregations