use of org.compiere.model.PrintInfo in project adempiere by adempiere.
the class AReport method launchReport.
// launchReport
/**
* Launch Report
* @param pf print format
*/
private void launchReport(MPrintFormat pf) {
int Record_ID = 0;
// The query is passed into AReport.java with only the key or link column included.
if (m_query.getRestrictionCount() == 1 && m_query.getCode(0) instanceof Integer)
Record_ID = ((Integer) m_query.getCode(0)).intValue();
// Add the extended query after the record ID has been identified.
if (m_whereExtended != null && m_whereExtended.length() > 0 && m_query != null)
m_query.addRestriction(Env.parseContext(Env.getCtx(), WindowNo, m_whereExtended, false));
PrintInfo info = new PrintInfo(pf.getName(), pf.getAD_Table_ID(), Record_ID);
info.setDescription(m_query.getInfo());
if (pf != null && pf.getJasperProcess_ID() > 0) {
// It's a report using the JasperReports engine
ProcessInfo pi = new ProcessInfo("", pf.getJasperProcess_ID(), pf.getAD_Table_ID(), Record_ID);
// Execute Process
ProcessCtl worker = ProcessCtl.process(parent, WindowNo, pi, null);
} else {
// It's a default report using the standard printing engine
ReportEngine re = new ReportEngine(Env.getCtx(), pf, m_query, info);
re.setWhereExtended(m_whereExtended);
re.setWindowNo(WindowNo);
ReportCtl.preview(re);
}
}
use of org.compiere.model.PrintInfo in project adempiere by adempiere.
the class VPrintDocument method print.
@Override
public void print(PO document, String printFormantName, int windowNo) {
JFrame window = Env.getWindow(windowNo);
if (ADialog.ask(windowNo, window, "PrintShipments")) {
window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
// see also ProcessDialog.printShipments/Invoices
int retValue = ADialogDialog.A_CANCEL;
do {
String keyColumnName = document.get_KeyColumns()[0];
MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID(printFormantName, document.get_Table_ID(), 0), false);
MQuery query = new MQuery(document.get_TableName());
query.addRestriction(keyColumnName, MQuery.EQUAL, document.get_ValueAsInt(keyColumnName));
// Engine
PrintInfo info = new PrintInfo(document.get_TableName(), document.get_Table_ID(), document.get_ValueAsInt(keyColumnName));
ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
re.print();
new Viewer(re);
ADialogDialog d = new ADialogDialog(window, Env.getHeader(Env.getCtx(), windowNo), Msg.getMsg(Env.getCtx(), "PrintoutOK?"), JOptionPane.QUESTION_MESSAGE);
retValue = d.getReturnCode();
} while (retValue == ADialogDialog.A_CANCEL);
window.setCursor(Cursor.getDefaultCursor());
}
}
use of org.compiere.model.PrintInfo in project adempiere by adempiere.
the class WReport method launchReport.
// launchReport
/**
* Launch Report
* @param pf print format
*/
private File launchReport(MPrintFormat pf, HttpServletRequest request, GridTab m_curTab, MQuery m_query) {
int Record_ID = 0;
WebSessionCtx wsc = WebSessionCtx.get(request);
WWindowStatus ws = WWindowStatus.get(request);
//Instance pInstance = new MPInstance (wsc.ctx, 0, 0);
File fileName = null;
if (m_query.getRestrictionCount() == 1 && m_query.getCode(0) instanceof Integer) {
Record_ID = ((Integer) m_query.getCode(0)).intValue();
}
PrintInfo info = new PrintInfo(pf.getName(), pf.getAD_Table_ID(), Record_ID);
info.setDescription(m_query.getInfo());
if (pf != null && pf.getJasperProcess_ID() > 0) {
// It's a report using the JasperReports engine
ProcessInfo pi = new ProcessInfo("", pf.getJasperProcess_ID());
Trx trx = Trx.get(Trx.createTrxName("WebPrc"), true);
// Execute Process
WProcessCtl.process(this, m_curTab.getAD_Window_ID(), pi, trx, request);
} else {
// It's a default report using the standard printing engine
ReportEngine re = new ReportEngine(wsc.ctx, pf, m_query, info);
if (re == null) {
log.info("Could not start ReportEngine");
} else {
try {
File file = File.createTempFile("WProcess", ".pdf");
boolean ok = re.createPDF(file);
if (ok) {
fileName = file;
} else {
log.info("Could not create Report");
}
} catch (Exception e) {
log.info(e.toString());
}
}
}
return fileName;
}
use of org.compiere.model.PrintInfo in project adempiere by adempiere.
the class WReport method launchReport.
// launchReport
/**
* Launch Report
* @param pf print format
*/
private void launchReport(MPrintFormat pf) {
int Record_ID = 0;
// The query is passed into A/WReport.java with only the key or link column included.
if (m_query.getRestrictionCount() == 1 && m_query.getCode(0) instanceof Integer)
Record_ID = ((Integer) m_query.getCode(0)).intValue();
// Add the extended query after the record ID has been identified.
if (m_whereExtended != null && m_whereExtended.length() > 0 && m_query != null)
m_query.addRestriction(Env.parseContext(Env.getCtx(), WindowNo, m_whereExtended, false));
PrintInfo info = new PrintInfo(pf.getName(), pf.getAD_Table_ID(), Record_ID);
info.setDescription(m_query.getInfo());
if (pf != null && pf.getJasperProcess_ID() > 0) {
// It's a report using the JasperReports engine
ProcessInfo pi = new ProcessInfo("", pf.getJasperProcess_ID(), pf.getAD_Table_ID(), Record_ID);
// Execute Process
WProcessCtl.process(null, WindowNo, pi, null);
} else {
// It's a default report using the standard printing engine
ReportEngine re = new ReportEngine(Env.getCtx(), pf, m_query, info);
// TODO: Is this required? The extended query, if any, is included in the query.
re.setWhereExtended(m_whereExtended);
ReportCtl.preview(re);
}
}
use of org.compiere.model.PrintInfo in project adempiere by adempiere.
the class Process method startFinReport.
// startCheckPrint
/**
* Start Financial Report.
* @param pi Process Info
* @return true if OK
*/
public static ReportEngine startFinReport(ProcessInfo pi) {
int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
// Create Query from Parameters
String TableName = pi.getAD_Process_ID() == 202 ? "T_Report" : "T_ReportStatement";
MQuery query = MQuery.get(Env.getCtx(), pi.getAD_PInstance_ID(), TableName);
// Get PrintFormat
MPrintFormat format = (MPrintFormat) pi.getTransientObject();
if (format == null)
format = (MPrintFormat) pi.getSerializableObject();
if (format == null) {
log.log(Level.SEVERE, "startFinReport - No PrintFormat");
return null;
}
PrintInfo info = new PrintInfo(pi);
ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
//new Viewer(re);
return re;
}
Aggregations