diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java index 84cb8ec12c..6e18c2f15e 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java @@ -94,8 +94,10 @@ import org.zkoss.zul.Treeitem; public class ADTabpanel extends Div implements Evaluatee, EventListener, DataStatusListener, IADTabpanel, VetoableChangeListener { - - private static final long serialVersionUID = 6811039639239312863L; + /** + * generated serial version ID + */ + private static final long serialVersionUID = 6945934489328360251L; private static final CLogger logger; @@ -985,6 +987,7 @@ DataStatusListener, IADTabpanel, VetoableChangeListener listPanel.setVisible(!formComponent.isVisible()); if (listPanel.isVisible()) { listPanel.refresh(gridTab); + listPanel.scrollToCurrentRow(); } else { listPanel.deactivate(); } @@ -1145,6 +1148,10 @@ DataStatusListener, IADTabpanel, VetoableChangeListener return listPanel.isVisible(); } + /** + * @param gTab + * @return embedded panel or null if not found + */ public IADTabpanel findEmbeddedPanel(GridTab gTab) { IADTabpanel panel = null; for(EmbeddedPanel ep : includedPanel) { @@ -1154,5 +1161,13 @@ DataStatusListener, IADTabpanel, VetoableChangeListener } return panel; } + + /** + * + * @return GridPanel + */ + public GridPanel getGridView() { + return listPanel; + } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADWindowPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADWindowPanel.java index c513fc4185..307334d720 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADWindowPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADWindowPanel.java @@ -32,6 +32,7 @@ import org.adempiere.webui.component.IADTab; import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabs; +import org.adempiere.webui.part.ITabOnSelectHandler; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.UserPreference; import org.compiere.model.GridWindow; @@ -182,6 +183,21 @@ public class ADWindowPanel extends AbstractADWindowPanel keyListener.setAutoBlur(false); } + layout.setAttribute(ITabOnSelectHandler.ATTRIBUTE_KEY, new ITabOnSelectHandler() { + public void onSelect() { + IADTab adTab = getADTab(); + if (adTab != null) { + IADTabpanel iadTabpanel = adTab.getSelectedTabpanel(); + if (iadTabpanel != null && iadTabpanel instanceof ADTabpanel) { + ADTabpanel adTabpanel = (ADTabpanel) iadTabpanel; + if (adTabpanel.isGridView()) { + adTabpanel.getGridView().scrollToCurrentRow(); + } + } + } + } + }); + return layout; } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ITabOnCloseHandler.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ITabOnCloseHandler.java index e626018fdf..a643a772e1 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ITabOnCloseHandler.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ITabOnCloseHandler.java @@ -1,7 +1,25 @@ +/****************************************************************************** + * Copyright (C) 2010 Low Heng Sin * + * Copyright (C) 2010 Idalica Corporation * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ package org.adempiere.webui.panel; import org.adempiere.webui.component.Tabpanel; +/** + * + * @author hengsin + * + */ public interface ITabOnCloseHandler { public void onClose(Tabpanel tabPanel); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/part/ITabOnSelectHandler.java b/zkwebui/WEB-INF/src/org/adempiere/webui/part/ITabOnSelectHandler.java new file mode 100644 index 0000000000..a2ab4770f9 --- /dev/null +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/part/ITabOnSelectHandler.java @@ -0,0 +1,30 @@ +/****************************************************************************** + * Copyright (C) 2010 Low Heng Sin * + * Copyright (C) 2010 Idalica Corporation * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.adempiere.webui.part; + +/** + * + * @author hengsin + * + */ +public interface ITabOnSelectHandler { + + public final static String ATTRIBUTE_KEY = "TabOnSelectHandler"; + + /** + * handle tab on_select event + */ + public void onSelect(); + +} 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 479a47f233..a4375b0be4 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java @@ -18,7 +18,13 @@ import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanels; import org.adempiere.webui.component.Tabs; +import org.adempiere.webui.panel.ADTabpanel; import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zk.ui.event.Events; +import org.zkoss.zkex.zul.Borderlayout; +import org.zkoss.zkex.zul.Center; /** * @@ -114,6 +120,20 @@ public class WindowContainer extends AbstractUIPart tab.setLabel(title); } tab.setClosable(closeable); + + // fix scroll position lost coming back into a grid view tab + tab.addEventListener(Events.ON_SELECT, new EventListener() { + public void onEvent(Event event) throws Exception { + Tab tab = (Tab)event.getTarget(); + org.zkoss.zul.Tabpanel panel = tab.getLinkedPanel(); + Component component = panel.getFirstChild(); + if (component != null && component.getAttribute(ITabOnSelectHandler.ATTRIBUTE_KEY) instanceof ITabOnSelectHandler) + { + ITabOnSelectHandler handler = (ITabOnSelectHandler) component.getAttribute(ITabOnSelectHandler.ATTRIBUTE_KEY); + handler.onSelect(); + } + } + }); Tabpanel tabpanel = null; if (comp instanceof Tabpanel) {