IDEMPIERE-2640 Performance: Html/Tabular reports size could be reduced / IDEMPIERE-2355 Allow to style the summary rows of HTML report
This commit is contained in:
parent
045e250a69
commit
c47d87d389
|
@ -16,9 +16,9 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.print;
|
package org.compiere.print;
|
||||||
|
|
||||||
import static org.compiere.model.SystemIDs.TABLE_AD_TABLE;
|
|
||||||
import static org.compiere.model.SystemIDs.PROCESS_RPT_M_INVENTORY;
|
import static org.compiere.model.SystemIDs.PROCESS_RPT_M_INVENTORY;
|
||||||
import static org.compiere.model.SystemIDs.PROCESS_RPT_M_MOVEMENT;
|
import static org.compiere.model.SystemIDs.PROCESS_RPT_M_MOVEMENT;
|
||||||
|
import static org.compiere.model.SystemIDs.TABLE_AD_TABLE;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
|
@ -807,14 +807,14 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
||||||
if (extension != null && extension.getStyleURL() != null)
|
if (extension != null && extension.getStyleURL() != null)
|
||||||
{
|
{
|
||||||
// maybe cache style content with key is path
|
// maybe cache style content with key is path
|
||||||
String pathStyleFile = extension.getFullPathStyle();
|
String pathStyleFile = extension.getFullPathStyle(); // creates a temp file - delete below
|
||||||
Path path = Paths.get(pathStyleFile);
|
Path path = Paths.get(pathStyleFile);
|
||||||
List<String> styleLines = Files.readAllLines(path, Ini.getCharset());
|
List<String> styleLines = Files.readAllLines(path, Ini.getCharset());
|
||||||
|
Files.delete(path); // delete temp file
|
||||||
StringBuilder styleBuild = new StringBuilder();
|
StringBuilder styleBuild = new StringBuilder();
|
||||||
for (String styleLine : styleLines){
|
for (String styleLine : styleLines){
|
||||||
styleBuild.append(styleLine);
|
styleBuild.append(styleLine); //.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendInlineCss (doc, styleBuild);
|
appendInlineCss (doc, styleBuild);
|
||||||
}
|
}
|
||||||
if (extension != null && extension.getScriptURL() != null && !isExport)
|
if (extension != null && extension.getScriptURL() != null && !isExport)
|
||||||
|
@ -2092,4 +2092,5 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
|
||||||
return String.format(CSS_SELECTOR_TEMPLATE, index + 1);
|
return String.format(CSS_SELECTOR_TEMPLATE, index + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // ReportEngine
|
} // ReportEngine
|
||||||
|
|
|
@ -798,8 +798,7 @@ public class DashboardController implements EventListener<Event> {
|
||||||
Iframe iframe = new Iframe();
|
Iframe iframe = new Iframe();
|
||||||
iframe.setSclass("dashboard-report-iframe");
|
iframe.setSclass("dashboard-report-iframe");
|
||||||
File file = File.createTempFile(re.getName(), ".html");
|
File file = File.createTempFile(re.getName(), ".html");
|
||||||
re.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getDesktop().getWebApp().getRealPath("/"),
|
re.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp",
|
||||||
Executions.getCurrent().getContextPath(), "rp",
|
|
||||||
SessionManager.getAppDesktop().getComponent().getUuid()));
|
SessionManager.getAppDesktop().getComponent().getUuid()));
|
||||||
AMedia media = new AMedia(re.getName(), "html", "text/html", file, false);
|
AMedia media = new AMedia(re.getName(), "html", "text/html", file, false);
|
||||||
iframe.setContent(media);
|
iframe.setContent(media);
|
||||||
|
|
|
@ -13,6 +13,13 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.adempiere.webui.report;
|
package org.adempiere.webui.report;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.adempiere.webui.apps.AEnv;
|
import org.adempiere.webui.apps.AEnv;
|
||||||
import org.adempiere.webui.theme.ThemeManager;
|
import org.adempiere.webui.theme.ThemeManager;
|
||||||
import org.apache.ecs.ConcreteElement;
|
import org.apache.ecs.ConcreteElement;
|
||||||
|
@ -36,9 +43,8 @@ public class HTMLExtension implements IHTMLExtension {
|
||||||
private String componentId;
|
private String componentId;
|
||||||
private String scriptURL;
|
private String scriptURL;
|
||||||
private String styleURL;
|
private String styleURL;
|
||||||
private String contextFullPath;
|
|
||||||
|
|
||||||
public HTMLExtension(String contextFullPath, String contextPath, String classPrefix, String componentId) {
|
public HTMLExtension(String contextPath, String classPrefix, String componentId) {
|
||||||
|
|
||||||
String theme = MSysConfig.getValue(MSysConfig.HTML_REPORT_THEME, "/", Env.getAD_Client_ID(Env.getCtx()));
|
String theme = MSysConfig.getValue(MSysConfig.HTML_REPORT_THEME, "/", Env.getAD_Client_ID(Env.getCtx()));
|
||||||
|
|
||||||
|
@ -51,7 +57,6 @@ public class HTMLExtension implements IHTMLExtension {
|
||||||
this.componentId = componentId;
|
this.componentId = componentId;
|
||||||
this.scriptURL = contextPath + theme + "js/report.js";
|
this.scriptURL = contextPath + theme + "js/report.js";
|
||||||
this.styleURL = contextPath + theme + "css/report.css";
|
this.styleURL = contextPath + theme + "css/report.css";
|
||||||
this.contextFullPath = contextFullPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void extendIDColumn(int row, ConcreteElement columnElement, a href,
|
public void extendIDColumn(int row, ConcreteElement columnElement, a href,
|
||||||
|
@ -94,15 +99,44 @@ public class HTMLExtension implements IHTMLExtension {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFullPathStyle (){
|
public String getFullPathStyle() {
|
||||||
String theme = MSysConfig.getValue(MSysConfig.HTML_REPORT_THEME, "/", Env.getAD_Client_ID(Env.getCtx()));
|
String theme = MSysConfig.getValue(MSysConfig.HTML_REPORT_THEME, "/", Env.getAD_Client_ID(Env.getCtx()));
|
||||||
|
|
||||||
if (! theme.startsWith("/"))
|
if (! theme.startsWith("/"))
|
||||||
theme = "/" + theme;
|
theme = "/" + theme;
|
||||||
if (! theme.endsWith("/"))
|
if (! theme.endsWith("/"))
|
||||||
theme = theme + "/";
|
theme = theme + "/";
|
||||||
|
String resFile = theme + "css/report.css";
|
||||||
|
|
||||||
return contextFullPath + theme + "css/report.css";
|
URL urlFile = this.getClass().getResource(resFile);
|
||||||
|
if (urlFile == null) {
|
||||||
|
resFile = "/css/report.css"; // default
|
||||||
|
urlFile = this.getClass().getResource(resFile);
|
||||||
|
}
|
||||||
|
if (urlFile != null) {
|
||||||
|
FileOutputStream cssStream = null;
|
||||||
|
File cssFile = null;
|
||||||
|
try {
|
||||||
|
// copy the resource to a temporary file to process it with 2pack
|
||||||
|
InputStream stream = urlFile.openStream();
|
||||||
|
cssFile = File.createTempFile("report", ".css");
|
||||||
|
cssStream = new FileOutputStream(cssFile);
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int read;
|
||||||
|
while((read = stream.read(buffer)) != -1){
|
||||||
|
cssStream.write(buffer, 0, read);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new AdempiereException(e);
|
||||||
|
} finally{
|
||||||
|
if (cssStream != null) {
|
||||||
|
try {
|
||||||
|
cssStream.close();
|
||||||
|
} catch (Exception e2) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cssFile.getAbsolutePath();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1043,8 +1043,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
String contextPath = Executions.getCurrent().getContextPath();
|
String contextPath = Executions.getCurrent().getContextPath();
|
||||||
String contextFullPath = Executions.getCurrent().getDesktop().getWebApp().getRealPath("/");
|
m_reportEngine.createHTML(sw, false, m_reportEngine.getPrintFormat().getLanguage(), new HTMLExtension(contextPath, "rp", this.getUuid()), true);
|
||||||
m_reportEngine.createHTML(sw, false, m_reportEngine.getPrintFormat().getLanguage(), new HTMLExtension(contextFullPath, contextPath, "rp", this.getUuid()), true);
|
|
||||||
data = sw.getBuffer().toString().getBytes();
|
data = sw.getBuffer().toString().getBytes();
|
||||||
}
|
}
|
||||||
else if (ext.equals("xls"))
|
else if (ext.equals("xls"))
|
||||||
|
@ -1424,13 +1423,11 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
||||||
|
|
||||||
private ZkReportViewer viewer;
|
private ZkReportViewer viewer;
|
||||||
private String contextPath;
|
private String contextPath;
|
||||||
private String contextFullPath;
|
|
||||||
|
|
||||||
public HTMLRendererRunnable(ZkReportViewer viewer) {
|
public HTMLRendererRunnable(ZkReportViewer viewer) {
|
||||||
super();
|
super();
|
||||||
this.viewer = viewer;
|
this.viewer = viewer;
|
||||||
contextPath = Executions.getCurrent().getContextPath();
|
contextPath = Executions.getCurrent().getContextPath();
|
||||||
contextFullPath = Executions.getCurrent().getDesktop().getWebApp().getRealPath("/");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1445,7 +1442,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
||||||
log.log(Level.FINE, "Path="+path + " Prefix="+prefix);
|
log.log(Level.FINE, "Path="+path + " Prefix="+prefix);
|
||||||
}
|
}
|
||||||
File file = File.createTempFile(prefix, ".html", new File(path));
|
File file = File.createTempFile(prefix, ".html", new File(path));
|
||||||
viewer.m_reportEngine.createHTML(file, false, viewer.m_reportEngine.getPrintFormat().getLanguage(), new HTMLExtension(contextFullPath, contextPath, "rp", viewer.getUuid()));
|
viewer.m_reportEngine.createHTML(file, false, viewer.m_reportEngine.getPrintFormat().getLanguage(), new HTMLExtension(contextPath, "rp", viewer.getUuid()));
|
||||||
viewer.media = new AMedia(file.getName(), "html", "text/html", file, false);
|
viewer.media = new AMedia(file.getName(), "html", "text/html", file, false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof RuntimeException)
|
if (e instanceof RuntimeException)
|
||||||
|
|
Loading…
Reference in New Issue