IDEMPIERE-2640:Performance: Html/Tabular reports size could be reduced

step2: remove duplicate menu context
This commit is contained in:
hieplq 2015-07-02 14:40:07 +07:00
parent 8c3f9cf771
commit e8fadaefbc
4 changed files with 94 additions and 47 deletions

View File

@ -15,6 +15,7 @@ package org.compiere.print;
import org.apache.ecs.ConcreteElement; import org.apache.ecs.ConcreteElement;
import org.apache.ecs.xhtml.a; import org.apache.ecs.xhtml.a;
import org.apache.ecs.xhtml.body;
/** /**
* *
@ -32,4 +33,6 @@ public interface IHTMLExtension {
public void extendRowElement(ConcreteElement row, PrintData printData); public void extendRowElement(ConcreteElement row, PrintData printData);
public void extendIDColumn(int row, ConcreteElement columnElement, a href, PrintDataElement dataElement); public void extendIDColumn(int row, ConcreteElement columnElement, a href, PrintDataElement dataElement);
public void setWebAttribute (body reportBody);
} }

View File

@ -776,6 +776,9 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
} }
appendInlineCss (doc); appendInlineCss (doc);
if (extension != null){
extension.setWebAttribute(doc.getBody());
}
doc.output(w); doc.output(w);
} }

View File

@ -17,8 +17,7 @@ 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;
import org.apache.ecs.xhtml.a; import org.apache.ecs.xhtml.a;
import org.apache.ecs.xhtml.div; import org.apache.ecs.xhtml.body;
import org.apache.ecs.xhtml.img;
import org.compiere.model.MSysConfig; import org.compiere.model.MSysConfig;
import org.compiere.print.IHTMLExtension; import org.compiere.print.IHTMLExtension;
import org.compiere.print.PrintData; import org.compiere.print.PrintData;
@ -56,49 +55,9 @@ public class HTMLExtension implements IHTMLExtension {
public void extendIDColumn(int row, ConcreteElement columnElement, a href, public void extendIDColumn(int row, ConcreteElement columnElement, a href,
PrintDataElement dataElement) { PrintDataElement dataElement) {
href.addAttribute("onclick", "showColumnMenu(event, '" + dataElement.getColumnName() + "', " + row + ")"); href.addAttribute("onclick", "showColumnMenu(event, '" + dataElement.getColumnName() + "', " + row + ")");
href.addAttribute ("componentId", componentId);
//menu div href.addAttribute ("foreignColumnName", dataElement.getForeignColumnName());
div menu = new div(); href.addAttribute ("value", dataElement.getValueAsString());
menu.setID(dataElement.getColumnName() + "_" + row + "_d");
menu.setStyle("position:absolute;display:none;top:0;left:0;border: 1px solid lightgray; background-color: white;");
columnElement.addElementToRegistry(menu);
//window menu item
div window = new div();
window.setStyle("padding: 3px; vertical-align: middle");
window.addAttribute("onmouseover", "this.style.backgroundColor = 'lightgray'");
window.addAttribute("onmouseout", "this.style.backgroundColor = 'white'");
href = new a("javascript:void(0)");
href.setStyle("text-decoration: none; font-size: 11px; vertical-align: middle;");
href.addAttribute("onclick", "parent.zoom('"
+ componentId + "', '"
+ dataElement.getForeignColumnName() + "', '"
+ dataElement.getValueAsString() + "')");
window.addElement(href);
menu.addElement(window);
img image = new img("/webui" + ThemeManager.getThemeResource("images/mWindow.png"));
image.setAlign("middle");
href.addElement(image);
href.addElement(Msg.getMsg(AEnv.getLanguage(Env.getCtx()), "Window"));
//report menu item
div report = new div();
report.setStyle("padding: 3px; vertical-align: middle");
report.addAttribute("onmouseover", "this.style.backgroundColor = 'lightgray'");
report.addAttribute("onmouseout", "this.style.backgroundColor = 'white'");
href = new a("javascript:void(0)");
href.setStyle("text-decoration: none; font-size: 11px; vertical-align: middle;");
href.addAttribute("onclick", "parent.drillDown('"
+ componentId + "', '"
+ dataElement.getForeignColumnName() + "', '"
+ dataElement.getValueAsString() + "')");
report.addElement(href);
menu.addElement(report);
image = new img("/webui" + ThemeManager.getThemeResource("images/mReport.png"));
image.setAlign("middle");
href.addElement(image);
href.addElement(Msg.getMsg(AEnv.getLanguage(Env.getCtx()), "Report").replace("&", ""));
} }
public void extendRowElement(ConcreteElement row, PrintData printData) { public void extendRowElement(ConcreteElement row, PrintData printData) {
@ -124,4 +83,12 @@ public class HTMLExtension implements IHTMLExtension {
return styleURL; return styleURL;
} }
public void setWebAttribute (body reportBody){
// set attribute value for create menu context
reportBody.addAttribute("windowIco", "/webui" + ThemeManager.getThemeResource("images/mWindow.png"));
reportBody.addAttribute("reportIco", "/webui" + ThemeManager.getThemeResource("images/mReport.png"));
reportBody.addAttribute ("reportLabel", Msg.getMsg(AEnv.getLanguage(Env.getCtx()), "Report").replace("&", ""));
reportBody.addAttribute ("windowLabel", Msg.getMsg(AEnv.getLanguage(Env.getCtx()), "Window"));
}
} }

View File

@ -20,7 +20,7 @@ function drillDown(cmpid, column, value){
} }
function showColumnMenu(e, columnName, row) { function showColumnMenu(e, columnName, row) {
var d = document.getElementById(columnName + "_" + row + "_d"); var d = getMenu (e.target.getAttribute ("componentId"), e.target.getAttribute ("foreignColumnName"), e.target.getAttribute ("value"));
var posx = 0; var posx = 0;
var posy = 0; var posy = 0;
@ -40,6 +40,80 @@ function showColumnMenu(e, columnName, row) {
d.style.left = posx; d.style.left = posx;
d.style.display = "block"; d.style.display = "block";
setTimeout("document.getElementById('" + columnName + "_" + row + "_d" + "').style.display='none'", 3000); setTimeout("getMenu ().style.display='none'", 3000);
} }
var contextMenu;
function getMenu (componentId, foreignColumnName, value){
if (contextMenu == null){
//menu div
var menu = document.createElement("div");
menu.style.position = "absolute";
menu.style.display = "none";
menu.style.top = "0";
menu.style.left = "0";
menu.style.border = "1px solid lightgray";
menu.style.border = "1px solid lightgray";
menu.style.backgroundColor = "white";
//window menu item
var windowMenu = document.createElement("div");
windowMenu.style.padding = "3px";
windowMenu.style.verticalAlign = "middle";
windowMenu.setAttribute("onmouseover", "this.style.backgroundColor = 'lightgray'");
windowMenu.setAttribute("onmouseout", "this.style.backgroundColor = 'white'");
var href = document.createElement("a");
href.style.fontSize = "11px";
href.style.textDecoration = "none";
href.style.verticalAlign = "middle";
href.href = "javascript:void(0)";
href.setAttribute("onclick", "parent.zoom(contextMenu.getAttribute ('componentId'), " +
"contextMenu.getAttribute ('foreignColumnName'), " +
"contextMenu.getAttribute ('value'))");
windowMenu.appendChild(href);
menu.appendChild(windowMenu);
var image = document.createElement("img");
image.src = window.document.body.getAttribute ("windowIco");
image.setAttribute("align", "middle");
href.appendChild(image);
href.appendChild(document.createTextNode(window.document.body.getAttribute ("windowLabel")));
//report menu item
var report = document.createElement("div");
report.style.padding = "3px";
report.style.verticalAlign = "middle";
report.setAttribute("onmouseover", "this.style.backgroundColor = 'lightgray'");
report.setAttribute("onmouseout", "this.style.backgroundColor = 'white'");
var reportHref = document.createElement("a");
reportHref.href = "javascript:void(0)";
reportHref.style.textDecoration = "none";
reportHref.style.fontSize = "11px";
reportHref.style.verticalAlign = "middle";
reportHref.setAttribute("onclick", "parent.drillDown(contextMenu.getAttribute ('componentId'), " +
"contextMenu.getAttribute ('foreignColumnName'), " +
"contextMenu.getAttribute ('value'))");
report.appendChild(reportHref);
menu.appendChild(report);
var reportimage = document.createElement("img");
reportimage.src = window.document.body.getAttribute ("reportIco");
reportimage.setAttribute("align", "middle");
reportHref.appendChild(reportimage);
reportHref.appendChild(document.createTextNode(window.document.body.getAttribute ("reportLabel")));
contextMenu = menu;
window.document.body.appendChild (contextMenu);
}
contextMenu.setAttribute ("componentId", componentId);
contextMenu.setAttribute ("foreignColumnName", foreignColumnName);
contextMenu.setAttribute ("value", value);
return contextMenu;
}