From 960a984e5dbf667eec45f1a8e5b04197b86bc893 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 26 Nov 2012 11:12:57 +0800 Subject: [PATCH] IDEMPIERE-369 Master Detail layout improvements. Minor adjustment to the redraw of detailpane. --- .../src/org/adempiere/webui/LayoutUtils.java | 15 +++++++++++ .../adwindow/AbstractADWindowContent.java | 7 +++-- .../webui/adwindow/CompositeADTabbox.java | 27 +++++++++++++------ .../adempiere/webui/adwindow/DetailPane.java | 12 ++++++--- 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java index b2e9ea0f86..b73816d660 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/LayoutUtils.java @@ -12,8 +12,13 @@ *****************************************************************************/ package org.adempiere.webui; +import java.io.IOException; +import java.io.StringWriter; + import org.adempiere.webui.component.Label; +import org.zkoss.zk.au.out.AuOuter; import org.zkoss.zk.au.out.AuScript; +import org.zkoss.zk.ui.AbstractComponent; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.HtmlBasedComponent; import org.zkoss.zk.ui.util.Clients; @@ -124,4 +129,14 @@ public final class LayoutUtils { window.doOverlapped(); Clients.response("_openPopupWindow_", new AuScript(window, script.toString())); } + + public static void redraw(AbstractComponent component) { + StringWriter writer = new StringWriter(1024); + try { + component.redraw(writer); + Clients.response(new AuOuter(component, writer.toString())); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index af7c6d976f..d202c185ea 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -570,8 +570,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements private void initFirstTabpanel() { adTabbox.getSelectedTabpanel().query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords()); - adTabbox.getSelectedTabpanel().activate(true); - Events.echoEvent(new Event("onPostInit", adTabbox.getComponent())); + adTabbox.getSelectedTabpanel().activate(true); + + if (adTabbox.getSelectedTabpanel().isGridView()) { + Events.postEvent(new Event(CompositeADTabbox.ON_POST_INIT_EVENT, adTabbox.getComponent())); + } } /** diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java index dd0babc2ef..8fc0ae6656 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java @@ -23,6 +23,7 @@ import java.util.LinkedHashMap; import java.util.List; import org.adempiere.util.Callback; +import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.component.ADTabListModel; import org.adempiere.webui.component.ADTabListModel.ADTabLabel; import org.adempiere.webui.window.FDialog; @@ -54,6 +55,8 @@ import org.zkoss.zul.Vlayout; */ public class CompositeADTabbox extends AbstractADTabbox { + public static final String ON_POST_INIT_EVENT = "onPostInit"; + public static final String ON_SELECTION_CHANGED_EVENT = "onSelectionChanged"; /** Logger */ @@ -133,6 +136,18 @@ public class CompositeADTabbox extends AbstractADTabbox } } }); + + detailPane.addEventListener(DetailPane.ON_POST_SELECT_TAB_EVENT, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + if ((!ADTabpanel.isUseSplitViewForForm() && !headerTab.isGridView()) + || (detailPane.getSelectedADTabpanel() instanceof ADSortTab)) { + LayoutUtils.redraw(detailPane); + Clients.scrollIntoView(detailPane.getSelectedADTabpanel()); + } + + } + }); } protected void onEditDetail(int row) { @@ -188,10 +203,10 @@ public class CompositeADTabbox extends AbstractADTabbox } }); - layout.addEventListener("onPostInit", new EventListener() { + layout.addEventListener(ON_POST_INIT_EVENT, new EventListener() { @Override public void onEvent(Event event) throws Exception { - layout.invalidate(); + LayoutUtils.redraw(layout); } }); @@ -547,8 +562,8 @@ public class CompositeADTabbox extends AbstractADTabbox detailTab.activate(true); detailTab.setDetailPaneMode(true, isUseVflexForDetailPane()); detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); - if (!ADTabpanel.isUseSplitViewForForm()) { - layout.invalidate(); + if (!ADTabpanel.isUseSplitViewForForm() && !headerTab.isGridView()) { + Events.echoEvent(new Event(DetailPane.ON_REDRAW_EVENT, detailPane)); } } } @@ -647,13 +662,9 @@ public class CompositeADTabbox extends AbstractADTabbox tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); if (tabPanel instanceof ADSortTab) { - detailPane.invalidate(); detailPane.updateToolbar(false, true); } else { tabPanel.dynamicDisplay(0); - if (!ADTabpanel.isUseSplitViewForForm() && !headerTab.isGridView()) { - detailPane.invalidate(); - } } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java index 63646977bc..1adccecc75 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java @@ -44,6 +44,10 @@ import org.zkoss.zul.Toolbar; */ public class DetailPane extends Panel implements EventListener { + public static final String ON_POST_SELECT_TAB_EVENT = "onPostSelectTab"; + + public static final String ON_REDRAW_EVENT = "onRedraw"; + private static final String STATUS_TEXT_ATTRIBUTE = "status.text"; private static final String STATUS_ERROR_ATTRIBUTE = "status.error"; @@ -91,9 +95,7 @@ public class DetailPane extends Panel implements EventListener { @Override public void onEvent(Event event) throws Exception { fireActivateDetailEvent(); - if (!ADTabpanel.isUseSplitViewForForm()) { - Clients.scrollIntoView(getSelectedADTabpanel()); - } + Events.postEvent(new Event(ON_POST_SELECT_TAB_EVENT, DetailPane.this)); } }); tabbox.setSclass("adwindow-detailpane-tabbox"); @@ -107,6 +109,8 @@ public class DetailPane extends Panel implements EventListener { if (!ADTabpanel.isUseSplitViewForForm()) { LayoutUtils.addSclass("adwindow-detailpane-xsplit", this); } + + addEventListener(ON_REDRAW_EVENT, this); } public int getSelectedIndex() { @@ -391,6 +395,8 @@ public class DetailPane extends Panel implements EventListener { showPopup(error, messageContainer); } else if (event.getName().equals(ADTabpanel.ON_DYNAMIC_DISPLAY_EVENT)) { updateProcessToolbar(); + } else if (event.getName().equals(ON_REDRAW_EVENT)) { + LayoutUtils.redraw(this); } }