[ 1684853 ] Add Print Preview button

[ 1729327 ] Reporting Functionality ( zk client )
This commit is contained in:
Heng Sin Low 2007-06-13 05:20:23 +00:00
parent 4a5b39811f
commit 361c3f4982
9 changed files with 166 additions and 35 deletions

View File

@ -159,7 +159,7 @@ public final class APanel extends CPanel
} // jbInit } // jbInit
private AppsAction aPrevious, aNext, aParent, aDetail, aFirst, aLast, private AppsAction aPrevious, aNext, aParent, aDetail, aFirst, aLast,
aNew, aCopy, aDelete, aPrint, aNew, aCopy, aDelete, aPrint, aPrintPreview,
aRefresh, aHistory, aAttachment, aChat, aMulti, aFind, aRefresh, aHistory, aAttachment, aChat, aMulti, aFind,
aWorkflow, aZoomAcross, aRequest, aWinSize, aArchive; aWorkflow, aZoomAcross, aRequest, aWinSize, aArchive;
/** Ignore Button */ /** Ignore Button */
@ -191,6 +191,7 @@ public final class APanel extends CPanel
aScrShot = addAction("ScreenShot", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, Event.SHIFT_MASK), false); aScrShot = addAction("ScreenShot", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_PRINTSCREEN, Event.SHIFT_MASK), false);
aReport = addAction("Report", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0), false); aReport = addAction("Report", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0), false);
aPrint = addAction("Print", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0), false); aPrint = addAction("Print", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0), false);
aPrintPreview = addAction("PrintPreview", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.SHIFT_MASK+Event.ALT_MASK), false);
mFile.addSeparator(); mFile.addSeparator();
aEnd = addAction("End", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.ALT_MASK), false); aEnd = addAction("End", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.ALT_MASK), false);
aLogout = addAction("Logout", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.SHIFT_MASK+Event.ALT_MASK), false); aLogout = addAction("Logout", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.SHIFT_MASK+Event.ALT_MASK), false);
@ -339,6 +340,7 @@ public final class APanel extends CPanel
toolBar.addSeparator(); toolBar.addSeparator();
toolBar.add(aReport.getButton()); toolBar.add(aReport.getButton());
toolBar.add(aArchive.getButton()); toolBar.add(aArchive.getButton());
toolBar.add(aPrintPreview.getButton());
toolBar.add(aPrint.getButton()); toolBar.add(aPrint.getButton());
toolBar.addSeparator(); toolBar.addSeparator();
if (m_isPersonalLock) if (m_isPersonalLock)
@ -1184,6 +1186,7 @@ public final class APanel extends CPanel
} }
// Document Print // Document Print
aPrint.setEnabled(m_curTab.isPrinted()); aPrint.setEnabled(m_curTab.isPrinted());
aPrintPreview.setEnabled(m_curTab.isPrinted());
// Query // Query
aFind.setPressed(m_curTab.isQueryActive()); aFind.setPressed(m_curTab.isQueryActive());
@ -1319,6 +1322,8 @@ public final class APanel extends CPanel
cmd_report(); cmd_report();
else if (cmd.equals(aPrint.getName())) else if (cmd.equals(aPrint.getName()))
cmd_print(); cmd_print();
else if (cmd.equals(aPrintPreview.getName()))
cmd_print(true);
else if (cmd.equals(aEnd.getName())) else if (cmd.equals(aEnd.getName()))
cmd_end(false); cmd_end(false);
else if (cmd.equals(aExit.getName())) else if (cmd.equals(aExit.getName()))
@ -1694,6 +1699,7 @@ public final class APanel extends CPanel
} }
m_curTab.dataIgnore(); m_curTab.dataIgnore();
m_curGC.dynamicDisplay(0); m_curGC.dynamicDisplay(0);
} // cmd_ignore } // cmd_ignore
/** /**
@ -1823,6 +1829,14 @@ public final class APanel extends CPanel
* Print specific Report - or start default Report * Print specific Report - or start default Report
*/ */
private void cmd_print() private void cmd_print()
{
cmd_print(false);
}
/**
* Print specific Report - or start default Report
*/
private void cmd_print(boolean printPreview)
{ {
// Get process defined for this tab // Get process defined for this tab
int AD_Process_ID = m_curTab.getAD_Process_ID(); int AD_Process_ID = m_curTab.getAD_Process_ID();
@ -1842,6 +1856,7 @@ public final class APanel extends CPanel
ProcessInfo pi = new ProcessInfo (getTitle(), AD_Process_ID, table_ID, record_ID); ProcessInfo pi = new ProcessInfo (getTitle(), AD_Process_ID, table_ID, record_ID);
pi.setAD_User_ID (Env.getAD_User_ID(m_ctx)); pi.setAD_User_ID (Env.getAD_User_ID(m_ctx));
pi.setAD_Client_ID (Env.getAD_Client_ID(m_ctx)); pi.setAD_Client_ID (Env.getAD_Client_ID(m_ctx));
pi.setPrintPreview(printPreview);
ProcessCtl.process(this, m_curWindowNo, pi, null); // calls lockUI, unlockUI ProcessCtl.process(this, m_curWindowNo, pi, null); // calls lockUI, unlockUI
} // cmd_print } // cmd_print

View File

@ -174,11 +174,13 @@ public class ProcessCtl implements Runnable
pi.setAD_PInstance_ID (instance.getAD_PInstance_ID()); pi.setAD_PInstance_ID (instance.getAD_PInstance_ID());
// Get Parameters // Get Parameters
if (!parameter.saveParameters()) if (parameter != null) {
{ if (!parameter.saveParameters())
pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessCancelled")); {
pi.setError (true); pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessCancelled"));
return null; pi.setError (true);
return null;
}
} }
// execute // execute
@ -258,6 +260,8 @@ public class ProcessCtl implements Runnable
int AD_Workflow_ID = 0; int AD_Workflow_ID = 0;
boolean IsReport = false; boolean IsReport = false;
boolean IsDirectPrint = false; boolean IsDirectPrint = false;
boolean isPrintPreview = m_pi.isPrintPreview();
// //
String sql = "SELECT p.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4 String sql = "SELECT p.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4
+ " p.isReport,p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8 + " p.isReport,p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8
@ -297,7 +301,8 @@ public class ProcessCtl implements Runnable
if ("Y".equals(rs.getString(5))) if ("Y".equals(rs.getString(5)))
{ {
IsReport = true; IsReport = true;
if ("Y".equals(rs.getString(6)) && !Ini.isPropertyBool(Ini.P_PRINTPREVIEW)) if ("Y".equals(rs.getString(6)) && !Ini.isPropertyBool(Ini.P_PRINTPREVIEW)
&& !isPrintPreview )
IsDirectPrint = true; IsDirectPrint = true;
} }
AD_ReportView_ID = rs.getInt(7); AD_ReportView_ID = rs.getInt(7);

View File

Before

Width:  |  Height:  |  Size: 779 B

After

Width:  |  Height:  |  Size: 779 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

View File

@ -18,13 +18,13 @@ package org.compiere.print;
import java.util.logging.*; import java.util.logging.*;
import javax.swing.JFrame;
import org.compiere.apps.*; import org.compiere.apps.*;
import org.compiere.model.*; import org.compiere.model.*;
import org.compiere.process.*; import org.compiere.process.*;
import org.compiere.util.*; import org.compiere.util.*;
import sun.misc.Launcher;
/** /**
* Report Controller. * Report Controller.
* *
@ -43,6 +43,8 @@ public class ReportCtl
/** Static Logger */ /** Static Logger */
private static CLogger s_log = CLogger.getCLogger (ReportCtl.class); private static CLogger s_log = CLogger.getCLogger (ReportCtl.class);
private static ReportViewerProvider viewerProvider = new SwingViewerProvider();
/** /**
* Create Report. * Create Report.
* Called from ProcessCtl. * Called from ProcessCtl.
@ -69,6 +71,23 @@ public class ReportCtl
* @return true if created * @return true if created
*/ */
static public boolean start (ASyncProcess parent, int WindowNo, ProcessInfo pi, boolean IsDirectPrint) static public boolean start (ASyncProcess parent, int WindowNo, ProcessInfo pi, boolean IsDirectPrint)
{
pi.setPrintPreview(!IsDirectPrint);
return start(parent, WindowNo, pi);
}
/**
* Create Report.
* Called from ProcessCtl.
* - Check special reports first, if not, create standard Report
*
* @param parent The window which invoked the printing
* @param WindowNo The windows number which invoked the printing
* @param pi process info
* @param IsDirectPrint if true, prints directly - otherwise View
* @return true if created
*/
static public boolean start (ASyncProcess parent, int WindowNo, ProcessInfo pi)
{ {
s_log.info("start - " + pi); s_log.info("start - " + pi);
@ -76,17 +95,17 @@ public class ReportCtl
* Order Print * Order Print
*/ */
if (pi.getAD_Process_ID() == 110) // C_Order if (pi.getAD_Process_ID() == 110) // C_Order
return startDocumentPrint(ReportEngine.ORDER, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint); return startDocumentPrint(ReportEngine.ORDER, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
else if (pi.getAD_Process_ID() == 116) // C_Invoice else if (pi.getAD_Process_ID() == 116) // C_Invoice
return startDocumentPrint(ReportEngine.INVOICE, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint); return startDocumentPrint(ReportEngine.INVOICE, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
else if (pi.getAD_Process_ID() == 117) // M_InOut else if (pi.getAD_Process_ID() == 117) // M_InOut
return startDocumentPrint(ReportEngine.SHIPMENT, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint); return startDocumentPrint(ReportEngine.SHIPMENT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
else if (pi.getAD_Process_ID() == 217) // C_Project else if (pi.getAD_Process_ID() == 217) // C_Project
return startDocumentPrint(ReportEngine.PROJECT, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint); return startDocumentPrint(ReportEngine.PROJECT, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
else if (pi.getAD_Process_ID() == 276) // C_RfQResponse else if (pi.getAD_Process_ID() == 276) // C_RfQResponse
return startDocumentPrint(ReportEngine.RFQ, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint); return startDocumentPrint(ReportEngine.RFQ, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
else if (pi.getAD_Process_ID() == 313) // C_Payment else if (pi.getAD_Process_ID() == 313) // C_Payment
return startCheckPrint(pi.getRecord_ID(), IsDirectPrint); return startCheckPrint(pi.getRecord_ID(), !pi.isPrintPreview());
/** /**
else if (pi.getAD_Process_ID() == 290) // Movement Submission by VHARCQ else if (pi.getAD_Process_ID() == 290) // Movement Submission by VHARCQ
return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint); return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint);
@ -96,17 +115,16 @@ public class ReportCtl
return startDocumentPrint(REMITTANCE, pi, IsDirectPrint); return startDocumentPrint(REMITTANCE, pi, IsDirectPrint);
**/ **/
else if (pi.getAD_Process_ID() == 159) // Dunning else if (pi.getAD_Process_ID() == 159) // Dunning
return startDocumentPrint(ReportEngine.DUNNING, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint); return startDocumentPrint(ReportEngine.DUNNING, pi.getRecord_ID(), parent, WindowNo, !pi.isPrintPreview());
else if (pi.getAD_Process_ID() == 202 // Financial Report else if (pi.getAD_Process_ID() == 202 // Financial Report
|| pi.getAD_Process_ID() == 204) // Financial Statement || pi.getAD_Process_ID() == 204) // Financial Statement
return startFinReport (pi); return startFinReport (pi);
/******************** /********************
* Standard Report * Standard Report
*******************/ *******************/
return startStandardReport (pi, IsDirectPrint); return startStandardReport (pi);
} // create } // create
/************************************************************************** /**************************************************************************
* Start Standard Report. * Start Standard Report.
* - Get Table Info & submit * - Get Table Info & submit
@ -115,6 +133,19 @@ public class ReportCtl
* @return true if OK * @return true if OK
*/ */
static public boolean startStandardReport (ProcessInfo pi, boolean IsDirectPrint) static public boolean startStandardReport (ProcessInfo pi, boolean IsDirectPrint)
{
pi.setPrintPreview(!IsDirectPrint);
return startStandardReport(pi);
}
/**************************************************************************
* Start Standard Report.
* - Get Table Info & submit
* @param pi Process Info
* @param IsDirectPrint if true, prints directly - otherwise View
* @return true if OK
*/
static public boolean startStandardReport (ProcessInfo pi)
{ {
ReportEngine re = ReportEngine.get(Env.getCtx(), pi); ReportEngine re = ReportEngine.get(Env.getCtx(), pi);
if (re == null) if (re == null)
@ -122,12 +153,8 @@ public class ReportCtl
pi.setSummary("No ReportEngine"); pi.setSummary("No ReportEngine");
return false; return false;
} }
if (IsDirectPrint)
{ createOutput(re, pi.isPrintPreview());
re.print();
}
else
preview(re);
return true; return true;
} // startStandardReport } // startStandardReport
@ -156,7 +183,7 @@ public class ReportCtl
PrintInfo info = new PrintInfo(pi); PrintInfo info = new PrintInfo(pi);
ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info); ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
preview(re); createOutput(re, pi.isPrintPreview());
return true; return true;
} // startFinReport } // startFinReport
@ -183,7 +210,8 @@ public class ReportCtl
* @param IsDirectPrint if true, prints directly - otherwise View * @param IsDirectPrint if true, prints directly - otherwise View
* @return true if success * @return true if success
*/ */
public static boolean startDocumentPrint (int type, int Record_ID, ASyncProcess parent, int WindowNo, boolean IsDirectPrint) public static boolean startDocumentPrint (int type, int Record_ID, ASyncProcess parent, int WindowNo,
boolean IsDirectPrint)
{ {
ReportEngine re = ReportEngine.get (Env.getCtx(), type, Record_ID); ReportEngine re = ReportEngine.get (Env.getCtx(), type, Record_ID);
if (re == null) if (re == null)
@ -195,7 +223,7 @@ public class ReportCtl
if(re.getPrintFormat() != null && re.getPrintFormat().getJasperProcess_ID() > 0) if(re.getPrintFormat() != null && re.getPrintFormat().getJasperProcess_ID() > 0)
{ {
ProcessInfo pi = new ProcessInfo ("", re.getPrintFormat().getJasperProcess_ID()); ProcessInfo pi = new ProcessInfo ("", re.getPrintFormat().getJasperProcess_ID());
pi.setPrintPreview(!IsDirectPrint);
// Execute Process // Execute Process
ProcessCtl worker = ProcessCtl.process(parent, WindowNo, pi, null); ProcessCtl worker = ProcessCtl.process(parent, WindowNo, pi, null);
if(worker == null) // Process has been canceled if(worker == null) // Process has been canceled
@ -209,13 +237,11 @@ public class ReportCtl
} }
else else
{ {
createOutput(re, !IsDirectPrint);
if (IsDirectPrint) if (IsDirectPrint)
{ {
re.print ();
ReportEngine.printConfirm (type, Record_ID); ReportEngine.printConfirm (type, Record_ID);
} }
else
preview(re);
} }
return true; return true;
@ -243,10 +269,29 @@ public class ReportCtl
return startDocumentPrint (ReportEngine.CHECK, C_PaySelectionCheck_ID, null, -1, IsDirectPrint); return startDocumentPrint (ReportEngine.CHECK, C_PaySelectionCheck_ID, null, -1, IsDirectPrint);
} // startCheckPrint } // startCheckPrint
private static void preview(ReportEngine re) { private static void createOutput(ReportEngine re, boolean printPreview)
Viewer viewer = new Viewer(re); {
JFrame top = Env.getWindow(0); if (printPreview)
if (top instanceof AMenu) preview(re);
((AMenu)top).getWindowManager().add(viewer); else
re.print();
}
private static void preview(ReportEngine re)
{
ReportViewerProvider provider = getReportViewerProvider();
provider.openViewer(re);
}
public static void setReportViewerProvider(ReportViewerProvider provider)
{
if (provider == null)
throw new IllegalArgumentException("Cannot set report viewer provider to null");
viewerProvider = provider;
}
public static ReportViewerProvider getReportViewerProvider()
{
return viewerProvider;
} }
} // ReportCtl } // ReportCtl

View File

@ -0,0 +1,28 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2007 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*
* Copyright (C) 2007 Low Heng Sin hengsin@avantz.com
* _____________________________________________
*****************************************************************************/
package org.compiere.print;
import org.compiere.print.ReportEngine;
/**
*
* @author Low Heng Sin
*
*/
public interface ReportViewerProvider {
public void openViewer(ReportEngine re);
}

View File

@ -0,0 +1,38 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2007 Adempiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*
* Copyright (C) 2007 Low Heng Sin hengsin@avantz.com
* _____________________________________________
*****************************************************************************/
package org.compiere.print;
import javax.swing.JFrame;
import org.compiere.apps.AMenu;
import org.compiere.util.Env;
/**
*
* @author Low Heng Sin
*
*/
public class SwingViewerProvider implements ReportViewerProvider {
public void openViewer(ReportEngine re) {
Viewer viewer = new Viewer(re);
JFrame top = Env.getWindow(0);
if (top instanceof AMenu)
((AMenu)top).getWindowManager().add(viewer);
}
}