diff --git a/modules/web/src/com/haulmont/cuba/web/WebWindowManager.java b/modules/web/src/com/haulmont/cuba/web/WebWindowManager.java index 0b96e331cb..10be77b8c1 100644 --- a/modules/web/src/com/haulmont/cuba/web/WebWindowManager.java +++ b/modules/web/src/com/haulmont/cuba/web/WebWindowManager.java @@ -50,6 +50,7 @@ public class WebWindowManager extends WindowManager { protected final Map>> stacks = new HashMap>>(); protected final Map windowOpenMode = new LinkedHashMap(); protected final Map windows = new HashMap(); + protected final Map fakeTabs = new HashMap(); } protected App app; @@ -90,6 +91,10 @@ public class WebWindowManager extends WindowManager { return getCurrentWindowData().tabs; } + protected Map getFakeTabs() { + return getCurrentWindowData().fakeTabs; + } + private Map getWindowOpenMode() { return getCurrentWindowData().windowOpenMode; } @@ -177,7 +182,13 @@ public class WebWindowManager extends WindowManager { } protected Layout findTab(Integer hashCode) { - Set> set = getTabs().entrySet(); + Set> set = getFakeTabs().entrySet(); + for (Map.Entry entry : set) { + Window currentWindow = entry.getValue().getCurrentWindow(); + if (hashCode.equals(getWindowHashCode(currentWindow))) + return entry.getKey(); + } + set = getTabs().entrySet(); for (Map.Entry entry : set) { Window currentWindow = entry.getValue().getCurrentWindow(); if (hashCode.equals(getWindowHashCode(currentWindow))) @@ -235,7 +246,7 @@ public class WebWindowManager extends WindowManager { final Window oldWindow = oldBreadCrumbs.getCurrentWindow(); Layout l = new VerticalLayout(); appWindow.getTabSheet().replaceComponent(tab, l); - getCurrentWindowData().tabs.put(l, oldBreadCrumbs); + getCurrentWindowData().fakeTabs.put(l, oldBreadCrumbs); oldWindow.closeAndRun("mainMenu", new Runnable() { public void run() { putToWindowMap(oldWindow, hashCode); @@ -330,8 +341,6 @@ public class WebWindowManager extends WindowManager { final Layout layout = createNewTabLayout(window, caption, description, appWindow, breadCrumbs); - getTabs().put(layout, breadCrumbs); - return layout; } @@ -359,9 +368,10 @@ public class WebWindowManager extends WindowManager { tab = findTab(hashCode); if (tab != null) { tabSheet.replaceComponent(tab, layout); + tabSheet.removeComponent(tab); getTabs().put(layout, (WindowBreadCrumbs) components[0]); - removeFromWindowMap(getTabs().get(tab).getCurrentWindow()); - getTabs().remove(tab); + removeFromWindowMap(getFakeTabs().get(tab).getCurrentWindow()); + getFakeTabs().remove(tab); newTab = tabSheet.getTab(layout); } else { newTab = tabSheet.addTab(layout, formatTabCaption(caption, description), null); diff --git a/modules/web/src/com/haulmont/cuba/web/toolkit/ui/ActionsTabSheet.java b/modules/web/src/com/haulmont/cuba/web/toolkit/ui/ActionsTabSheet.java index 989a2a23d8..3ec7dca56f 100644 --- a/modules/web/src/com/haulmont/cuba/web/toolkit/ui/ActionsTabSheet.java +++ b/modules/web/src/com/haulmont/cuba/web/toolkit/ui/ActionsTabSheet.java @@ -57,8 +57,13 @@ public class ActionsTabSheet extends com.vaadin.ui.TabSheet implements Action.Co if (tab != null) { while (openedComponents.removeElement(tab)) openedComponents.removeElement(tab); - if ((!openedComponents.empty()) && (selected.equals(tab))) - setSelectedTab(openedComponents.pop()); + if ((!openedComponents.empty()) && (selected.equals(tab))) { + Component c = openedComponents.pop(); + while (!components.contains(c) && !openedComponents.isEmpty()) + c = openedComponents.pop(); + + setSelectedTab(c); + } closeHandler.onTabClose(this, tab); } } else {