use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.
the class WebScreens method getConfiguredWorkAreaOrNull.
@Nullable
protected WebAppWorkArea getConfiguredWorkAreaOrNull() {
RootWindow topLevelWindow = ui.getTopLevelWindow();
if (topLevelWindow == null) {
throw new IllegalStateException("There is no root screen opened");
}
Screen controller = topLevelWindow.getFrameOwner();
if (controller instanceof HasWorkArea) {
AppWorkArea workArea = ((HasWorkArea) controller).getWorkArea();
if (workArea != null) {
return (WebAppWorkArea) workArea;
}
}
return null;
}
use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.
the class WebScreens method removeAll.
@Override
public void removeAll() {
List<Screen> dialogScreens = getDialogScreensStream().collect(Collectors.toList());
for (Screen dialogScreen : dialogScreens) {
remove(dialogScreen);
}
WebAppWorkArea workArea = getConfiguredWorkAreaOrNull();
if (workArea != null) {
Collection<WindowStack> workAreaStacks = getWorkAreaStacks(workArea);
for (WindowStack workAreaStack : workAreaStacks) {
Collection<Screen> tabScreens = workAreaStack.getBreadcrumbs();
for (Screen screen : tabScreens) {
remove(screen);
}
}
}
}
use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.
the class WebScreens method selectWindowTab.
@Override
public void selectWindowTab(Window window) {
WebAppWorkArea workArea = getConfiguredWorkArea();
Collection<WindowStack> workAreaStacks = getWorkAreaStacks(workArea);
Screen screen = window.getFrameOwner();
workAreaStacks.stream().filter(ws -> ws.getBreadcrumbs().contains(screen)).findFirst().ifPresent(WindowStack::select);
}
use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.
the class WebScreens method showThisTabWindow.
protected void showThisTabWindow(Screen screen) {
WebAppWorkArea workArea = getConfiguredWorkArea();
workArea.switchTo(AppWorkArea.State.WINDOW_CONTAINER);
TabWindowContainer windowContainer;
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
windowContainer = (TabWindowContainer) tabSheet.getSelectedTab();
} else {
windowContainer = (TabWindowContainer) workArea.getSingleWindowContainer().getWindowContainer();
}
if (windowContainer == null || windowContainer.getBreadCrumbs() == null) {
throw new IllegalStateException("BreadCrumbs not found");
}
WindowBreadCrumbs breadCrumbs = windowContainer.getBreadCrumbs();
Window currentWindow = breadCrumbs.getCurrentWindow();
windowContainer.removeComponent(currentWindow.unwrapComposition(Layout.class));
Window newWindow = screen.getWindow();
com.vaadin.ui.Component newWindowComposition = newWindow.unwrapComposition(com.vaadin.ui.Component.class);
windowContainer.addComponent(newWindowComposition);
breadCrumbs.addWindow(newWindow);
WebWindow webWindow = (WebWindow) screen.getWindow();
webWindow.setResolvedState(createOrUpdateState(webWindow.getResolvedState(), getConfiguredWorkArea().generateUrlStateMark()));
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
String tabId = tabSheet.getTab(windowContainer);
TabWindow tabWindow = (TabWindow) newWindow;
String formattedCaption = tabWindow.formatTabCaption();
String formattedDescription = tabWindow.formatTabDescription();
tabSheet.setTabCaption(tabId, formattedCaption);
if (!Objects.equals(formattedCaption, formattedDescription)) {
tabSheet.setTabDescription(tabId, formattedDescription);
} else {
tabSheet.setTabDescription(tabId, null);
}
tabSheet.setTabIcon(tabId, iconResolver.getIconResource(newWindow.getIcon()));
tabSheet.setTabClosable(tabId, newWindow.isCloseable());
ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(tabWindow.getContentSwitchMode().name());
tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
} else {
windowContainer.markAsDirtyRecursive();
}
}
Aggregations