From a86e23932acbcbc243fdc7a1134b96c6d8e86536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Tak=C3=A1cs?= <93127072+PeterTakacs300@users.noreply.github.com> Date: Fri, 21 Jul 2023 06:57:58 +0200 Subject: [PATCH] IDEMPIERE-5790 - Improve Report Refresh functionality (#1923) * IDEMPIERE-5790 - Improve Report Refresh functionality * IDEMPIERE-5790 - fix not setting Language in combobox * IDEMPIERE-5790 - bug fixes - fix preview type changing to SysConfig default after refresh - now it stay on the selected type - language is not set on process audit record when refreshing --- .../webui/window/ZkReportViewer.java | 51 ++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) 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 f8bff824d8..2647b51028 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 @@ -27,6 +27,7 @@ import java.util.Calendar; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.Properties; import java.util.function.Supplier; import java.util.logging.Level; @@ -77,6 +78,7 @@ import org.compiere.model.MAttachment; import org.compiere.model.MAuthorizationAccount; import org.compiere.model.MClient; import org.compiere.model.MLanguage; +import org.compiere.model.MProcess; import org.compiere.model.MQuery; import org.compiere.model.MRole; import org.compiere.model.MSysConfig; @@ -533,7 +535,16 @@ public class ZkReportViewer extends Window implements EventListener, IRep { toolBar.appendChild(wLanguage.getComponent()); } - wLanguage.setValue(m_reportEngine.getLanguageID()); + // Init Language from Printformat + int languageID = 0; + if(m_reportEngine.getPrintFormat() != null && m_reportEngine.getPrintFormat().getLanguage() != null) { + MLanguage language = MLanguage.get(m_ctx, m_reportEngine.getPrintFormat().getLanguage()); + if(language != null) + languageID = language.getAD_Language_ID(); + } + if(m_reportEngine.getLanguageID() > 0) + languageID = m_reportEngine.getLanguageID(); + wLanguage.setValue(languageID); wLanguage.getComponent().addEventListener(Events.ON_SELECT, this); } catch (Exception e) { log.log(Level.SEVERE, e.getLocalizedMessage()); @@ -1233,7 +1244,7 @@ public class ZkReportViewer extends Window implements EventListener, IRep else if (e.getTarget() == bWizard) cmd_Wizard(); else if (e.getTarget() == bRefresh) - cmd_report(); + cmd_refresh(); else if (e.getTarget() == bReRun) cmd_reRun(); // @@ -1518,15 +1529,38 @@ public class ZkReportViewer extends Window implements EventListener, IRep } } // cmd_report + /** + * Refresh with same parameters + */ + private void cmd_refresh() { + int AD_Process_ID = m_reportEngine.getPrintInfo() != null ? m_reportEngine.getPrintInfo().getAD_Process_ID() : 0; + if(AD_Process_ID <= 0) + this.cmd_report(); + else + this.cmd_reRun(MProcess.SHOWHELP_RunSilently_TakeDefaults); + } + /** * Refresh With Parameters */ private void cmd_reRun() { + this.cmd_reRun(null); + } + + /** + * Refresh With Parameters + * @param showHelp + */ + private void cmd_reRun(String showHelp) { int AD_Process_ID = m_reportEngine.getPrintInfo() != null ? m_reportEngine.getPrintInfo().getAD_Process_ID() : 0; if(AD_Process_ID <= 0) return; ProcessInfo pi = new ProcessInfo("RefreshWithParameters", AD_Process_ID); + pi.setLanguageID(m_reportEngine.getLanguageID()); + pi.setReportType(m_reportEngine.getReportType()); pi.setReplaceTabContent(); + if(!Util.isEmpty(showHelp)) + pi.setShowHelp(showHelp); setTabOnCloseHandler(); ProcessModalDialog processModalDialog = new ProcessModalDialog(this, m_WindowNo, pi); ZKUpdateUtil.setWindowWidthX(processModalDialog, 850); @@ -1553,9 +1587,22 @@ public class ZkReportViewer extends Window implements EventListener, IRep } } + protected void setPreviewType() { + String type = Objects.toString(previewType.getValue()); + + // get default from SysConfig + if(type == null) { + type = m_reportEngine.getPrintFormat().isForm() + ? MSysConfig.getValue(MSysConfig.ZK_REPORT_FORM_OUTPUT_TYPE,PDF_OUTPUT_TYPE,Env.getAD_Client_ID(m_ctx),Env.getAD_Org_ID(m_ctx)) + : MSysConfig.getValue(MSysConfig.ZK_REPORT_TABLE_OUTPUT_TYPE,PDF_OUTPUT_TYPE,Env.getAD_Client_ID(m_ctx),Env.getAD_Org_ID(m_ctx)); + } + m_reportEngine.setReportType(type); + } + private void postRenderReportEvent() { showBusyDialog(); setLanguage(); + setPreviewType(); Events.echoEvent(ON_RENDER_REPORT_EVENT, this, null); updateRowCount(); }