From 9678aa617bed49c6fafe037301bcc2c678548573 Mon Sep 17 00:00:00 2001 From: hieplq Date: Wed, 30 Jul 2014 16:03:12 +0700 Subject: [PATCH] IDEMPIERE-2109:make show ProcessInfoDialog as common function --- .../adwindow/AbstractADWindowContent.java | 14 ++------ .../webui/component/ProcessInfoDialog.java | 35 ++++++++++++++++++- 2 files changed, 37 insertions(+), 12 deletions(-) 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 2e6ab1c288..28db4ec827 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 @@ -3063,17 +3063,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements ProcessInfoUtil.setLogFromDB(pi); ProcessInfoLog m_logs[] = pi.getLogs(); statusBar.setStatusLine(pi.getSummary(), pi.isError(),m_logs); - if (m_logs != null) { - ProcessInfoDialog dialog = new ProcessInfoDialog(AEnv.getDialogHeader(ctx, curWindowNo),AEnv.getDialogHeader(ctx, curWindowNo), m_logs); - dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { - @Override - public void onEvent(Event event) throws Exception { - hideBusyMask(); - } - }); - getComponent().getParent().appendChild(dialog); - showBusyMask(dialog); - LayoutUtils.openOverlappedWindow(this.getComponent(),dialog,"middle_center"); + + if (m_logs != null && m_logs.length > 0) { + ProcessInfoDialog.showProcessInfo(pi, curWindowNo, getComponent(), false); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ProcessInfoDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ProcessInfoDialog.java index 85f6695a7d..89fb46a532 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ProcessInfoDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/ProcessInfoDialog.java @@ -16,17 +16,22 @@ package org.adempiere.webui.component; import java.text.SimpleDateFormat; +import org.adempiere.webui.ISupportMask; +import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.apps.AEnv; +import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.factory.ButtonFactory; +import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfoLog; +import org.compiere.process.ProcessInfoUtil; import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Msg; import org.zkoss.zhtml.Text; +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.A; import org.zkoss.zul.Hbox; import org.zkoss.zul.Image; import org.zkoss.zul.Separator; @@ -162,4 +167,32 @@ public class ProcessInfoDialog extends Window implements EventListener { this.detach(); } } + + /** + * after run a process, call this function to show result in a dialog + * @param pi + * @param windowNo + * @param comp + * @param needFillLogFromDb if ProcessInfoUtil.setLogFromDB(pi) is called by outer function, + * just pass false, other pass true to avoid duplicate message + */ + public static void showProcessInfo (ProcessInfo pi, int windowNo, final Component comp, boolean needFillLogFromDb) { + // Get Log Info + if (needFillLogFromDb) + ProcessInfoUtil.setLogFromDB(pi); + ProcessInfoLog m_logs[] = pi.getLogs(); + + if (m_logs != null && m_logs.length > 0) { + ProcessInfoDialog dialog = new ProcessInfoDialog(AEnv.getDialogHeader(Env.getCtx(), windowNo),AEnv.getDialogHeader(Env.getCtx(), windowNo), m_logs); + final ISupportMask supportMask = LayoutUtils.showWindowWithMask(dialog, comp, LayoutUtils.OVERLAP_PARENT);; + dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + supportMask.hideMask(); + } + }); + + } + + } }