use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.
the class WebWindowManager method closeWindow.
protected void closeWindow(Window window, WindowOpenInfo openInfo) {
if (!disableSavingScreenHistory) {
screenHistorySupport.saveScreenHistory(window, openInfo.getOpenMode());
}
WebWindow webWindow = (WebWindow) window;
webWindow.stopTimers();
switch(openInfo.getOpenMode()) {
case DIALOG:
{
final CubaWindow cubaDialogWindow = (CubaWindow) openInfo.getData();
cubaDialogWindow.forceClose();
fireListeners(window, tabs.size() != 0);
break;
}
case NEW_WINDOW:
case NEW_TAB:
{
final Layout layout = (Layout) openInfo.getData();
layout.removeComponent(WebComponentsHelper.getComposition(window));
WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
tabSheet.silentCloseTabAndSelectPrevious(layout);
tabSheet.removeComponent(layout);
} else {
VerticalLayout singleLayout = workArea.getSingleWindowContainer();
singleLayout.removeComponent(layout);
}
WindowBreadCrumbs windowBreadCrumbs = tabs.get(layout);
if (windowBreadCrumbs != null) {
windowBreadCrumbs.clearListeners();
windowBreadCrumbs.removeWindow();
}
tabs.remove(layout);
stacks.remove(windowBreadCrumbs);
fireListeners(window, !tabs.isEmpty());
if (tabs.isEmpty() && app.getConnection().isConnected()) {
workArea.switchTo(AppWorkArea.State.INITIAL_LAYOUT);
}
break;
}
case THIS_TAB:
{
final Layout layout = (Layout) openInfo.getData();
final WindowBreadCrumbs breadCrumbs = tabs.get(layout);
if (breadCrumbs == null) {
throw new IllegalStateException("Unable to close screen: breadCrumbs not found");
}
breadCrumbs.removeWindow();
Window currentWindow = breadCrumbs.getCurrentWindow();
if (!getStack(breadCrumbs).empty()) {
Pair<Window, Integer> entry = getStack(breadCrumbs).pop();
putToWindowMap(entry.getFirst(), entry.getSecond());
}
Component component = WebComponentsHelper.getComposition(currentWindow);
component.setSizeFull();
WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));
layout.removeComponent(WebComponentsHelper.getComposition(window));
if (app.getConnection().isConnected()) {
layout.addComponent(component);
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
String tabId = tabSheet.getTab(layout);
String formattedCaption = formatTabCaption(currentWindow.getCaption(), currentWindow.getDescription());
tabSheet.setTabCaption(tabId, formattedCaption);
String formattedDescription = formatTabDescription(currentWindow.getCaption(), currentWindow.getDescription());
if (!Objects.equals(formattedCaption, formattedDescription)) {
tabSheet.setTabDescription(tabId, formattedDescription);
} else {
tabSheet.setTabDescription(tabId, null);
}
tabSheet.setTabIcon(tabId, iconResolver.getIconResource(currentWindow.getIcon()));
ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(currentWindow.getContentSwitchMode().name());
tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
}
}
fireListeners(window, !tabs.isEmpty());
if (tabs.isEmpty() && app.getConnection().isConnected()) {
workArea.switchTo(AppWorkArea.State.INITIAL_LAYOUT);
}
break;
}
default:
{
throw new UnsupportedOperationException();
}
}
}
use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.
the class WebWindowManager method showWindowThisTab.
protected Component showWindowThisTab(final Window window, final String caption, final String description) {
getDialogParams().reset();
WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));
Layout layout;
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
layout = (Layout) tabSheet.getSelectedTab();
} else {
layout = (Layout) workArea.getSingleWindowContainer().getComponent(0);
}
final WindowBreadCrumbs breadCrumbs = tabs.get(layout);
if (breadCrumbs == null) {
throw new IllegalStateException("BreadCrumbs not found");
}
final Window currentWindow = breadCrumbs.getCurrentWindow();
Set<Map.Entry<Window, Integer>> set = windows.entrySet();
boolean pushed = false;
for (Map.Entry<Window, Integer> entry : set) {
if (entry.getKey().equals(currentWindow)) {
windows.remove(currentWindow);
getStack(breadCrumbs).push(new Pair<>(entry.getKey(), entry.getValue()));
pushed = true;
break;
}
}
if (!pushed) {
getStack(breadCrumbs).push(new Pair<>(currentWindow, null));
}
removeFromWindowMap(currentWindow);
layout.removeComponent(WebComponentsHelper.getComposition(currentWindow));
final Component component = WebComponentsHelper.getComposition(window);
component.setSizeFull();
layout.addComponent(component);
breadCrumbs.addWindow(window);
if (workArea.getMode() == Mode.TABBED) {
TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
String tabId = tabSheet.getTab(layout);
String formattedCaption = formatTabCaption(caption, description);
tabSheet.setTabCaption(tabId, formattedCaption);
String formattedDescription = formatTabDescription(caption, description);
if (!Objects.equals(formattedCaption, formattedDescription)) {
tabSheet.setTabDescription(tabId, formattedDescription);
} else {
tabSheet.setTabDescription(tabId, null);
}
tabSheet.setTabIcon(tabId, iconResolver.getIconResource(window.getIcon()));
ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(window.getContentSwitchMode().name());
tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
} else {
layout.markAsDirtyRecursive();
}
return layout;
}
use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.
the class WebScreens method handleTabWindowClose.
protected void handleTabWindowClose(HasTabSheetBehaviour targetTabSheet, com.vaadin.ui.Component tabContent) {
WindowBreadCrumbs tabBreadCrumbs = ((TabWindowContainer) tabContent).getBreadCrumbs();
WebAppWorkArea workArea = getConfiguredWorkAreaOrNull();
if (workArea != null && workArea.isNotCloseable(tabBreadCrumbs.getCurrentWindow())) {
return;
}
Runnable closeTask = new TabCloseTask(tabBreadCrumbs);
closeTask.run();
// it is needed to force redraw tabSheet if it has a lot of tabs and part of them are hidden
targetTabSheet.markAsDirty();
}
use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.
the class WebScreens method createWindowBreadCrumbs.
protected WindowBreadCrumbs createWindowBreadCrumbs(@SuppressWarnings("unused") Screen screen) {
WebAppWorkArea appWorkArea = getConfiguredWorkArea();
WindowBreadCrumbs windowBreadCrumbs = new WindowBreadCrumbs(appWorkArea.getMode());
windowBreadCrumbs.setUI(ui);
windowBreadCrumbs.setBeanLocator(beanLocator);
boolean showBreadCrumbs = webConfig.getShowBreadCrumbs() || appWorkArea.getMode() == Mode.SINGLE;
windowBreadCrumbs.setVisible(showBreadCrumbs);
return windowBreadCrumbs;
}
use of com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea in project cuba by cuba-platform.
the class WebScreens method getActiveWorkAreaScreensStream.
protected Stream<Screen> getActiveWorkAreaScreensStream() {
Screen rootScreen = getRootScreenOrNull();
if (rootScreen == null) {
return Stream.empty();
}
WebAppWorkArea workArea = getConfiguredWorkAreaOrNull();
if (workArea == null) {
return Stream.empty();
}
return workArea.getActiveWorkAreaScreensStream();
}
Aggregations