hg merge release-1.0c (forward-porting)
This commit is contained in:
commit
266e55afc8
|
@ -5,7 +5,7 @@ SELECT
|
|||
ms.IsActive, ms.Created, ms.CreatedBy, ms.Updated, ms.UpdatedBy,
|
||||
mp.VALUE, mp.help, (ms.qtyonhand - ms.qtyreserved) AS qtyavailable, ms.qtyonhand,
|
||||
ms.qtyreserved, mp.description, mw.NAME AS warehouse, mw.m_warehouse_id, mw.ad_client_id,
|
||||
mw.ad_org_id, mp.documentnote
|
||||
mw.ad_org_id, mp.documentnote, mp.m_product_id
|
||||
FROM M_STORAGE ms
|
||||
JOIN M_PRODUCT mp ON ms.m_product_id = mp.m_product_id
|
||||
JOIN M_LOCATOR ml ON ms.m_locator_id = ml.m_locator_id
|
||||
|
|
|
@ -16,7 +16,7 @@ AS
|
|||
s.m_attributesetinstance_id,
|
||||
s.m_storageonhand_uu AS m_storage_uu
|
||||
FROM m_storageonhand s
|
||||
UNION
|
||||
UNION ALL
|
||||
SELECT sr.m_product_id,
|
||||
w.m_reservelocator_id AS m_locator_id,
|
||||
sr.ad_client_id,
|
||||
|
@ -36,7 +36,7 @@ AS
|
|||
JOIN m_warehouse w
|
||||
ON sr.m_warehouse_id = w.m_warehouse_id
|
||||
WHERE sr.issotrx = 'Y'
|
||||
UNION
|
||||
UNION ALL
|
||||
SELECT so.m_product_id,
|
||||
w.m_reservelocator_id AS m_locator_id,
|
||||
so.ad_client_id,
|
||||
|
|
|
@ -5,7 +5,7 @@ SELECT
|
|||
ms.IsActive, ms.Created, ms.CreatedBy, ms.Updated, ms.UpdatedBy,
|
||||
mp.VALUE, mp.help, (ms.qtyonhand - ms.qtyreserved) AS qtyavailable, ms.qtyonhand,
|
||||
ms.qtyreserved, mp.description, mw.NAME AS warehouse, mw.m_warehouse_id, mw.ad_client_id,
|
||||
mw.ad_org_id, mp.documentnote
|
||||
mw.ad_org_id, mp.documentnote, mp.m_product_id
|
||||
FROM M_STORAGE ms
|
||||
JOIN M_PRODUCT mp ON ms.m_product_id = mp.m_product_id
|
||||
JOIN M_LOCATOR ml ON ms.m_locator_id = ml.m_locator_id
|
||||
|
|
|
@ -16,7 +16,7 @@ AS
|
|||
s.m_attributesetinstance_id,
|
||||
s.m_storageonhand_uu AS m_storage_uu
|
||||
FROM m_storageonhand s
|
||||
UNION
|
||||
UNION ALL
|
||||
SELECT sr.m_product_id,
|
||||
w.m_reservelocator_id AS m_locator_id,
|
||||
sr.ad_client_id,
|
||||
|
@ -36,7 +36,7 @@ AS
|
|||
JOIN m_warehouse w
|
||||
ON sr.m_warehouse_id = w.m_warehouse_id
|
||||
WHERE sr.issotrx = 'Y'
|
||||
UNION
|
||||
UNION ALL
|
||||
SELECT so.m_product_id,
|
||||
w.m_reservelocator_id AS m_locator_id,
|
||||
so.ad_client_id,
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
--IDEMPIERE-1459 - Improving performance on InfoWindows
|
||||
CREATE OR REPLACE VIEW M_PRODUCT_STOCK_V
|
||||
AS
|
||||
SELECT
|
||||
ms.IsActive, ms.Created, ms.CreatedBy, ms.Updated, ms.UpdatedBy,
|
||||
mp.VALUE, mp.help, (ms.qtyonhand - ms.qtyreserved) AS qtyavailable, ms.qtyonhand,
|
||||
ms.qtyreserved, mp.description, mw.NAME AS warehouse, mw.m_warehouse_id, mw.ad_client_id,
|
||||
mw.ad_org_id, mp.documentnote, mp.m_product_id
|
||||
FROM M_STORAGE ms
|
||||
JOIN M_PRODUCT mp ON ms.m_product_id = mp.m_product_id
|
||||
JOIN M_LOCATOR ml ON ms.m_locator_id = ml.m_locator_id
|
||||
JOIN M_WAREHOUSE mw ON ml.m_warehouse_id = mw.m_warehouse_id
|
||||
ORDER BY mw.NAME;
|
||||
|
||||
--IDEMPIERE-1459 - Improving performance on InfoWindows
|
||||
CREATE OR REPLACE VIEW m_storage
|
||||
AS
|
||||
SELECT s.m_product_id,
|
||||
s.m_locator_id,
|
||||
s.ad_client_id,
|
||||
s.ad_org_id,
|
||||
s.isactive,
|
||||
s.created,
|
||||
s.createdby,
|
||||
s.updated,
|
||||
s.updatedby,
|
||||
s.qtyonhand,
|
||||
0 AS qtyreserved,
|
||||
0 AS qtyordered,
|
||||
s.datelastinventory,
|
||||
s.m_attributesetinstance_id,
|
||||
s.m_storageonhand_uu AS m_storage_uu
|
||||
FROM m_storageonhand s
|
||||
UNION ALL
|
||||
SELECT sr.m_product_id,
|
||||
w.m_reservelocator_id AS m_locator_id,
|
||||
sr.ad_client_id,
|
||||
sr.ad_org_id,
|
||||
sr.isactive,
|
||||
sr.created,
|
||||
sr.createdby,
|
||||
sr.updated,
|
||||
sr.updatedby,
|
||||
0 AS qtyonhand,
|
||||
sr.qty AS qtyreserved,
|
||||
0 AS qtyordered,
|
||||
sr.datelastinventory,
|
||||
sr.m_attributesetinstance_id,
|
||||
sr.m_storagereservation_uu AS m_storage_uu
|
||||
FROM m_storagereservation sr
|
||||
JOIN m_warehouse w
|
||||
ON sr.m_warehouse_id = w.m_warehouse_id
|
||||
WHERE sr.issotrx = 'Y'
|
||||
UNION ALL
|
||||
SELECT so.m_product_id,
|
||||
w.m_reservelocator_id AS m_locator_id,
|
||||
so.ad_client_id,
|
||||
so.ad_org_id,
|
||||
so.isactive,
|
||||
so.created,
|
||||
so.createdby,
|
||||
so.updated,
|
||||
so.updatedby,
|
||||
0 AS qtyonhand,
|
||||
0 AS qtyreserved,
|
||||
so.qty AS qtyordered,
|
||||
so.datelastinventory,
|
||||
so.m_attributesetinstance_id,
|
||||
so.m_storagereservation_uu AS m_storage_uu
|
||||
FROM m_storagereservation so
|
||||
JOIN m_warehouse w
|
||||
ON so.m_warehouse_id = w.m_warehouse_id
|
||||
WHERE so.issotrx = 'N'
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201310231101_IDEMPIERE-1459.sql') FROM dual
|
||||
;
|
|
@ -0,0 +1,78 @@
|
|||
--IDEMPIERE-1459 - Improving performance on InfoWindows
|
||||
CREATE OR REPLACE VIEW M_PRODUCT_STOCK_V
|
||||
AS
|
||||
SELECT
|
||||
ms.IsActive, ms.Created, ms.CreatedBy, ms.Updated, ms.UpdatedBy,
|
||||
mp.VALUE, mp.help, (ms.qtyonhand - ms.qtyreserved) AS qtyavailable, ms.qtyonhand,
|
||||
ms.qtyreserved, mp.description, mw.NAME AS warehouse, mw.m_warehouse_id, mw.ad_client_id,
|
||||
mw.ad_org_id, mp.documentnote, mp.m_product_id
|
||||
FROM M_STORAGE ms
|
||||
JOIN M_PRODUCT mp ON ms.m_product_id = mp.m_product_id
|
||||
JOIN M_LOCATOR ml ON ms.m_locator_id = ml.m_locator_id
|
||||
JOIN M_WAREHOUSE mw ON ml.m_warehouse_id = mw.m_warehouse_id
|
||||
ORDER BY mw.NAME;
|
||||
|
||||
--IDEMPIERE-1459 - Improving performance on InfoWindows
|
||||
CREATE OR REPLACE VIEW m_storage
|
||||
AS
|
||||
SELECT s.m_product_id,
|
||||
s.m_locator_id,
|
||||
s.ad_client_id,
|
||||
s.ad_org_id,
|
||||
s.isactive,
|
||||
s.created,
|
||||
s.createdby,
|
||||
s.updated,
|
||||
s.updatedby,
|
||||
s.qtyonhand,
|
||||
0 AS qtyreserved,
|
||||
0 AS qtyordered,
|
||||
s.datelastinventory,
|
||||
s.m_attributesetinstance_id,
|
||||
s.m_storageonhand_uu AS m_storage_uu
|
||||
FROM m_storageonhand s
|
||||
UNION ALL
|
||||
SELECT sr.m_product_id,
|
||||
w.m_reservelocator_id AS m_locator_id,
|
||||
sr.ad_client_id,
|
||||
sr.ad_org_id,
|
||||
sr.isactive,
|
||||
sr.created,
|
||||
sr.createdby,
|
||||
sr.updated,
|
||||
sr.updatedby,
|
||||
0 AS qtyonhand,
|
||||
sr.qty AS qtyreserved,
|
||||
0 AS qtyordered,
|
||||
sr.datelastinventory,
|
||||
sr.m_attributesetinstance_id,
|
||||
sr.m_storagereservation_uu AS m_storage_uu
|
||||
FROM m_storagereservation sr
|
||||
JOIN m_warehouse w
|
||||
ON sr.m_warehouse_id = w.m_warehouse_id
|
||||
WHERE sr.issotrx = 'Y'
|
||||
UNION ALL
|
||||
SELECT so.m_product_id,
|
||||
w.m_reservelocator_id AS m_locator_id,
|
||||
so.ad_client_id,
|
||||
so.ad_org_id,
|
||||
so.isactive,
|
||||
so.created,
|
||||
so.createdby,
|
||||
so.updated,
|
||||
so.updatedby,
|
||||
0 AS qtyonhand,
|
||||
0 AS qtyreserved,
|
||||
so.qty AS qtyordered,
|
||||
so.datelastinventory,
|
||||
so.m_attributesetinstance_id,
|
||||
so.m_storagereservation_uu AS m_storage_uu
|
||||
FROM m_storagereservation so
|
||||
JOIN m_warehouse w
|
||||
ON so.m_warehouse_id = w.m_warehouse_id
|
||||
WHERE so.issotrx = 'N'
|
||||
;
|
||||
|
||||
|
||||
SELECT register_migration_script('201310231101_IDEMPIERE-1459.sql') FROM dual
|
||||
;
|
|
@ -156,7 +156,7 @@ public class InfoProductWindow extends InfoWindow {
|
|||
/** From Clause */
|
||||
String s_sqlFrom = " M_PRODUCT_STOCK_V ";
|
||||
/** Where Clause */
|
||||
String s_sqlWhere = "Value = ?";
|
||||
String s_sqlWhere = "M_Product_ID = ?";
|
||||
warehouseTbl = ListboxFactory.newDataTable();
|
||||
m_sqlWarehouse = warehouseTbl.prepareTable(s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V");
|
||||
m_sqlWarehouse += " GROUP BY Warehouse";
|
||||
|
@ -331,7 +331,7 @@ public class InfoProductWindow extends InfoWindow {
|
|||
|
||||
for(int i = 0; i < columnInfos.length; i++) {
|
||||
if (columnInfos[i].getGridField() != null && columnInfos[i].getGridField().getColumnName().equals("Value")) {
|
||||
refresh(contentPanel.getValueAt(row,i), M_Warehouse_ID, M_PriceList_Version_ID);
|
||||
refresh(M_Warehouse_ID, M_PriceList_Version_ID);
|
||||
contentBorderLayout.getSouth().setOpen(true);
|
||||
break;
|
||||
}
|
||||
|
@ -530,9 +530,9 @@ public class InfoProductWindow extends InfoWindow {
|
|||
/**
|
||||
* Refresh Query
|
||||
*/
|
||||
private void refresh(Object obj, int M_Warehouse_ID, int M_PriceList_Version_ID)
|
||||
private void refresh(int M_Warehouse_ID, int M_PriceList_Version_ID)
|
||||
{
|
||||
//int M_Product_ID = 0;
|
||||
int m_M_Product_ID = getSelectedRowKey();
|
||||
String sql = m_sqlWarehouse;
|
||||
if (log.isLoggable(Level.FINEST)) log.finest(sql);
|
||||
PreparedStatement pstmt = null;
|
||||
|
@ -540,7 +540,7 @@ public class InfoProductWindow extends InfoWindow {
|
|||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setString(1, (String)obj);
|
||||
pstmt.setInt(1, m_M_Product_ID);
|
||||
rs = pstmt.executeQuery();
|
||||
warehouseTbl.loadTable(rs);
|
||||
}
|
||||
|
@ -554,7 +554,6 @@ public class InfoProductWindow extends InfoWindow {
|
|||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
int m_M_Product_ID = getSelectedRowKey();
|
||||
sql = "SELECT DocumentNote FROM M_Product WHERE M_Product_ID=?";
|
||||
fieldDescription.setText(DB.getSQLValueString(null, sql, m_M_Product_ID));
|
||||
|
||||
|
|
|
@ -21,20 +21,26 @@ import static org.compiere.model.SystemIDs.WINDOW_PRINTFORMAT;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.ref.WeakReference;
|
||||
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;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.adempiere.pdf.Document;
|
||||
import org.adempiere.util.ContextRunnable;
|
||||
import org.adempiere.util.ServerContext;
|
||||
import org.adempiere.webui.AdempiereWebUI;
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.apps.BusyDialog;
|
||||
import org.adempiere.webui.apps.WReport;
|
||||
import org.adempiere.webui.apps.form.WReportCustomization;
|
||||
import org.adempiere.webui.component.Checkbox;
|
||||
|
@ -42,6 +48,7 @@ import org.adempiere.webui.component.ConfirmPanel;
|
|||
import org.adempiere.webui.component.Label;
|
||||
import org.adempiere.webui.component.ListItem;
|
||||
import org.adempiere.webui.component.Listbox;
|
||||
import org.adempiere.webui.component.Mask;
|
||||
import org.adempiere.webui.component.Tabpanel;
|
||||
import org.adempiere.webui.component.ToolBarButton;
|
||||
import org.adempiere.webui.component.Window;
|
||||
|
@ -54,6 +61,9 @@ import org.adempiere.webui.panel.StatusBarPanel;
|
|||
import org.adempiere.webui.report.HTMLExtension;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.theme.ThemeManager;
|
||||
import org.adempiere.webui.util.IServerPushCallback;
|
||||
import org.adempiere.webui.util.ServerPushTemplate;
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.MArchive;
|
||||
import org.compiere.model.MClient;
|
||||
|
@ -77,7 +87,9 @@ import org.compiere.util.Msg;
|
|||
import org.compiere.util.Util;
|
||||
import org.zkoss.util.media.AMedia;
|
||||
import org.zkoss.util.media.Media;
|
||||
import org.zkoss.zk.au.out.AuScript;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Desktop;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.Page;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
|
@ -177,6 +189,13 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
|
||||
private boolean init;
|
||||
|
||||
private BusyDialog progressWindow;
|
||||
private Mask mask;
|
||||
|
||||
private Future<?> future;
|
||||
|
||||
private final static String ON_RENDER_REPORT_EVENT = "onRenderReport";
|
||||
|
||||
//private static final String REPORT = "org.idempiere.ui.report";
|
||||
|
||||
/**
|
||||
|
@ -199,6 +218,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
m_isCanExport = MRole.getDefault().isCanExport(m_AD_Table_ID);
|
||||
|
||||
setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Report") + ": " + m_reportEngine.getName()));
|
||||
|
||||
addEventListener(ON_RENDER_REPORT_EVENT, this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -365,11 +386,7 @@ 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);
|
||||
|
||||
try {
|
||||
renderReport();
|
||||
} catch (Exception e) {
|
||||
throw new AdempiereException("Failed to render report", e);
|
||||
}
|
||||
postRenderReportEvent();
|
||||
|
||||
iframe.setAutohide(true);
|
||||
|
||||
|
@ -443,56 +460,36 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
return AD_Tab_ID;
|
||||
}
|
||||
|
||||
private void renderReport() throws Exception {
|
||||
private void renderReport() {
|
||||
//prepare context for background thread
|
||||
Properties context = ServerContext.getCurrentInstance();
|
||||
if (context.get(AdempiereWebUI.ZK_DESKTOP_SESSION_KEY) == null) {
|
||||
Desktop desktop = this.getDesktop();
|
||||
context.put(AdempiereWebUI.ZK_DESKTOP_SESSION_KEY, new WeakReference<Desktop>(desktop));
|
||||
}
|
||||
|
||||
media = null;
|
||||
Listitem selected = previewType.getSelectedItem();
|
||||
if (selected == null || "PDF".equals(selected.getValue())) {
|
||||
String path = System.getProperty("java.io.tmpdir");
|
||||
String prefix = makePrefix(m_reportEngine.getName());
|
||||
if (log.isLoggable(Level.FINE))
|
||||
{
|
||||
log.log(Level.FINE, "Path="+path + " Prefix="+prefix);
|
||||
}
|
||||
File file = File.createTempFile(prefix, ".pdf", new File(path));
|
||||
m_reportEngine.createPDF(file);
|
||||
media = new AMedia(file.getName(), "pdf", "application/pdf", file, true);
|
||||
|
||||
labelDrill.setVisible(false);
|
||||
comboDrill.setVisible(false);
|
||||
future = Adempiere.getThreadPoolExecutor().submit(new PDFRendererRunnable(this));
|
||||
} else if ("HTML".equals(previewType.getSelectedItem().getValue())) {
|
||||
String path = System.getProperty("java.io.tmpdir");
|
||||
String prefix = makePrefix(m_reportEngine.getName());
|
||||
if (log.isLoggable(Level.FINE))
|
||||
{
|
||||
log.log(Level.FINE, "Path="+path + " Prefix="+prefix);
|
||||
}
|
||||
File file = File.createTempFile(prefix, ".html", new File(path));
|
||||
m_reportEngine.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp", this.getUuid()));
|
||||
media = new AMedia(file.getName(), "html", "text/html", file, false);
|
||||
|
||||
if (comboDrill.getItemCount() > 1) {
|
||||
labelDrill.setVisible(true);
|
||||
comboDrill.setVisible(true);
|
||||
}
|
||||
future = Adempiere.getThreadPoolExecutor().submit(new HTMLRendererRunnable(this));
|
||||
} else if ("XLS".equals(previewType.getSelectedItem().getValue())) {
|
||||
String path = System.getProperty("java.io.tmpdir");
|
||||
String prefix = makePrefix(m_reportEngine.getName());
|
||||
if (log.isLoggable(Level.FINE))
|
||||
{
|
||||
log.log(Level.FINE, "Path="+path + " Prefix="+prefix);
|
||||
future = Adempiere.getThreadPoolExecutor().submit(new XLSRendererRunnable(this));
|
||||
}
|
||||
File file = File.createTempFile(prefix, ".xls", new File(path));
|
||||
m_reportEngine.createXLS(file, AEnv.getLanguage(Env.getCtx()));
|
||||
media = new AMedia(file.getName(), "xls", "application/vnd.ms-excel", file, true);
|
||||
|
||||
labelDrill.setVisible(false);
|
||||
comboDrill.setVisible(false);
|
||||
}
|
||||
|
||||
Events.echoEvent("onPreviewReport", this, null);
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
public void onPreviewReport() {
|
||||
mediaVersion++;
|
||||
String url = Utils.getDynamicMediaURI(this, mediaVersion, media.getName(), media.getFormat());
|
||||
iframe.setContent(media);
|
||||
|
@ -501,6 +498,11 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
url = url.substring((request.getContextPath() + "/").length());
|
||||
reportLink.setHref(url);
|
||||
reportLink.setLabel(media.getName());
|
||||
revalidate();
|
||||
} finally {
|
||||
hideBusyDialog();
|
||||
future = null;
|
||||
}
|
||||
}
|
||||
|
||||
private String makePrefix(String name) {
|
||||
|
@ -713,6 +715,12 @@ 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 {
|
||||
|
@ -728,6 +736,14 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
m_reportEngine.setSummary(summary.isSelected());
|
||||
cmd_report();
|
||||
}
|
||||
else if (event.getName().equals(ON_RENDER_REPORT_EVENT))
|
||||
{
|
||||
onRenderReportEvent();
|
||||
}
|
||||
}
|
||||
|
||||
private void onRenderReportEvent() {
|
||||
renderReport();
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
@ -764,11 +780,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
} // actionPerformed
|
||||
|
||||
private void cmd_render() {
|
||||
try {
|
||||
renderReport();
|
||||
} catch (Exception e) {
|
||||
throw new AdempiereException("Failed to render report", e);
|
||||
}
|
||||
postRenderReportEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1029,15 +1041,15 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
}
|
||||
m_reportEngine.setPrintFormat(pf);
|
||||
|
||||
try {
|
||||
renderReport();
|
||||
} catch (Exception e) {
|
||||
throw new AdempiereException("Failed to render report", e);
|
||||
postRenderReportEvent();
|
||||
} // cmd_report
|
||||
|
||||
private void postRenderReportEvent() {
|
||||
showBusyDialog();
|
||||
Events.echoEvent(ON_RENDER_REPORT_EVENT, this, null);
|
||||
}
|
||||
|
||||
revalidate();
|
||||
|
||||
} // cmd_report
|
||||
|
||||
/**
|
||||
* Query Report
|
||||
|
@ -1137,12 +1149,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
if (!find.isCancel())
|
||||
{
|
||||
m_reportEngine.setQuery(find.getQuery());
|
||||
try {
|
||||
renderReport();
|
||||
} catch (Exception e) {
|
||||
throw new AdempiereException("Failed to render report", e);
|
||||
}
|
||||
revalidate();
|
||||
postRenderReportEvent();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1239,4 +1246,179 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
ToolBarMenuRestictionLoaded = true;
|
||||
}//updateToolBarAndMenuWithRestriction
|
||||
|
||||
private void showBusyDialog() {
|
||||
progressWindow = new BusyDialog();
|
||||
progressWindow.setStyle("position: absolute;");
|
||||
this.appendChild(progressWindow);
|
||||
showBusyMask(progressWindow);
|
||||
LayoutUtils.openOverlappedWindow(this, progressWindow, "middle_center");
|
||||
}
|
||||
|
||||
private Div getMask() {
|
||||
if (mask == null) {
|
||||
mask = new Mask();
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
private void showBusyMask(Window window) {
|
||||
getParent().appendChild(getMask());
|
||||
StringBuilder script = new StringBuilder("var w=zk.Widget.$('#");
|
||||
script.append(getParent().getUuid()).append("');");
|
||||
if (window != null) {
|
||||
script.append("var d=zk.Widget.$('#").append(window.getUuid()).append("');w.busy=d;");
|
||||
} else {
|
||||
script.append("w.busy=true;");
|
||||
}
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
}
|
||||
|
||||
public void hideBusyMask() {
|
||||
if (mask != null && mask.getParent() != null) {
|
||||
mask.detach();
|
||||
StringBuilder script = new StringBuilder("var w=zk.Widget.$('#");
|
||||
script.append(getParent().getUuid()).append("');w.busy=false;");
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private void hideBusyDialog() {
|
||||
hideBusyMask();
|
||||
if (progressWindow != null) {
|
||||
progressWindow.dispose();
|
||||
progressWindow = null;
|
||||
}
|
||||
}
|
||||
|
||||
static class PDFRendererRunnable extends ContextRunnable implements IServerPushCallback {
|
||||
|
||||
private ZkReportViewer viewer;
|
||||
|
||||
public PDFRendererRunnable(ZkReportViewer viewer) {
|
||||
super();
|
||||
this.viewer = viewer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
String path = System.getProperty("java.io.tmpdir");
|
||||
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
||||
if (log.isLoggable(Level.FINE))
|
||||
{
|
||||
log.log(Level.FINE, "Path="+path + " Prefix="+prefix);
|
||||
}
|
||||
File file = File.createTempFile(prefix, ".pdf", new File(path));
|
||||
viewer.m_reportEngine.createPDF(file);
|
||||
viewer.media = new AMedia(file.getName(), "pdf", "application/pdf", file, true);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof RuntimeException)
|
||||
throw (RuntimeException)e;
|
||||
else
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
Desktop desktop = AEnv.getDesktop();
|
||||
if (desktop != null && desktop.isAlive()) {
|
||||
new ServerPushTemplate(desktop).executeAsync(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
viewer.labelDrill.setVisible(false);
|
||||
viewer.comboDrill.setVisible(false);
|
||||
viewer.onPreviewReport();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class HTMLRendererRunnable extends ContextRunnable implements IServerPushCallback {
|
||||
|
||||
private ZkReportViewer viewer;
|
||||
private String contextPath;
|
||||
|
||||
public HTMLRendererRunnable(ZkReportViewer viewer) {
|
||||
super();
|
||||
this.viewer = viewer;
|
||||
contextPath = Executions.getCurrent().getContextPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
String path = System.getProperty("java.io.tmpdir");
|
||||
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
||||
if (log.isLoggable(Level.FINE))
|
||||
{
|
||||
log.log(Level.FINE, "Path="+path + " Prefix="+prefix);
|
||||
}
|
||||
File file = File.createTempFile(prefix, ".html", new File(path));
|
||||
viewer.m_reportEngine.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(contextPath, "rp", viewer.getUuid()));
|
||||
viewer.media = new AMedia(file.getName(), "html", "text/html", file, false);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof RuntimeException)
|
||||
throw (RuntimeException)e;
|
||||
else
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
Desktop desktop = AEnv.getDesktop();
|
||||
if (desktop != null && desktop.isAlive()) {
|
||||
new ServerPushTemplate(desktop).executeAsync(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
if (viewer.comboDrill.getItemCount() > 1) {
|
||||
viewer.labelDrill.setVisible(true);
|
||||
viewer.comboDrill.setVisible(true);
|
||||
}
|
||||
viewer.onPreviewReport();
|
||||
}
|
||||
}
|
||||
|
||||
static class XLSRendererRunnable extends ContextRunnable implements IServerPushCallback {
|
||||
|
||||
private ZkReportViewer viewer;
|
||||
|
||||
public XLSRendererRunnable(ZkReportViewer viewer) {
|
||||
super();
|
||||
this.viewer = viewer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
String path = System.getProperty("java.io.tmpdir");
|
||||
String prefix = viewer.makePrefix(viewer.m_reportEngine.getName());
|
||||
if (log.isLoggable(Level.FINE))
|
||||
{
|
||||
log.log(Level.FINE, "Path="+path + " Prefix="+prefix);
|
||||
}
|
||||
File file = File.createTempFile(prefix, ".xls", new File(path));
|
||||
viewer.m_reportEngine.createXLS(file, AEnv.getLanguage(Env.getCtx()));
|
||||
viewer.media = new AMedia(file.getName(), "xls", "application/vnd.ms-excel", file, true);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof RuntimeException)
|
||||
throw (RuntimeException)e;
|
||||
else
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
Desktop desktop = AEnv.getDesktop();
|
||||
if (desktop != null && desktop.isAlive()) {
|
||||
new ServerPushTemplate(desktop).executeAsync(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
viewer.labelDrill.setVisible(false);
|
||||
viewer.comboDrill.setVisible(false);
|
||||
viewer.onPreviewReport();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue