IDEMPIERE-5275 Tabular Report Re-Run button/close parameter window (#1962)

* IDEMPIERE-5275 Tabular Report Re-Run button/close parameter window

- Fix process info log & error not shown
- Fix re-run missing context variable from menu

* IDEMPIERE-5275 Tabular Report Re-Run button/close parameter window

- turn off auto close after zoom
This commit is contained in:
hengsin 2023-08-09 22:00:00 +08:00 committed by GitHub
parent 3791149ddc
commit 66b7b20619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 1 deletions

View File

@ -2855,4 +2855,20 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
element.setStyle(styleBuilder.toString());
//
}
private ProcessInfo m_pi = null;
/**
* @param pi
*/
public void setProcessInfo(ProcessInfo pi) {
m_pi = pi;
}
/**
* @return ProcessInfo
*/
public ProcessInfo getProcessInfo() {
return m_pi;
}
} // ReportEngine

View File

@ -93,6 +93,8 @@ import com.lowagie.text.pdf.PdfWriter;
*/
public class ProcessDialog extends AbstractProcessDialog implements EventListener<Event>, IHelpContext, ITabOnCloseHandler
{
public static final String SAVED_PREDEFINED_CONTEXT_VARIABLES = "__PredefinedContextVariables__";
/**
* generated serial id
*/
@ -152,6 +154,11 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
m_WindowNo = SessionManager.getAppDesktop().registerWindow(this);
this.setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_WindowNo);
Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", isSOTrx ? "Y" : "N");
//save for rerun of report
if (predefinedContextVariables != null && MProcess.get(AD_Process_ID).isReport())
{
Env.setContext(Env.getCtx(), m_WindowNo, SAVED_PREDEFINED_CONTEXT_VARIABLES, predefinedContextVariables);
}
Env.setPredefinedVariables(Env.getCtx(), m_WindowNo, predefinedContextVariables);
try
{

View File

@ -44,6 +44,7 @@ import org.adempiere.webui.Extensions;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.apps.BusyDialog;
import org.adempiere.webui.apps.ProcessDialog;
import org.adempiere.webui.apps.ProcessModalDialog;
import org.adempiere.webui.apps.WReport;
import org.adempiere.webui.apps.form.WReportCustomization;
@ -52,6 +53,7 @@ import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Mask;
import org.adempiere.webui.component.ProcessInfoDialog;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.component.Window;
@ -92,6 +94,7 @@ import org.compiere.print.ArchiveEngine;
import org.compiere.print.MPrintFormat;
import org.compiere.print.ReportEngine;
import org.compiere.process.ProcessInfo;
import org.compiere.process.ProcessInfoUtil;
import org.compiere.tools.FileUtil;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
@ -1038,8 +1041,25 @@ public class ZkReportViewer extends Window implements EventListener<Event>, IRep
fillComboReport(m_reportEngine.getPrintFormat().get_ID());
revalidate();
if (Window.REPLACE.equals(getAttribute(Window.INSERT_POSITION_KEY))) {
if (m_reportEngine != null && m_reportEngine.getProcessInfo() != null) {
ProcessInfo pi = m_reportEngine.getProcessInfo();
checkProcessInfo(pi);
}
}
} // dynInit
private void checkProcessInfo(ProcessInfo pi) {
ProcessInfoUtil.setLogFromDB(pi);
if (pi.isError() || (pi.getLogs() != null && pi.getLogs().length > 0)) {
ProcessInfoDialog dialog = new ProcessInfoDialog(pi, false);
dialog.setAutoCloseAfterZoom(false);
dialog.setPage(this.getPage());
dialog.doHighlighted();
}
}
/**
* Fill ComboBox comboReport (report options)
* @param AD_PrintFormat_ID item to be selected
@ -1189,6 +1209,9 @@ public class ZkReportViewer extends Window implements EventListener<Event>, IRep
if (getDesktop() != null)
clearTabOnCloseHandler();
}
ProcessInfo pi = dialog.getProcessInfo();
if (pi != null)
checkProcessInfo(pi);
}
}
else if(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT.equals(event.getName())) {
@ -1572,6 +1595,14 @@ public class ZkReportViewer extends Window implements EventListener<Event>, IRep
if(!Util.isEmpty(showHelp))
pi.setShowHelp(showHelp);
setTabOnCloseHandler();
String predefined = (String) getAttribute(ProcessDialog.SAVED_PREDEFINED_CONTEXT_VARIABLES);
if (!Util.isEmpty(predefined, true)) {
Env.setContext(Env.getCtx(), m_WindowNo, ProcessDialog.SAVED_PREDEFINED_CONTEXT_VARIABLES, predefined);
Env.setPredefinedVariables(Env.getCtx(), m_WindowNo, predefined);
}
if (getAttribute("IsSOTrx") != null) {
Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", getAttribute("IsSOTrx").toString());
}
ProcessModalDialog processModalDialog = new ProcessModalDialog(this, m_WindowNo, pi);
ZKUpdateUtil.setWindowWidthX(processModalDialog, 850);
this.getParent().appendChild(processModalDialog);
@ -1782,6 +1813,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, IRep
}
private boolean ToolBarMenuRestictionLoaded = false;
public void updateToolbarAccess(int AD_Window_ID, int AD_Process_ID) {
if (ToolBarMenuRestictionLoaded)
return;

View File

@ -17,11 +17,14 @@
package org.adempiere.webui.window;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.apps.ProcessDialog;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.part.WindowContainer;
import org.adempiere.webui.session.SessionManager;
import org.compiere.print.ReportEngine;
import org.compiere.print.ReportViewerProvider;
import org.compiere.util.Env;
import org.compiere.util.Util;
import org.zkoss.zk.ui.Executions;
/**
@ -55,6 +58,11 @@ public class ZkReportViewerProvider implements ReportViewerProvider {
if(report.isReplaceTabContent()) {
viewer.setAttribute(Window.INSERT_POSITION_KEY, Window.REPLACE);
viewer.setAttribute(WindowContainer.REPLACE_WINDOW_NO, report.getWindowNo());
String predefined = Env.getContext(Env.getCtx(), report.getWindowNo(), ProcessDialog.SAVED_PREDEFINED_CONTEXT_VARIABLES);
if (!Util.isEmpty(predefined, true)) {
viewer.setAttribute(ProcessDialog.SAVED_PREDEFINED_CONTEXT_VARIABLES, predefined);
}
viewer.setAttribute("IsSOTrx", Env.getContext(Env.getCtx(), report.getWindowNo(), "IsSOTrx"));
}
viewer.setAttribute(WindowContainer.DEFER_SET_SELECTED_TAB, Boolean.TRUE);
SessionManager.getAppDesktop().showWindow(viewer);

View File

@ -312,6 +312,7 @@ public class ReportCtl
}
re.setLanguageID(pi.getLanguageID());
re.setIsReplaceTabContent(pi.isReplaceTabContent());
re.setProcessInfo(pi);
createOutput(re, pi.isPrintPreview(), null);
return true;
} // startStandardReport