IDEMPIERE-4421 Html asset versioning should allow fluent deployment (#431)
- Fix broken menu icon for html report - Fix an issue with switching theme
This commit is contained in:
parent
a833e778a6
commit
c3aafb2a4f
|
@ -48,7 +48,7 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
|
|||
<javascript-module name="jawwa.atmosphere" version="202011170510"/>
|
||||
<javascript-module name="adempiere.local.storage" version="202011151100"/>
|
||||
<javascript-moudle name="html2canvas" version="1.0.0.rc7"/>
|
||||
<javascript-module name="org.idempiere.commons" version="202011230530"/>
|
||||
<javascript-module name="org.idempiere.commons" version="202012030330"/>
|
||||
<javascript-module name="jquery.maskedinput" version="1.4.1" />
|
||||
<javascript-module name="photobooth" version="0.7-rsd3" />
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.compiere.print.PrintData;
|
|||
import org.compiere.print.PrintDataElement;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -43,19 +44,27 @@ public class HTMLExtension implements IHTMLExtension {
|
|||
private String componentId;
|
||||
private String scriptURL;
|
||||
private String styleURL;
|
||||
private String contextPath;
|
||||
|
||||
public HTMLExtension(String contextPath, String classPrefix, String componentId) {
|
||||
|
||||
String theme = MSysConfig.getValue(MSysConfig.HTML_REPORT_THEME, "/", Env.getAD_Client_ID(Env.getCtx()));
|
||||
|
||||
if (! theme.startsWith("/"))
|
||||
if (! theme.startsWith("/") && !theme.startsWith("~./"))
|
||||
theme = "/" + theme;
|
||||
if (! theme.endsWith("/"))
|
||||
theme = theme + "/";
|
||||
|
||||
this.classPrefix = classPrefix;
|
||||
this.componentId = componentId;
|
||||
this.styleURL = contextPath + theme + "css/report.css";
|
||||
if (theme.startsWith("~./")) {
|
||||
if (Executions.getCurrent() != null) {
|
||||
this.styleURL = Executions.encodeURL(theme + "css/report.css");
|
||||
}
|
||||
} else {
|
||||
this.styleURL = contextPath + theme + "css/report.css";
|
||||
}
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
public void extendIDColumn(int row, ConcreteElement columnElement, a href,
|
||||
|
@ -91,8 +100,32 @@ public class HTMLExtension implements IHTMLExtension {
|
|||
|
||||
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"));
|
||||
StringBuilder windowImageURL = new StringBuilder();
|
||||
String windowIco = ThemeManager.getThemeResource("images/mWindow.png");
|
||||
if (windowIco.startsWith("~./")) {
|
||||
if (Executions.getCurrent() != null) {
|
||||
windowImageURL.append(Executions.encodeURL(windowIco));
|
||||
}
|
||||
} else {
|
||||
windowImageURL.append(contextPath);
|
||||
if (!windowIco.startsWith("/") && !contextPath.endsWith("/"))
|
||||
windowImageURL.append("/");
|
||||
windowImageURL.append(windowIco);
|
||||
}
|
||||
StringBuilder reportImageURL = new StringBuilder();
|
||||
String reportIco = ThemeManager.getThemeResource("images/mReport.png");
|
||||
if (reportIco.startsWith("~./")) {
|
||||
if (Executions.getCurrent() != null) {
|
||||
reportImageURL.append(Executions.encodeURL(reportIco));
|
||||
}
|
||||
} else {
|
||||
reportImageURL.append(contextPath);
|
||||
if (!reportIco.startsWith("/") && !contextPath.endsWith("/"))
|
||||
reportImageURL.append("/");
|
||||
reportImageURL.append(reportIco);
|
||||
}
|
||||
reportBody.addAttribute("windowIco",windowImageURL.toString());
|
||||
reportBody.addAttribute("reportIco", reportImageURL.toString());
|
||||
reportBody.addAttribute ("reportLabel", Msg.getMsg(AEnv.getLanguage(Env.getCtx()), "Report").replace("&", ""));
|
||||
reportBody.addAttribute ("windowLabel", Msg.getMsg(AEnv.getLanguage(Env.getCtx()), "Window"));
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.activation.FileDataSource;
|
||||
|
@ -37,7 +35,6 @@ import org.adempiere.webui.ClientInfo;
|
|||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.apps.BusyDialog;
|
||||
import org.adempiere.webui.apps.DesktopRunnable;
|
||||
import org.adempiere.webui.apps.WReport;
|
||||
import org.adempiere.webui.apps.form.WReportCustomization;
|
||||
import org.adempiere.webui.component.Checkbox;
|
||||
|
@ -63,7 +60,6 @@ import org.adempiere.webui.theme.ThemeManager;
|
|||
import org.adempiere.webui.util.IServerPushCallback;
|
||||
import org.adempiere.webui.util.ServerPushTemplate;
|
||||
import org.adempiere.webui.util.ZKUpdateUtil;
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.MArchive;
|
||||
import org.compiere.model.MClient;
|
||||
|
@ -200,8 +196,6 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
private BusyDialog progressWindow;
|
||||
private Mask mask;
|
||||
|
||||
private Future<?> future;
|
||||
|
||||
private final static String ON_RENDER_REPORT_EVENT = "onRenderReport";
|
||||
|
||||
private Popup toolbarPopup;
|
||||
|
@ -232,6 +226,9 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
m_reportEngine.getPrintFormat().get_Translation(MPrintFormat.COLUMNNAME_Name)));
|
||||
|
||||
addEventListener(ON_RENDER_REPORT_EVENT, this);
|
||||
addEventListener("onPostInit", e -> {
|
||||
postRenderReportEvent();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -579,9 +576,6 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
int AD_Process_ID = m_reportEngine.getPrintInfo() != null ? m_reportEngine.getPrintInfo().getAD_Process_ID() : 0;
|
||||
updateToolbarAccess(AD_Window_ID, AD_Process_ID);
|
||||
|
||||
postRenderReportEvent();
|
||||
//iframe.setAutohide(true);
|
||||
|
||||
this.setBorder("normal");
|
||||
|
||||
this.addEventListener("onZoom", new EventListener<Event>() {
|
||||
|
@ -634,6 +628,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
});
|
||||
|
||||
init = true;
|
||||
|
||||
Events.echoEvent("onPostInit", this, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -656,29 +652,20 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
media = null;
|
||||
Listitem selected = previewType.getSelectedItem();
|
||||
if (selected == null || "PDF".equals(selected.getValue())) {
|
||||
future = Adempiere.getThreadPoolExecutor().submit(new DesktopRunnable(new PDFRendererRunnable(this),getDesktop()));
|
||||
new PDFRendererRunnable(this).run();
|
||||
} else if ("HTML".equals(previewType.getSelectedItem().getValue())) {
|
||||
future = Adempiere.getThreadPoolExecutor().submit(new DesktopRunnable(new HTMLRendererRunnable(this),getDesktop()));
|
||||
new HTMLRendererRunnable(this).run();
|
||||
} else if ("XLS".equals(previewType.getSelectedItem().getValue())) {
|
||||
future = Adempiere.getThreadPoolExecutor().submit(new DesktopRunnable(new XLSRendererRunnable(this),getDesktop()));
|
||||
new XLSRendererRunnable(this).run();
|
||||
} else if ("CSV".equals(previewType.getSelectedItem().getValue())) {
|
||||
future = Adempiere.getThreadPoolExecutor().submit(new DesktopRunnable(new CSVRendererRunnable(this),getDesktop()));
|
||||
new CSVRendererRunnable(this).run();
|
||||
} else if ("XLSX".equals(previewType.getSelectedItem().getValue())) {
|
||||
future = Adempiere.getThreadPoolExecutor().submit(new DesktopRunnable(new XLSXRendererRunnable(this),getDesktop()));
|
||||
new XLSXRendererRunnable(this).run();
|
||||
}
|
||||
}
|
||||
|
||||
private void onPreviewReport() {
|
||||
try {
|
||||
if (future != null) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
}
|
||||
mediaVersion++;
|
||||
String url = Utils.getDynamicMediaURI(this, mediaVersion, media.getName(), media.getFormat());
|
||||
String pdfJsUrl = "pdf.js/web/viewer.html?file="+url;
|
||||
|
@ -715,7 +702,6 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
revalidate();
|
||||
} finally {
|
||||
hideBusyDialog();
|
||||
future = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -940,12 +926,6 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
m_ctx = null;
|
||||
m_WindowNo = -1;
|
||||
}
|
||||
if (future != null && !future.isDone())
|
||||
{
|
||||
future.cancel(true);
|
||||
future = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onEvent(Event event) throws Exception {
|
||||
|
|
|
@ -86,10 +86,13 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
|
|||
windowMenu.appendChild(href);
|
||||
menu.appendChild(windowMenu);
|
||||
|
||||
var image = doc.createElement("img");
|
||||
image.src = doc.body.getAttribute ("windowIco");
|
||||
image.setAttribute("align", "middle");
|
||||
href.appendChild(image);
|
||||
var windowIco = doc.body.getAttribute ("windowIco");
|
||||
if (typeof windowIco === 'string' && windowIco.length > 0) {
|
||||
var image = doc.createElement("img");
|
||||
image.src = windowIco;
|
||||
image.setAttribute("align", "middle");
|
||||
href.appendChild(image);
|
||||
}
|
||||
href.appendChild(doc.createTextNode(doc.body.getAttribute ("windowLabel")));
|
||||
|
||||
//report menu item
|
||||
|
@ -109,10 +112,13 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
|
|||
|
||||
report.appendChild(reportHref);
|
||||
menu.appendChild(report);
|
||||
var reportimage = doc.createElement("img");
|
||||
reportimage.src = doc.body.getAttribute ("reportIco");
|
||||
reportimage.setAttribute("align", "middle");
|
||||
reportHref.appendChild(reportimage);
|
||||
var reportIco = doc.body.getAttribute ("reportIco");
|
||||
if (typeof reportIco === 'string' && reportIco.length > 0) {
|
||||
var reportimage = doc.createElement("img");
|
||||
reportimage.src = reportIco;
|
||||
reportimage.setAttribute("align", "middle");
|
||||
reportHref.appendChild(reportimage);
|
||||
}
|
||||
reportHref.appendChild(doc.createTextNode(doc.body.getAttribute ("reportLabel")));
|
||||
|
||||
doc.contextMenu = menu;
|
||||
|
|
|
@ -10,12 +10,15 @@
|
|||
import org.compiere.util.Env;
|
||||
import org.adempiere.webui.theme.ITheme;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.zkoss.zul.theme.Themes;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
||||
Env.setContext(Env.getCtx(), ITheme.ZK_TOOLBAR_BUTTON_SIZE, "24");
|
||||
/* Set the next variable if you want to control browser title in theme */
|
||||
/* Env.setContext(Env.getCtx(), "#ZK_BROWSER_TITLE", "iDempiere"); */
|
||||
Env.setContext(Env.getCtx(), ITheme.USE_CSS_FOR_WINDOW_SIZE, "Y");
|
||||
Env.setContext(Env.getCtx(), ITheme.USE_FONT_ICON_FOR_IMAGE, MSysConfig.getBooleanValue(MSysConfig.ZK_THEME_USE_FONT_ICON_FOR_IMAGE, false));
|
||||
Themes.setTheme(Executions.getCurrent(), "breeze");
|
||||
]]>
|
||||
</zscript>
|
||||
</zk>
|
||||
|
|
Loading…
Reference in New Issue