diff --git a/client/src/org/compiere/apps/APanel.java b/client/src/org/compiere/apps/APanel.java index cd1ac509b8..444b8e253e 100644 --- a/client/src/org/compiere/apps/APanel.java +++ b/client/src/org/compiere/apps/APanel.java @@ -720,7 +720,7 @@ public final class APanel extends CPanel where.toString(), findFields, 10); // no query below 10 query = find.getQuery(); isCancel = (query == null);//Goodwill - find.dispose(); + find.dispose(); find = null; } return query; @@ -1667,7 +1667,7 @@ public final class APanel extends CPanel infoName, infoDisplay); } - new AReport (m_curTab.getAD_Table_ID(), aReport.getButton(), query); + new AReport (m_curTab.getAD_Table_ID(), aReport.getButton(), query, this, m_curWindowNo); } // cmd_report @@ -1774,7 +1774,7 @@ public final class APanel extends CPanel m_curTab.getAD_Table_ID(), m_curTab.getTableName(), m_curTab.getWhereExtended(), findFields, 1); MQuery query = find.getQuery(); - find.dispose(); + find.dispose(); find = null; // Confirmed query @@ -2085,9 +2085,9 @@ public final class APanel extends CPanel { if (ADialog.ask(m_curWindowNo, this, "PostImmediate?")) { - boolean force = ps != null && !ps.equals ("N"); // force when problems + boolean force = ps != null && !ps.equals ("N"); // force when problems String error = AEnv.postImmediate (m_curWindowNo, Env.getAD_Client_ID(m_ctx), - m_curTab.getAD_Table_ID(), m_curTab.getRecord_ID(), force); + m_curTab.getAD_Table_ID(), m_curTab.getRecord_ID(), force); m_curTab.dataRefresh(); if (error != null) ADialog.error(m_curWindowNo, this, "PostingError-N", error); diff --git a/client/src/org/compiere/print/AReport.java b/client/src/org/compiere/print/AReport.java index 7b424d5986..c483fb98e7 100644 --- a/client/src/org/compiere/print/AReport.java +++ b/client/src/org/compiere/print/AReport.java @@ -24,6 +24,7 @@ import java.util.logging.*; import javax.swing.*; import org.compiere.apps.*; import org.compiere.model.*; +import org.compiere.process.ProcessInfo; import org.compiere.util.*; /** @@ -46,6 +47,20 @@ public class AReport implements ActionListener * @param query query */ public AReport (int AD_Table_ID, JComponent invoker, MQuery query) + { + new AReport(AD_Table_ID, invoker, query, null, 0); + } + + /** + * Constructor + * + * @param AD_Table_ID table + * @param invoker component to display popup (optional) + * @param query query + * @param parent The invoking parent window + * @param WindowNo The invoking parent window number + */ + public AReport (int AD_Table_ID, JComponent invoker, MQuery query, ASyncProcess parent, int WindowNo) { log.config("AD_Table_ID=" + AD_Table_ID + " " + query); if (!MRole.getDefault().isCanReport(AD_Table_ID)) @@ -55,6 +70,8 @@ public class AReport implements ActionListener } m_query = query; + this.parent = parent; + this.WindowNo = WindowNo; // See What is there getPrintFormats (AD_Table_ID, invoker); @@ -68,6 +85,10 @@ public class AReport implements ActionListener private ArrayList m_list = new ArrayList(); /** Logger */ private static CLogger log = CLogger.getCLogger(AReport.class); + /** The parent window for locking/unlocking during process execution */ + ASyncProcess parent; + /** The parent window number */ + int WindowNo; /** * Get the Print Formats for the table. @@ -169,8 +190,29 @@ public class AReport implements ActionListener pf.getAD_Table_ID(), Record_ID); info.setDescription(m_query.getInfo()); - ReportEngine re = new ReportEngine (Env.getCtx(), pf, m_query, info); - new Viewer(re); + + if(pf != null && pf.getJasperProcess_ID() > 0) + { + // It's a report using the JasperReports engine + ProcessInfo pi = new ProcessInfo ("", pf.getJasperProcess_ID()); + + // Execute Process + ProcessCtl worker = ProcessCtl.process(parent, WindowNo, pi, null); + if(worker == null) // Process has been canceled + return; + + try { + worker.start(); + } catch(java.lang.IllegalThreadStateException itse) { + // Do nothing + } + } + else + { + // It's a default report using the standard printing engine + ReportEngine re = new ReportEngine (Env.getCtx(), pf, m_query, info); + new Viewer(re); + } // if (m_popup.isVisible()) // m_popup.setVisible(false); } // launchReport