use of com.haulmont.cuba.gui.screen.Screen in project cuba by cuba-platform.
the class WindowLoader method loadCrossFieldValidate.
@Deprecated
protected void loadCrossFieldValidate(Window resultComponent, Element element) {
Screen controller = resultComponent.getFrameOwner();
if (controller instanceof AbstractWindow) {
String crossFieldValidate = element.attributeValue("crossFieldValidate");
if (isNotEmpty(crossFieldValidate)) {
if (controller instanceof Window.Editor) {
Window.Editor editor = (Window.Editor) controller;
editor.setCrossFieldValidate(parseBoolean(crossFieldValidate));
} else {
throw new GuiDevelopmentException("Window should extend Window.Editor to use crossFieldValidate attribute", context);
}
}
}
}
use of com.haulmont.cuba.gui.screen.Screen 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.screen.Screen in project cuba by cuba-platform.
the class WebScreenTools method openDefaultScreen.
@Override
public void openDefaultScreen(Screens screens) {
String defaultScreenId = webConfig.getDefaultScreenId();
if (webConfig.getUserCanChooseDefaultScreen()) {
String userDefaultScreen = userSettingService.loadSetting(ClientType.WEB, "userDefaultScreen");
defaultScreenId = StringUtils.isEmpty(userDefaultScreen) ? defaultScreenId : userDefaultScreen;
}
if (StringUtils.isEmpty(defaultScreenId)) {
return;
}
if (!windowConfig.hasWindow(defaultScreenId)) {
log.info("Can't find default screen: {}", defaultScreenId);
return;
}
Screen screen = screens.create(defaultScreenId, OpenMode.NEW_TAB);
if (screen instanceof EditorScreen) {
((EditorScreen) screen).setEntityToEdit(getEntityToEdit(defaultScreenId));
}
screen.show();
Window window = screen.getWindow();
WebWindow webWindow;
if (window instanceof Window.Wrapper) {
webWindow = (WebWindow) ((Window.Wrapper) window).getWrappedWindow();
} else {
webWindow = (WebWindow) window;
}
webWindow.setDefaultScreenWindow(true);
if (!webConfig.getDefaultScreenCanBeClosed()) {
window.setCloseable(false);
}
}
use of com.haulmont.cuba.gui.screen.Screen in project cuba by cuba-platform.
the class AttributeAccessSupport method applyAttributeAccess.
/**
* Apply attribute access rules to a given frame. It means that all components bound to datasources will adjust
* their visible/read-only/required state according to security state of entity instances contained in the datasources.
*
* @param frameOwner frame or screen
* @param reset whether to reset the components to the default state specified by role-based security and model
* annotations. If you invoke this method to apply attribute access to already opened screen, set
* the parameter to true, but keep in mind that previous programmatic changes in the components
* visible/read-only/required state will be lost.
*/
public void applyAttributeAccess(FrameOwner frameOwner, boolean reset) {
ComponentContainer componentContainer;
if (frameOwner instanceof Screen) {
componentContainer = ((Screen) frameOwner).getWindow();
} else {
componentContainer = (Window) frameOwner;
}
ComponentsHelper.walkComponents(componentContainer, (component, name) -> visitComponent(component, reset));
}
use of com.haulmont.cuba.gui.screen.Screen in project cuba by cuba-platform.
the class WebSuggestionField method showSuggestions.
protected void showSuggestions(List<V> suggestions, boolean userOriginated) {
FrameOwner frameOwner = getFrame().getFrameOwner();
Collection<Screen> dialogScreens = UiControllerUtils.getScreenContext(frameOwner).getScreens().getOpenedScreens().getDialogScreens();
Screen lastDialog = null;
for (Screen dialogScreen : dialogScreens) {
lastDialog = dialogScreen;
}
if (frameOwner instanceof ScreenFragment) {
frameOwner = ComponentsHelper.getScreen((ScreenFragment) frameOwner);
}
if (lastDialog == null || Objects.equals(frameOwner, lastDialog)) {
component.showSuggestions(suggestions, userOriginated);
}
}
Aggregations