[ 1684853 ] Add Print Preview button
[ 1729327 ] Reporting Functionality ( zk client )
This commit is contained in:
parent
4a5b39811f
commit
361c3f4982
|
@ -159,7 +159,7 @@ public final class APanel extends CPanel
|
|||
} // jbInit
|
||||
|
||||
private AppsAction aPrevious, aNext, aParent, aDetail, aFirst, aLast,
|
||||
aNew, aCopy, aDelete, aPrint,
|
||||
aNew, aCopy, aDelete, aPrint, aPrintPreview,
|
||||
aRefresh, aHistory, aAttachment, aChat, aMulti, aFind,
|
||||
aWorkflow, aZoomAcross, aRequest, aWinSize, aArchive;
|
||||
/** 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);
|
||||
aReport = addAction("Report", mFile, KeyStroke.getKeyStroke(KeyEvent.VK_F11, 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();
|
||||
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);
|
||||
|
@ -339,6 +340,7 @@ public final class APanel extends CPanel
|
|||
toolBar.addSeparator();
|
||||
toolBar.add(aReport.getButton());
|
||||
toolBar.add(aArchive.getButton());
|
||||
toolBar.add(aPrintPreview.getButton());
|
||||
toolBar.add(aPrint.getButton());
|
||||
toolBar.addSeparator();
|
||||
if (m_isPersonalLock)
|
||||
|
@ -1184,6 +1186,7 @@ public final class APanel extends CPanel
|
|||
}
|
||||
// Document Print
|
||||
aPrint.setEnabled(m_curTab.isPrinted());
|
||||
aPrintPreview.setEnabled(m_curTab.isPrinted());
|
||||
// Query
|
||||
aFind.setPressed(m_curTab.isQueryActive());
|
||||
|
||||
|
@ -1319,6 +1322,8 @@ public final class APanel extends CPanel
|
|||
cmd_report();
|
||||
else if (cmd.equals(aPrint.getName()))
|
||||
cmd_print();
|
||||
else if (cmd.equals(aPrintPreview.getName()))
|
||||
cmd_print(true);
|
||||
else if (cmd.equals(aEnd.getName()))
|
||||
cmd_end(false);
|
||||
else if (cmd.equals(aExit.getName()))
|
||||
|
@ -1694,6 +1699,7 @@ public final class APanel extends CPanel
|
|||
}
|
||||
m_curTab.dataIgnore();
|
||||
m_curGC.dynamicDisplay(0);
|
||||
|
||||
} // cmd_ignore
|
||||
|
||||
/**
|
||||
|
@ -1823,6 +1829,14 @@ public final class APanel extends CPanel
|
|||
* Print specific Report - or start default Report
|
||||
*/
|
||||
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
|
||||
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);
|
||||
pi.setAD_User_ID (Env.getAD_User_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
|
||||
} // cmd_print
|
||||
|
|
|
@ -174,11 +174,13 @@ public class ProcessCtl implements Runnable
|
|||
pi.setAD_PInstance_ID (instance.getAD_PInstance_ID());
|
||||
|
||||
// Get Parameters
|
||||
if (!parameter.saveParameters())
|
||||
{
|
||||
pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessCancelled"));
|
||||
pi.setError (true);
|
||||
return null;
|
||||
if (parameter != null) {
|
||||
if (!parameter.saveParameters())
|
||||
{
|
||||
pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessCancelled"));
|
||||
pi.setError (true);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// execute
|
||||
|
@ -258,6 +260,8 @@ public class ProcessCtl implements Runnable
|
|||
int AD_Workflow_ID = 0;
|
||||
boolean IsReport = false;
|
||||
boolean IsDirectPrint = false;
|
||||
boolean isPrintPreview = m_pi.isPrintPreview();
|
||||
|
||||
//
|
||||
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
|
||||
|
@ -297,7 +301,8 @@ public class ProcessCtl implements Runnable
|
|||
if ("Y".equals(rs.getString(5)))
|
||||
{
|
||||
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;
|
||||
}
|
||||
AD_ReportView_ID = rs.getInt(7);
|
||||
|
|
Before Width: | Height: | Size: 779 B After Width: | Height: | Size: 779 B |
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 |
|
@ -18,13 +18,13 @@ package org.compiere.print;
|
|||
|
||||
import java.util.logging.*;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import org.compiere.apps.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
import sun.misc.Launcher;
|
||||
|
||||
/**
|
||||
* Report Controller.
|
||||
*
|
||||
|
@ -43,6 +43,8 @@ public class ReportCtl
|
|||
/** Static Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (ReportCtl.class);
|
||||
|
||||
private static ReportViewerProvider viewerProvider = new SwingViewerProvider();
|
||||
|
||||
/**
|
||||
* Create Report.
|
||||
* Called from ProcessCtl.
|
||||
|
@ -69,6 +71,23 @@ public class ReportCtl
|
|||
* @return true if created
|
||||
*/
|
||||
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);
|
||||
|
||||
|
@ -76,17 +95,17 @@ public class ReportCtl
|
|||
* Order Print
|
||||
*/
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
return startCheckPrint(pi.getRecord_ID(), IsDirectPrint);
|
||||
return startCheckPrint(pi.getRecord_ID(), !pi.isPrintPreview());
|
||||
/**
|
||||
else if (pi.getAD_Process_ID() == 290) // Movement Submission by VHARCQ
|
||||
return startDocumentPrint(ReportEngine.MOVEMENT, pi.getRecord_ID(), parent, WindowNo, IsDirectPrint);
|
||||
|
@ -96,17 +115,16 @@ public class ReportCtl
|
|||
return startDocumentPrint(REMITTANCE, pi, IsDirectPrint);
|
||||
**/
|
||||
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
|
||||
|| pi.getAD_Process_ID() == 204) // Financial Statement
|
||||
return startFinReport (pi);
|
||||
/********************
|
||||
* Standard Report
|
||||
*******************/
|
||||
return startStandardReport (pi, IsDirectPrint);
|
||||
return startStandardReport (pi);
|
||||
} // create
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Start Standard Report.
|
||||
* - Get Table Info & submit
|
||||
|
@ -115,6 +133,19 @@ public class ReportCtl
|
|||
* @return true if OK
|
||||
*/
|
||||
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);
|
||||
if (re == null)
|
||||
|
@ -122,12 +153,8 @@ public class ReportCtl
|
|||
pi.setSummary("No ReportEngine");
|
||||
return false;
|
||||
}
|
||||
if (IsDirectPrint)
|
||||
{
|
||||
re.print();
|
||||
}
|
||||
else
|
||||
preview(re);
|
||||
|
||||
createOutput(re, pi.isPrintPreview());
|
||||
return true;
|
||||
} // startStandardReport
|
||||
|
||||
|
@ -156,7 +183,7 @@ public class ReportCtl
|
|||
PrintInfo info = new PrintInfo(pi);
|
||||
|
||||
ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
|
||||
preview(re);
|
||||
createOutput(re, pi.isPrintPreview());
|
||||
return true;
|
||||
} // startFinReport
|
||||
|
||||
|
@ -183,7 +210,8 @@ public class ReportCtl
|
|||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @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);
|
||||
if (re == null)
|
||||
|
@ -195,7 +223,7 @@ public class ReportCtl
|
|||
if(re.getPrintFormat() != null && re.getPrintFormat().getJasperProcess_ID() > 0)
|
||||
{
|
||||
ProcessInfo pi = new ProcessInfo ("", re.getPrintFormat().getJasperProcess_ID());
|
||||
|
||||
pi.setPrintPreview(!IsDirectPrint);
|
||||
// Execute Process
|
||||
ProcessCtl worker = ProcessCtl.process(parent, WindowNo, pi, null);
|
||||
if(worker == null) // Process has been canceled
|
||||
|
@ -209,13 +237,11 @@ public class ReportCtl
|
|||
}
|
||||
else
|
||||
{
|
||||
createOutput(re, !IsDirectPrint);
|
||||
if (IsDirectPrint)
|
||||
{
|
||||
re.print ();
|
||||
ReportEngine.printConfirm (type, Record_ID);
|
||||
}
|
||||
else
|
||||
preview(re);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -243,10 +269,29 @@ public class ReportCtl
|
|||
return startDocumentPrint (ReportEngine.CHECK, C_PaySelectionCheck_ID, null, -1, IsDirectPrint);
|
||||
} // startCheckPrint
|
||||
|
||||
private static void preview(ReportEngine re) {
|
||||
Viewer viewer = new Viewer(re);
|
||||
JFrame top = Env.getWindow(0);
|
||||
if (top instanceof AMenu)
|
||||
((AMenu)top).getWindowManager().add(viewer);
|
||||
private static void createOutput(ReportEngine re, boolean printPreview)
|
||||
{
|
||||
if (printPreview)
|
||||
preview(re);
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue