From 717dacc9a1cfd66d55581061d6439b371f7827d2 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 14 Jul 2008 06:09:29 +0000 Subject: [PATCH] * Implemented lock/unlock for ProcessDialog --- .../src/org/adempiere/webui/Desktop.java | 2 - .../adempiere/webui/apps/ProcessDialog.java | 79 ++++++++++++++++--- .../webui/panel/AbstractADWindowPanel.java | 3 + 3 files changed, 72 insertions(+), 12 deletions(-) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java index 3b5579f397..5869434bfb 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java @@ -189,8 +189,6 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl try { pd.doModal(); } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java index 5e023a67e5..362db8ff10 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java @@ -14,14 +14,17 @@ import org.adempiere.webui.session.SessionManager; import org.compiere.apps.ProcessCtl; import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfoUtil; +import org.compiere.util.ASyncProcess; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Msg; import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Executions; 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.Hbox; import org.zkoss.zul.Html; @@ -53,7 +56,7 @@ import org.zkoss.zul.Html; * @author arboleda - globalqss * - Implement ShowHelp option on processes and reports */ -public class ProcessDialog extends Window implements EventListener +public class ProcessDialog extends Window implements EventListener, ASyncProcess { /** @@ -142,6 +145,7 @@ public class ProcessDialog extends Window implements EventListener private ProcessParameterPanel parameterPanel = null; private ProcessInfo m_pi = null; + private boolean m_isLocked = false; /** @@ -249,13 +253,12 @@ public class ProcessDialog extends Window implements EventListener public void startProcess() { m_pi.setPrintPreview(true); - //can't use asyncprocess, zk ui threading issue + + if (!getDesktop().isServerPushEnabled()) + getDesktop().enableServerPush(true); + this.lockUI(m_pi); - try { - ProcessCtl.process(null, m_WindowNo, parameterPanel, m_pi, null); - } finally { - this.unlockUI(m_pi); - } + ProcessCtl.process(this, m_WindowNo, parameterPanel, m_pi, null); } public boolean isAsap() { @@ -279,11 +282,61 @@ public class ProcessDialog extends Window implements EventListener } public void lockUI(ProcessInfo pi) { - bOK.setLabel(""); - bOK.setEnabled(false); + if (m_isLocked) return; + + m_isLocked = true; + + if (Executions.getCurrent() != null) + Clients.showBusy("Processing...", true); + else + { + try { + //get full control of desktop + Executions.activate(this.getDesktop()); + try { + Clients.showBusy("Processing...", true); + } catch(Error ex){ + throw ex; + } finally{ + //release full control of desktop + Executions.deactivate(this.getDesktop()); + } + } catch (Exception e) { + log.log(Level.WARNING, "Failed to lock UI.", e); + } + } } public void unlockUI(ProcessInfo pi) { + if (!m_isLocked) return; + + m_isLocked = false; + if (Executions.getCurrent() != null) + { + updateUI(pi); + Clients.showBusy(null, false); + } + else + { + try { + //get full control of desktop + Executions.activate(this.getDesktop()); + try { + updateUI(pi); + Clients.showBusy(null, false); + } catch(Error ex){ + throw ex; + } finally{ + //release full control of desktop + Executions.deactivate(this.getDesktop()); + } + } catch (Exception e) { + log.log(Level.WARNING, "Failed to update UI upon unloc.", e); + } + } + } + + private void updateUI(ProcessInfo pi) { ProcessInfoUtil.setLogFromDB(pi); m_messageText.append("

** ") .append(pi.getSummary()) @@ -308,7 +361,6 @@ public class ProcessDialog extends Window implements EventListener // If the process is a silent one and no errors occured, close the dialog if(m_ShowHelp != null && m_ShowHelp.equals("S")) this.dispose(); - } /************************************************************************** @@ -394,4 +446,11 @@ public class ProcessDialog extends Window implements EventListener public boolean isValid() { return valid; } + + public void executeASync(ProcessInfo pi) { + } + + public boolean isUILocked() { + return m_isLocked; + } } // ProcessDialog diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java index 685d42bc8b..09a37db86d 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java @@ -1234,6 +1234,9 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To } public void unlockUI(ProcessInfo pi) { + if (!m_uiLocked) return; + + m_uiLocked = false; boolean notPrint = pi != null && pi.getAD_Process_ID() != curTab.getAD_Process_ID() && pi.isReportingProcess() == false;