From e1115bd294655b55f6cfe8cbb726b735caa3c7d1 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 4 Dec 2012 16:50:17 +0800 Subject: [PATCH] IDEMPIERE-522 Zk: Random Freeze of screen update. Modify process and form to only block the parent window instead of the whole browser. --- .../webui/adwindow/ADWindowContent.java | 22 +------ .../adwindow/AbstractADWindowContent.java | 59 +++++++++++-------- .../adempiere/webui/component/Tabpanel.java | 17 +----- .../adempiere/webui/panel/WAttachment.java | 2 - .../webui/panel/action/ReportAction.java | 14 ++++- .../src/org/adempiere/webui/window/WChat.java | 4 -- .../adempiere/webui/window/ZkJRViewer.java | 18 +----- .../webui/window/ZkReportViewer.java | 18 +----- 8 files changed, 49 insertions(+), 105 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java index 85daf1752f..48ea779551 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java @@ -23,13 +23,10 @@ package org.adempiere.webui.adwindow; -import java.util.List; import java.util.Properties; import org.adempiere.webui.LayoutUtils; -import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabpanel; -import org.adempiere.webui.component.Tabs; import org.adempiere.webui.panel.ITabOnCloseHandler; import org.adempiere.webui.session.SessionManager; import org.compiere.util.CLogger; @@ -162,24 +159,9 @@ public class ADWindowContent extends AbstractADWindowContent class TabOnCloseHanlder implements ITabOnCloseHandler { public void onClose(Tabpanel tabPanel) { - if (ADWindowContent.this.onExit()) { + if (ADWindowContent.this.onExit()) { Tab tab = tabPanel.getLinkedTab(); - Tabbox tabbox = (Tabbox) tab.getTabbox(); - if (tabbox.getSelectedTab() == tab) { - Tabs tabs = (Tabs) tabbox.getTabs(); - List childs = tabs.getChildren(); - for(int i = 0; i < childs.size(); i++) { - if (childs.get(i) == tab) { - if (i > 0) - tabbox.setSelectedIndex((i-1)); - break; - } - } - } else { - tabbox.getSelectedPanel().invalidate(); - } - tabPanel.detach(); - tab.detach(); + tab.close(); if (getWindowNo() > 0) SessionManager.getAppDesktop().unregisterWindow(getWindowNo()); } 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 11c4ea3ab8..0eab965c83 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 @@ -850,15 +850,24 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements EventListener listener = new EventListener() { @Override - public void onEvent(Event event) throws Exception { + public void onEvent(Event event) throws Exception { adTabbox.getSelectedGridTab().loadAttachments(); // reload toolbar.getButton("Attachment").setPressed(adTabbox.getSelectedGridTab().hasAttachment()); - focusToActivePanel(); + focusToActivePanel(); } }; // Attachment va = - new WAttachment ( curWindowNo, adTabbox.getSelectedGridTab().getAD_AttachmentID(), - adTabbox.getSelectedGridTab().getAD_Table_ID(), record_ID, null, listener); + WAttachment win = new WAttachment ( curWindowNo, adTabbox.getSelectedGridTab().getAD_AttachmentID(), + adTabbox.getSelectedGridTab().getAD_Table_ID(), record_ID, null, listener); + win.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + Clients.clearBusy(getComponent()); + } + }); + getComponent().getParent().appendChild(win); + Clients.showBusy(getComponent(), " "); + LayoutUtils.openOverlappedWindow(getComponent(), win, "middle_center"); } public void onChat() @@ -890,12 +899,16 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements WChat chat = new WChat(curWindowNo, adTabbox.getSelectedGridTab().getCM_ChatID(), adTabbox.getSelectedGridTab().getAD_Table_ID(), recordId, description, null); chat.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { @Override - public void onEvent(Event event) throws Exception { + public void onEvent(Event event) throws Exception { adTabbox.getSelectedGridTab().loadChats(); toolbar.getButton("Chat").setPressed(adTabbox.getSelectedGridTab().hasChat()); focusToActivePanel(); + Clients.clearBusy(getComponent()); } }); + getComponent().getParent().appendChild(chat); + Clients.showBusy(getComponent(), " "); + LayoutUtils.openOverlappedWindow(getComponent(), chat, "middle_center"); chat.showWindow(); } @@ -969,6 +982,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements boolean b = breadCrumb.getStatusError(); onRefresh(true, false); breadCrumb.setStatusLine(s, b); + Clients.clearBusy(getComponent()); } else if (ADTabpanel.ON_DYNAMIC_DISPLAY_EVENT.equals(event.getName())) { @@ -2023,14 +2037,16 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements hbox.setPack("end"); hbox.setHflex("1"); - messagePanel.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED); messagePanel.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { @Override - public void onEvent(Event event) throws Exception { + public void onEvent(Event event) throws Exception { focusToActivePanel(); + Clients.clearBusy(getComponent()); } }); - AEnv.showWindow(messagePanel); + getComponent().getParent().appendChild(messagePanel); + Clients.showBusy(getComponent(), " "); + LayoutUtils.openOverlappedWindow(getComponent(), messagePanel, "middle_center"); } // @@ -2059,9 +2075,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements ProcessModalDialog dialog = new ProcessModalDialog(AbstractADWindowContent.this, getWindowNo(), AD_Process_ID,table_ID, record_ID, true); if (dialog.isValid()) { - dialog.setPosition("center"); - dialog.setPage(AbstractADWindowContent.this.getComponent().getPage()); - dialog.doHighlighted(); + dialog.setWidth("500px"); + dialog.setBorder("normal"); + Clients.showBusy(getComponent(), " "); + getComponent().getParent().appendChild(dialog); + LayoutUtils.openOverlappedWindow(getComponent(), dialog, "middle_center"); } } } @@ -2329,12 +2347,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements { final int recordIdParam = record_ID; getComponent().getParent().appendChild(win); - win.setStyle("position: absolute;"); win.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { public void onEvent(Event event) throws Exception { Clients.clearBusy(getComponent()); if (!win.isStartProcess()) { - Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent())); return; } boolean startWOasking = true; @@ -2360,15 +2376,13 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements { Clients.showBusy(getComponent(), " "); final WCreateFromWindow window = (WCreateFromWindow) cf.getWindow(); - window.setStyle("position: absolute"); window.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { @Override - public void onEvent(Event event) throws Exception { - Clients.clearBusy(getComponent()); + public void onEvent(Event event) throws Exception { if (!window.isCancel()) { onRefresh(true, false); } - Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent())); + Clients.clearBusy(getComponent()); } }); getComponent().getParent().appendChild(window); @@ -2512,13 +2526,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements if (mode == Mode.HIGHLIGHTED || mode == Mode.MODAL) { form.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { @Override - public void onEvent(Event event) throws Exception { - Clients.clearBusy(getComponent()); + public void onEvent(Event event) throws Exception { onRefresh(true, false); - Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent())); + Clients.clearBusy(getComponent()); } }); - form.setStyle("position: absolute;"); getComponent().getParent().appendChild(form); Clients.showBusy(getComponent(), " "); LayoutUtils.openOverlappedWindow(getComponent(), form, "middle_center"); @@ -2533,7 +2545,6 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements if (dialog.isValid()) { - dialog.setStyle("position: absolute;"); dialog.setWidth("500px"); dialog.setBorder("normal"); Clients.showBusy(getComponent(), " "); @@ -2637,12 +2648,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements if (Executions.getCurrent() != null) { - Clients.clearBusy(getComponent()); if (notPrint) // refresh if not print { updateUI(pi); } - Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent())); } else { @@ -2650,12 +2659,10 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements //acquire desktop, 2 second timeout Executions.activate(getComponent().getDesktop(), 2000); try { - Clients.clearBusy(getComponent()); if (notPrint) // refresh if not print { updateUI(pi); } - Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, getComponent())); } catch(Error ex){ throw ex; } finally{ diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Tabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Tabpanel.java index 09d7324df4..31168648b3 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Tabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Tabpanel.java @@ -17,8 +17,6 @@ package org.adempiere.webui.component; -import java.util.List; - import org.adempiere.webui.panel.ITabOnCloseHandler; import org.zkoss.zul.Tab; @@ -66,20 +64,7 @@ public class Tabpanel extends org.zkoss.zul.Tabpanel onCloseHandler.onClose(this); else { Tab tab = this.getLinkedTab(); - Tabbox tabbox = (Tabbox) tab.getTabbox(); - if (tabbox.getSelectedTab() == tab) { - Tabs tabs = (Tabs) tabbox.getTabs(); - List childs = tabs.getChildren(); - for(int i = 0; i < childs.size(); i++) { - if (childs.get(i) == tab) { - if (i > 0) - tabbox.setSelectedIndex((i-1)); - break; - } - } - } - this.detach(); - tab.detach(); + tab.close(); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java index 5fa8a3008a..4a0278ff4a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java @@ -186,8 +186,6 @@ public class WAttachment extends Window implements EventListener Clients.response(new AuScript(null, script)); } - //enter modal - doHighlighted(); } catch (Exception e) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ReportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ReportAction.java index 742cdf8031..da3a9c5474 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ReportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ReportAction.java @@ -53,6 +53,7 @@ import org.zkoss.util.media.AMedia; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; +import org.zkoss.zk.ui.util.Clients; import org.zkoss.zul.Div; import org.zkoss.zul.Filedownload; import org.zkoss.zul.Hbox; @@ -93,6 +94,7 @@ public class ReportAction implements EventListener winReport.setClosable(true); winReport.setBorder("normal"); winReport.setStyle("position:absolute"); + winReport.addEventListener("onValidate", this); cboPrintFormat.setMold("select"); cboPrintFormat.getItems().clear(); @@ -162,7 +164,6 @@ public class ReportAction implements EventListener confirmPanel.addActionListener(this); } - winReport.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED); LayoutUtils.openPopupWindow(panel.getToolbar().getButton("Report"), winReport, "after_start"); } @@ -170,8 +171,11 @@ public class ReportAction implements EventListener public void onEvent(Event event) throws Exception { if(event.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) winReport.onClose(); - else if(event.getTarget().getId().equals(ConfirmPanel.A_OK)) - validate(); + else if(event.getTarget().getId().equals(ConfirmPanel.A_OK)) { + winReport.setVisible(false); + Clients.showBusy(panel.getComponent(), null); + Events.echoEvent("onValidate", winReport, null); + } else if(event.getTarget() == cboPrintFormat) { ListItem li = cboPrintFormat.getSelectedItem(); @@ -183,6 +187,10 @@ public class ReportAction implements EventListener } else if(event.getTarget() == chkExport) cboExportType.setVisible(chkExport.isChecked()); + else if (event.getName().equals("onValidate")) { + validate(); + Clients.clearBusy(panel.getComponent()); + } } private void validate() diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WChat.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WChat.java index 2b7beeede9..fd7c45f6ce 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WChat.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WChat.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.Map; import java.util.logging.Level; -import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.component.Button; import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Label; @@ -40,7 +39,6 @@ import org.compiere.util.Util; 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.zul.Borderlayout; import org.zkoss.zul.Center; import org.zkoss.zul.Div; @@ -109,8 +107,6 @@ public class WChat extends Window implements EventListener, DialogEvents public void showWindow() { - this.setAttribute(MODE_KEY, MODE_HIGHLIGHTED); - AEnv.showWindow(this); newText.focus(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java index d4ea821115..2c08ab83c0 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java @@ -2,7 +2,6 @@ package org.adempiere.webui.window; import java.io.File; import java.io.FileOutputStream; -import java.util.List; import java.util.logging.Level; import javax.servlet.http.HttpServletRequest; @@ -18,9 +17,7 @@ import net.sf.jasperreports.engine.export.JRXlsExporterParameter; import org.adempiere.exceptions.AdempiereException; import org.adempiere.webui.component.Listbox; -import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabpanel; -import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.Window; import org.adempiere.webui.panel.ITabOnCloseHandler; import org.adempiere.webui.session.SessionManager; @@ -222,20 +219,7 @@ public class ZkJRViewer extends Window implements EventListener, ITabOnCl @Override public void onClose(Tabpanel tabPanel) { Tab tab = tabPanel.getLinkedTab(); - Tabbox tabbox = (Tabbox) tab.getTabbox(); - if (tabbox.getSelectedTab() == tab) { - Tabs tabs = (Tabs) tabbox.getTabs(); - List childs = tabs.getChildren(); - for(int i = 0; i < childs.size(); i++) { - if (childs.get(i) == tab) { - if (i > 0) - tabbox.setSelectedIndex((i-1)); - break; - } - } - } - tabPanel.detach(); - tab.detach(); + tab.close(); cleanUp(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index e04a8b9415..b0424021f6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -24,7 +24,6 @@ import java.io.StringWriter; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.List; import java.util.Properties; import java.util.logging.Level; @@ -41,9 +40,7 @@ import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Label; import org.adempiere.webui.component.ListItem; import org.adempiere.webui.component.Listbox; -import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabpanel; -import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.Window; import org.adempiere.webui.event.DialogEvents; @@ -615,20 +612,7 @@ public class ZkReportViewer extends Window implements EventListener, ITab @Override public void onClose(Tabpanel tabPanel) { Tab tab = tabPanel.getLinkedTab(); - Tabbox tabbox = (Tabbox) tab.getTabbox(); - if (tabbox.getSelectedTab() == tab) { - Tabs tabs = (Tabs) tabbox.getTabs(); - List childs = tabs.getChildren(); - for(int i = 0; i < childs.size(); i++) { - if (childs.get(i) == tab) { - if (i > 0) - tabbox.setSelectedIndex((i-1)); - break; - } - } - } - tabPanel.detach(); - tab.detach(); + tab.close(); cleanUp(); }