From 4a5b39811f84c0d47c733e94951f5703815799be Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Wed, 13 Jun 2007 05:17:03 +0000 Subject: [PATCH] [ 1684853 ] Add Print Preview button --- base/src/org/compiere/print/ReportEngine.java | 12 +++++++----- base/src/org/compiere/process/ProcessInfo.java | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/base/src/org/compiere/print/ReportEngine.java b/base/src/org/compiere/print/ReportEngine.java index 473b96b683..a9cc426b0d 100644 --- a/base/src/org/compiere/print/ReportEngine.java +++ b/base/src/org/compiere/print/ReportEngine.java @@ -799,10 +799,10 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) /** * Write PostScript to writer - * @param fos file output stream + * @param os output stream * @return true if success */ - public boolean createPS (FileOutputStream fos) + public boolean createPS (OutputStream os) { try { @@ -817,7 +817,7 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) } // just use first one - sun.print.PSStreamPrinterFactory // System.out.println("- " + spsfactories[0]); - StreamPrintService sps = spsfactories[0].getPrintService(fos); + StreamPrintService sps = spsfactories[0].getPrintService(os); // get format if (m_layout == null) layout(); @@ -825,8 +825,10 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) sps.createPrintJob().print(m_layout.getPageable(false), new HashPrintRequestAttributeSet()); // - fos.flush(); - fos.close(); + os.flush(); + //following 2 line for backward compatibility + if (os instanceof FileOutputStream) + ((FileOutputStream)os).close(); } catch (Exception e) { diff --git a/base/src/org/compiere/process/ProcessInfo.java b/base/src/org/compiere/process/ProcessInfo.java index 1478b298db..fbe4195a87 100644 --- a/base/src/org/compiere/process/ProcessInfo.java +++ b/base/src/org/compiere/process/ProcessInfo.java @@ -44,6 +44,10 @@ public class ProcessInfo implements Serializable setAD_Process_ID(AD_Process_ID); setTable_ID (Table_ID); setRecord_ID (Record_ID); + if (Ini.isPropertyBool(Ini.P_PRINTPREVIEW)) + m_printPreview = true; + else + m_printPreview = false; } // ProcessInfo /** @@ -105,6 +109,8 @@ public class ProcessInfo implements Serializable /** Transaction Name */ private String m_transactionName = null; + + private boolean m_printPreview = false; /** @@ -602,4 +608,14 @@ public class ProcessInfo implements Serializable { m_transactionName = trxName; } + + public void setPrintPreview(boolean b) + { + m_printPreview = b; + } + + public boolean isPrintPreview() + { + return m_printPreview; + } } // ProcessInfo