use of org.compiere.print.MPrintFormat in project adempiere by adempiere.
the class OrderDistributionReceipt method dynInit.
public void dynInit() throws Exception {
setTitle("MovementGenerateInfo");
MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID("Inventory Move Hdr (Example)", MMovement.Table_ID, 0), false);
this.setPrintFormat(format);
setAskPrintMsg("PrintMovements");
}
use of org.compiere.print.MPrintFormat in project adempiere by adempiere.
the class WPrintDocument method print.
public void print(PO document, String printFormantName, int windowNo) {
boolean retValue = true;
if (FDialog.ask(windowNo, SessionManager.getAppDesktop().getComponent(), "PrintShipments")) {
do {
try {
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);
if (re != null) {
SimplePDFViewer win = new SimplePDFViewer(printFormantName, new FileInputStream(re.getPDF()));
SessionManager.getAppDesktop().showWindow(win, "center");
}
} catch (Exception e) {
} finally {
retValue = FDialog.ask(windowNo, SessionManager.getAppDesktop().getComponent(), Msg.getMsg(Env.getCtx(), "PrintoutOK?"));
}
} while (!retValue);
}
}
use of org.compiere.print.MPrintFormat in project adempiere by adempiere.
the class ReleaseInOutBound method getReportEngine.
/*
* get the a Report Engine Instance using the view table
* @param tableName
*/
private ReportEngine getReportEngine(String formatName, String tableName, int recordId) {
// Get Format & Data
int formatId = MPrintFormat.getPrintFormat_ID(formatName, MTable.getTable_ID(tableName), getAD_Client_ID());
MPrintFormat format = MPrintFormat.get(getCtx(), formatId, true);
if (format == null) {
addLog("@NotFound@ @AD_PrintFormat_ID@");
return null;
}
// query
MQuery query = new MQuery(tableName);
query.addRestriction(MDDOrder.COLUMNNAME_DD_Order_ID, MQuery.EQUAL, recordId);
// Engine
PrintInfo info = new PrintInfo(tableName, MTable.getTable_ID(tableName), recordId);
ReportEngine reportEngine = new ReportEngine(getCtx(), format, query, info);
return reportEngine;
}
use of org.compiere.print.MPrintFormat in project adempiere by adempiere.
the class ZkReportViewer method cmd_report.
/**
* Report Combo - Start other Report or create new one
*/
private void cmd_report() {
Listitem pp = (Listitem) comboReport.getSelectedItem();
if (pp != null && (int) pp.getValue() >= 0) {
// Set Default Report View
MPrintFormat pf = MPrintFormat.get(Env.getCtx(), (int) pp.getValue(), true);
selectReportView(pf.getAD_ReportView_ID());
}
// Call Report
cmd_report(false);
}
use of org.compiere.print.MPrintFormat in project adempiere by adempiere.
the class ZkReportViewer method cmd_report.
/**
* Report Combo - Start other Report or create new one
* @param isSummaryChanged for when the check Is Summary is changed
*/
private void cmd_report(boolean isSummaryChanged) {
ListItem li = comboReport.getSelectedItem();
if (li == null || li.getValue() == null)
return;
Object pp = li.getValue();
if (pp == null)
return;
//
MPrintFormat pf = null;
int AD_PrintFormat_ID = Integer.valueOf(pp.toString());
// create new
if (AD_PrintFormat_ID == -1) {
int AD_ReportView_ID = m_reportEngine.getPrintFormat().getAD_ReportView_ID();
if (AD_ReportView_ID != 0) {
String name = m_reportEngine.getName();
int index = name.lastIndexOf('_');
if (index != -1)
name = name.substring(0, index);
pf = MPrintFormat.createFromReportView(m_ctx, AD_ReportView_ID, name);
} else {
int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();
pf = MPrintFormat.createFromTable(m_ctx, AD_Table_ID);
}
if (pf != null)
fillComboReport(pf.get_ID());
else
return;
} else if (AD_PrintFormat_ID == -2) {
MPrintFormat current = m_reportEngine.getPrintFormat();
if (current != null) {
pf = MPrintFormat.copyToClient(m_ctx, current.getAD_PrintFormat_ID(), Env.getAD_Client_ID(m_ctx));
if (pf != null)
fillComboReport(pf.get_ID());
else
return;
} else
return;
} else
pf = MPrintFormat.get(Env.getCtx(), AD_PrintFormat_ID, true);
// FR [ 238 ]
if (pf == null)
return;
//
if (!isSummaryChanged) {
summary.setSelected(pf.isSummary());
}
// Set Summary for report
m_reportEngine.setSummary(summary.isSelected());
// Get Language from previous - thanks Gunther Hoppe
if (m_reportEngine.getPrintFormat() != null) {
// needs to be re-set - otherwise viewer will be blank
pf.setLanguage(m_reportEngine.getPrintFormat().getLanguage());
pf.setTranslationLanguage(m_reportEngine.getPrintFormat().getLanguage());
}
// FR [ 237 ]
Listitem reportView = (Listitem) comboReportView.getSelectedItem();
if (reportView != null) {
m_reportEngine.setAD_ReportView_ID((int) reportView.getValue());
}
m_reportEngine.setPrintFormat(pf);
//
try {
renderReport();
} catch (Exception e) {
throw new AdempiereException("Failed to render report", e);
}
revalidate();
}
Aggregations