diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java index b90d50598a..c76b74ff47 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java @@ -752,7 +752,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl DesktopTabpanel tabPanel = new DesktopTabpanel(); wnd.createPart(tabPanel); - windowContainer.addWindow(tabPanel, wnd.getTitle(), true); + windowContainer.insertAfter(windowContainer.getSelectedTab(), tabPanel, wnd.getTitle(), true, true); } /** @@ -874,7 +874,10 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl window.setParent(tabPanel); String title = window.getTitle(); window.setTitle(null); - windowContainer.addWindow(tabPanel, title, true); + if (Window.INSERT_NEXT.equals(window.getAttribute(Window.INSERT_POSITION_KEY))) + windowContainer.insertAfter(windowContainer.getSelectedTab(), tabPanel, title, true, true); + else + windowContainer.addWindow(tabPanel, title, true); } /** diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Window.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Window.java index 4e4656cc11..3d6da3d91c 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Window.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Window.java @@ -27,18 +27,26 @@ public class Window extends org.zkoss.zul.Window { private static final long serialVersionUID = 1L; + /*** Show as modal window ***/ public static final String MODE_MODAL = "modal"; - + /*** Show as popup window ***/ public static final String MODE_POPUP = "popup"; - + /*** Show as floating window ***/ public static final String MODE_OVERLAPPED = "overlapped"; - + /*** Add to the tabbed window container ***/ public static final String MODE_EMBEDDED = "embedded"; - + /*** Show as fake modal window ***/ public static final String MODE_HIGHLIGHTED = "highlighted"; - + /*** attribute key to store window display mode ***/ public static final String MODE_KEY = "mode"; + /*** attribute key to store insert position for embedded mode window ***/ + public static final String INSERT_POSITION_KEY = "insertPosition"; + /*** Append to the end of tabs of the tabbed window container ***/ + public static final String INSERT_END = "insertEnd"; + /*** Insert next to the active tab of the tabbed window container ***/ + public static final String INSERT_NEXT = "insertNext"; + public Window() { super(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java b/zkwebui/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java index 313fadfa0a..0c4d0645e5 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java @@ -42,6 +42,11 @@ public class WindowContainer extends AbstractUIPart implements EventListener { } + /** + * + * @param tb + * @return WindowContainer + */ public static WindowContainer createFrom(Tabbox tb) { WindowContainer wc = new WindowContainer(); @@ -53,7 +58,6 @@ public class WindowContainer extends AbstractUIPart implements EventListener protected Component doCreatePart(Component parent) { tabbox = new Tabbox(); -// tabbox.setSclass("desktop-tb"); Tabpanels tabpanels = new Tabpanels(); Tabs tabs = new Tabs(); @@ -72,13 +76,39 @@ public class WindowContainer extends AbstractUIPart implements EventListener return tabbox; } - + + /** + * + * @param comp + * @param title + * @param closeable + */ public void addWindow(Component comp, String title, boolean closeable) { addWindow(comp, title, closeable, true); } - - public void addWindow(Component comp, String title, boolean closeable, boolean enable) + + /** + * + * @param comp + * @param title + * @param closeable + * @param enable + */ + public void addWindow(Component comp, String title, boolean closeable, boolean enable) + { + insertBefore(null, comp, title, closeable, enable); + } + + /** + * + * @param refTab + * @param comp + * @param title + * @param closeable + * @param enable + */ + public void insertBefore(Tab refTab, Component comp, String title, boolean closeable, boolean enable) { Tab tab = new Tab(); title = title.replaceAll("[&]", ""); @@ -93,7 +123,6 @@ public class WindowContainer extends AbstractUIPart implements EventListener tab.setLabel(title); } tab.setClosable(closeable); -// tab.setHeight("20px"); Tabpanel tabpanel = null; if (comp instanceof Tabpanel) { @@ -107,20 +136,53 @@ public class WindowContainer extends AbstractUIPart implements EventListener tabpanel.setZclass("desktop-tabpanel"); tabpanel.setStyle("position: absolute;"); - tabbox.getTabs().appendChild(tab); - tabbox.getTabpanels().appendChild(tabpanel); + if (refTab == null) + { + tabbox.getTabs().appendChild(tab); + tabbox.getTabpanels().appendChild(tabpanel); + } + else + { + org.zkoss.zul.Tabpanel refpanel = refTab.getLinkedPanel(); + tabbox.getTabs().insertBefore(tab, refTab); + tabbox.getTabpanels().insertBefore(tabpanel, refpanel); + } if (enable) setSelectedTab(tab); deferLayout(); } + + /** + * + * @param refTab + * @param comp + * @param title + * @param closeable + * @param enable + */ + public void insertAfter(Tab refTab, Component comp, String title, boolean closeable, boolean enable) + { + if (refTab == null) + addWindow(comp, title, closeable, enable); + else + insertBefore((Tab)refTab.getNextSibling(), comp, title, closeable, enable); + } + /** + * + * @param tab + */ public void setSelectedTab(Tab tab) { tabbox.setSelectedTab(tab); } + /** + * + * @return true if successfully close the active window + */ public boolean closeActiveWindow() { Tab tab = (Tab) tabbox.getSelectedTab(); @@ -131,11 +193,20 @@ public class WindowContainer extends AbstractUIPart implements EventListener return false; } + /** + * + * @return Tab + */ public Tab getSelectedTab() { return (Tab) tabbox.getSelectedTab(); } // Elaine 2008/07/21 + /** + * @param tabNo + * @param title + * @param tooltip + */ public void setTabTitle(int tabNo, String title, String tooltip) { org.zkoss.zul.Tabs tabs = tabbox.getTabs(); @@ -145,6 +216,9 @@ public class WindowContainer extends AbstractUIPart implements EventListener } // + /** + * @param event + */ public void onEvent(Event event) throws Exception { if (Events.ON_SELECT.equals(event.getName())) deferLayout(); @@ -159,6 +233,9 @@ public class WindowContainer extends AbstractUIPart implements EventListener } } + /** + * @return Tabbox + */ public Tabbox getComponent() { return tabbox; } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewerProvider.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewerProvider.java index 9d2324cb31..4405b7b6af 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewerProvider.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewerProvider.java @@ -15,6 +15,7 @@ public class ZkJRViewerProvider implements JRViewerProvider { viewer.setWidth("95%"); viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED); + viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT); SessionManager.getAppDesktop().showWindow(viewer); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewerProvider.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewerProvider.java index d51d92ec68..abde054967 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewerProvider.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewerProvider.java @@ -33,6 +33,7 @@ public class ZkReportViewerProvider implements ReportViewerProvider { viewer.setWidth("95%"); viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED); + viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT); SessionManager.getAppDesktop().showWindow(viewer); } } \ No newline at end of file