use of com.haulmont.cuba.web.sys.TabWindowContainer in project cuba by cuba-platform.
the class WebAppWorkArea method getOpenedWorkAreaScreensStream.
public Stream<Screen> getOpenedWorkAreaScreensStream() {
if (getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheetBehaviour = getTabbedWindowContainer().getTabSheetBehaviour();
return tabSheetBehaviour.getTabComponentsStream().flatMap(c -> {
TabWindowContainer windowContainer = (TabWindowContainer) c;
Deque<Window> windows = windowContainer.getBreadCrumbs().getWindows();
return windows.stream().map(Window::getFrameOwner);
});
} else {
CubaSingleModeContainer singleWindowContainer = getSingleWindowContainer();
TabWindowContainer windowContainer = (TabWindowContainer) singleWindowContainer.getWindowContainer();
if (windowContainer != null) {
Deque<Window> windows = windowContainer.getBreadCrumbs().getWindows();
return windows.stream().map(Window::getFrameOwner);
}
}
return Stream.empty();
}
use of com.haulmont.cuba.web.sys.TabWindowContainer in project cuba by cuba-platform.
the class WebAppWorkArea method closeWindowByShortcut.
protected void closeWindowByShortcut(RootWindow topLevelWindow) {
if (getState() != AppWorkArea.State.WINDOW_CONTAINER) {
return;
}
CubaUI ui = (CubaUI) this.getComponent().getUI();
if (!ui.isAccessibleForUser(this.getComponent())) {
LoggerFactory.getLogger(WebAppWorkArea.class).debug("Ignore close shortcut attempt because workArea is inaccessible for user");
return;
}
if (getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = getTabbedWindowContainer().getTabSheetBehaviour();
if (tabSheet != null) {
TabWindowContainer layout = (TabWindowContainer) tabSheet.getSelectedTab();
if (layout != null) {
tabSheet.focus();
WindowBreadCrumbs breadCrumbs = layout.getBreadCrumbs();
Window currentWindow = breadCrumbs.getCurrentWindow();
if (isNotCloseable(currentWindow)) {
return;
}
if (isWindowClosePrevented(currentWindow, CloseOriginType.SHORTCUT)) {
return;
}
if (breadCrumbs.getWindows().isEmpty()) {
com.vaadin.ui.Component previousTab = tabSheet.getPreviousTab(layout);
if (previousTab != null) {
currentWindow.getFrameOwner().close(FrameOwner.WINDOW_CLOSE_ACTION).then(() -> tabSheet.setSelectedTab(previousTab));
} else {
currentWindow.getFrameOwner().close(FrameOwner.WINDOW_CLOSE_ACTION);
}
} else {
currentWindow.getFrameOwner().close(FrameOwner.WINDOW_CLOSE_ACTION);
}
}
}
} else {
Iterator<WindowBreadCrumbs> it = getWindowStacks().iterator();
if (it.hasNext()) {
Window currentWindow = it.next().getCurrentWindow();
if (!isWindowClosePrevented(currentWindow, CloseOriginType.SHORTCUT)) {
ui.focus();
currentWindow.getFrameOwner().close(FrameOwner.WINDOW_CLOSE_ACTION);
}
}
}
}
use of com.haulmont.cuba.web.sys.TabWindowContainer in project cuba by cuba-platform.
the class WebAppWorkArea method getOpenedTabCount.
public int getOpenedTabCount() {
if (getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheetBehaviour = getTabbedWindowContainer().getTabSheetBehaviour();
return tabSheetBehaviour.getComponentCount();
} else {
CubaSingleModeContainer singleWindowContainer = getSingleWindowContainer();
TabWindowContainer windowContainer = (TabWindowContainer) singleWindowContainer.getWindowContainer();
return windowContainer != null ? 1 : 0;
}
}
use of com.haulmont.cuba.web.sys.TabWindowContainer in project cuba by cuba-platform.
the class WebTabWindow method updateCaptionAndDescription.
protected void updateCaptionAndDescription() {
TabSheet.Tab tabWindow = findTab();
if (tabWindow != null) {
String tabCaption = formatTabCaption();
String tabDescription = formatTabDescription();
tabWindow.setCaption(tabCaption);
if (!Objects.equals(tabCaption, tabDescription)) {
tabWindow.setDescription(tabDescription);
} else {
tabWindow.setDescription(null);
}
((TabWindowContainer) tabWindow.getComponent()).getBreadCrumbs().update();
} else {
TabWindowContainer layout = (TabWindowContainer) asSingleWindow();
if (layout != null) {
layout.getBreadCrumbs().update();
}
}
}
use of com.haulmont.cuba.web.sys.TabWindowContainer in project cuba by cuba-platform.
the class WebAppWorkArea method getWindowStacks.
protected List<WindowBreadCrumbs> getWindowStacks() {
if (getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = getTabbedWindowContainer().getTabSheetBehaviour();
List<WindowBreadCrumbs> allBreadCrumbs = new ArrayList<>();
for (int i = 0; i < tabSheet.getComponentCount(); i++) {
String tabId = tabSheet.getTab(i);
TabWindowContainer tabComponent = (TabWindowContainer) tabSheet.getTabComponent(tabId);
allBreadCrumbs.add(tabComponent.getBreadCrumbs());
}
return allBreadCrumbs;
} else {
TabWindowContainer windowContainer = (TabWindowContainer) getSingleWindowContainer().getWindowContainer();
if (windowContainer == null) {
return Collections.emptyList();
}
return singletonList(windowContainer.getBreadCrumbs());
}
}
Aggregations