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
This commit is contained in:
Peter Takács 2023-07-21 06:57:58 +02:00 committed by GitHub
parent a72caac1fc
commit a86e23932a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 49 additions and 2 deletions

View File

@ -27,6 +27,7 @@ import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Properties; import java.util.Properties;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.logging.Level; import java.util.logging.Level;
@ -77,6 +78,7 @@ import org.compiere.model.MAttachment;
import org.compiere.model.MAuthorizationAccount; import org.compiere.model.MAuthorizationAccount;
import org.compiere.model.MClient; import org.compiere.model.MClient;
import org.compiere.model.MLanguage; import org.compiere.model.MLanguage;
import org.compiere.model.MProcess;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MSysConfig; import org.compiere.model.MSysConfig;
@ -533,7 +535,16 @@ public class ZkReportViewer extends Window implements EventListener<Event>, IRep
{ {
toolBar.appendChild(wLanguage.getComponent()); 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); wLanguage.getComponent().addEventListener(Events.ON_SELECT, this);
} catch (Exception e) { } catch (Exception e) {
log.log(Level.SEVERE, e.getLocalizedMessage()); log.log(Level.SEVERE, e.getLocalizedMessage());
@ -1233,7 +1244,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, IRep
else if (e.getTarget() == bWizard) else if (e.getTarget() == bWizard)
cmd_Wizard(); cmd_Wizard();
else if (e.getTarget() == bRefresh) else if (e.getTarget() == bRefresh)
cmd_report(); cmd_refresh();
else if (e.getTarget() == bReRun) else if (e.getTarget() == bReRun)
cmd_reRun(); cmd_reRun();
// //
@ -1518,15 +1529,38 @@ public class ZkReportViewer extends Window implements EventListener<Event>, IRep
} }
} // cmd_report } // 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 * Refresh With Parameters
*/ */
private void cmd_reRun() { 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; int AD_Process_ID = m_reportEngine.getPrintInfo() != null ? m_reportEngine.getPrintInfo().getAD_Process_ID() : 0;
if(AD_Process_ID <= 0) if(AD_Process_ID <= 0)
return; return;
ProcessInfo pi = new ProcessInfo("RefreshWithParameters", AD_Process_ID); ProcessInfo pi = new ProcessInfo("RefreshWithParameters", AD_Process_ID);
pi.setLanguageID(m_reportEngine.getLanguageID());
pi.setReportType(m_reportEngine.getReportType());
pi.setReplaceTabContent(); pi.setReplaceTabContent();
if(!Util.isEmpty(showHelp))
pi.setShowHelp(showHelp);
setTabOnCloseHandler(); setTabOnCloseHandler();
ProcessModalDialog processModalDialog = new ProcessModalDialog(this, m_WindowNo, pi); ProcessModalDialog processModalDialog = new ProcessModalDialog(this, m_WindowNo, pi);
ZKUpdateUtil.setWindowWidthX(processModalDialog, 850); ZKUpdateUtil.setWindowWidthX(processModalDialog, 850);
@ -1553,9 +1587,22 @@ public class ZkReportViewer extends Window implements EventListener<Event>, 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() { private void postRenderReportEvent() {
showBusyDialog(); showBusyDialog();
setLanguage(); setLanguage();
setPreviewType();
Events.echoEvent(ON_RENDER_REPORT_EVENT, this, null); Events.echoEvent(ON_RENDER_REPORT_EVENT, this, null);
updateRowCount(); updateRowCount();
} }