[ 1676086 ] JasperReport Printengine for normal Reports

This commit is contained in:
deathmeat 2007-03-20 16:44:33 +00:00
parent 03ae86128f
commit a9a2996718
2 changed files with 49 additions and 7 deletions

View File

@ -720,7 +720,7 @@ public final class APanel extends CPanel
where.toString(), findFields, 10); // no query below 10 where.toString(), findFields, 10); // no query below 10
query = find.getQuery(); query = find.getQuery();
isCancel = (query == null);//Goodwill isCancel = (query == null);//Goodwill
find.dispose(); find.dispose();
find = null; find = null;
} }
return query; return query;
@ -1667,7 +1667,7 @@ public final class APanel extends CPanel
infoName, infoDisplay); 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 } // cmd_report
@ -1774,7 +1774,7 @@ public final class APanel extends CPanel
m_curTab.getAD_Table_ID(), m_curTab.getTableName(), m_curTab.getAD_Table_ID(), m_curTab.getTableName(),
m_curTab.getWhereExtended(), findFields, 1); m_curTab.getWhereExtended(), findFields, 1);
MQuery query = find.getQuery(); MQuery query = find.getQuery();
find.dispose(); find.dispose();
find = null; find = null;
// Confirmed query // Confirmed query
@ -2085,9 +2085,9 @@ public final class APanel extends CPanel
{ {
if (ADialog.ask(m_curWindowNo, this, "PostImmediate?")) 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), 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(); m_curTab.dataRefresh();
if (error != null) if (error != null)
ADialog.error(m_curWindowNo, this, "PostingError-N", error); ADialog.error(m_curWindowNo, this, "PostingError-N", error);

View File

@ -24,6 +24,7 @@ import java.util.logging.*;
import javax.swing.*; import javax.swing.*;
import org.compiere.apps.*; import org.compiere.apps.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.process.ProcessInfo;
import org.compiere.util.*; import org.compiere.util.*;
/** /**
@ -46,6 +47,20 @@ public class AReport implements ActionListener
* @param query query * @param query query
*/ */
public AReport (int AD_Table_ID, JComponent invoker, MQuery 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); log.config("AD_Table_ID=" + AD_Table_ID + " " + query);
if (!MRole.getDefault().isCanReport(AD_Table_ID)) if (!MRole.getDefault().isCanReport(AD_Table_ID))
@ -55,6 +70,8 @@ public class AReport implements ActionListener
} }
m_query = query; m_query = query;
this.parent = parent;
this.WindowNo = WindowNo;
// See What is there // See What is there
getPrintFormats (AD_Table_ID, invoker); getPrintFormats (AD_Table_ID, invoker);
@ -68,6 +85,10 @@ public class AReport implements ActionListener
private ArrayList<KeyNamePair> m_list = new ArrayList<KeyNamePair>(); private ArrayList<KeyNamePair> m_list = new ArrayList<KeyNamePair>();
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(AReport.class); 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. * Get the Print Formats for the table.
@ -169,8 +190,29 @@ public class AReport implements ActionListener
pf.getAD_Table_ID(), pf.getAD_Table_ID(),
Record_ID); Record_ID);
info.setDescription(m_query.getInfo()); 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()) // if (m_popup.isVisible())
// m_popup.setVisible(false); // m_popup.setVisible(false);
} // launchReport } // launchReport