http://sourceforge.net/tracker/?func=detail&atid=955896&aid=2912815&group_id=176962 [Jasper Report in Process problem]
- ported ProcessCtl to WProcessCtl to remove swing dependency for process and report - modify ReportCtl to call WProcessCtl using reflection - refactor and cleanup of ProcessModalDialog - modify WReport to call WProcessCtl instead of ProcessCtl
This commit is contained in:
parent
eebe80ec8f
commit
7e698c6883
|
@ -33,6 +33,7 @@ import org.compiere.util.ASyncProcess;
|
|||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.Trx;
|
||||
|
||||
/**
|
||||
* Report Controller.
|
||||
|
@ -285,7 +286,26 @@ public class ReportCtl
|
|||
pi.setPrintPreview( !IsDirectPrint );
|
||||
pi.setRecord_ID ( Record_ID );
|
||||
// Execute Process
|
||||
ProcessCtl worker = ProcessCtl.process(parent, WindowNo, pi, null);
|
||||
if (Ini.isClient())
|
||||
{
|
||||
ProcessCtl.process(parent, WindowNo, pi, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
if (loader == null)
|
||||
loader = ReportCtl.class.getClassLoader();
|
||||
Class<?> clazz = loader.loadClass("org.adempiere.webui.apps.WProcessCtl");
|
||||
Method method = clazz.getDeclaredMethod("process", ASyncProcess.class, Integer.TYPE, ProcessInfo.class, Trx.class);
|
||||
method.invoke(null, parent, WindowNo, pi, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AdempiereException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -60,39 +60,27 @@ import org.zkoss.zul.Html;
|
|||
*/
|
||||
public class ProcessModalDialog extends Window implements EventListener
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -351486051681812866L;
|
||||
private static final long serialVersionUID = 8828804363347622789L;
|
||||
private boolean m_autoStart;
|
||||
|
||||
|
||||
/**
|
||||
* Dialog to start a process/report
|
||||
* @param ctx
|
||||
* @param parent
|
||||
* @param title
|
||||
* @param aProcess
|
||||
* @param WindowNo
|
||||
* @param AD_Process_ID
|
||||
* @param tableId
|
||||
* @param recordId
|
||||
* @param pi
|
||||
* @param autoStart
|
||||
*/
|
||||
public ProcessModalDialog (Window parent, String title,
|
||||
ASyncProcess aProcess, int WindowNo, int AD_Process_ID,
|
||||
int tableId, int recordId, boolean autoStart)
|
||||
public ProcessModalDialog(ASyncProcess aProcess, int WindowNo, ProcessInfo pi, boolean autoStart)
|
||||
{
|
||||
|
||||
log.info("Process=" + AD_Process_ID );
|
||||
m_ctx = Env.getCtx();
|
||||
m_ASyncProcess = aProcess;
|
||||
m_WindowNo = WindowNo;
|
||||
m_AD_Process_ID = AD_Process_ID;
|
||||
m_tableId = tableId;
|
||||
m_recordId = recordId;
|
||||
m_pi = pi;
|
||||
m_autoStart = autoStart;
|
||||
|
||||
log.info("Process=" + pi.getAD_Process_ID());
|
||||
try
|
||||
{
|
||||
initComponents();
|
||||
|
@ -102,6 +90,41 @@ public class ProcessModalDialog extends Window implements EventListener
|
|||
{
|
||||
log.log(Level.SEVERE, "", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialog to start a process/report
|
||||
* @param ctx
|
||||
* @param aProcess
|
||||
* @param WindowNo
|
||||
* @param AD_Process_ID
|
||||
* @param tableId
|
||||
* @param recordId
|
||||
* @param autoStart
|
||||
*/
|
||||
public ProcessModalDialog ( ASyncProcess aProcess, int WindowNo, int AD_Process_ID, int tableId, int recordId, boolean autoStart)
|
||||
{
|
||||
this(aProcess, WindowNo, new ProcessInfo("", AD_Process_ID, tableId, recordId), autoStart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialog to start a process/report
|
||||
* @param ctx
|
||||
* @param parent not used
|
||||
* @param title not used
|
||||
* @param aProcess
|
||||
* @param WindowNo
|
||||
* @param AD_Process_ID
|
||||
* @param tableId
|
||||
* @param recordId
|
||||
* @param autoStart
|
||||
* @deprecated
|
||||
*/
|
||||
public ProcessModalDialog (Window parent, String title,
|
||||
ASyncProcess aProcess, int WindowNo, int AD_Process_ID,
|
||||
int tableId, int recordId, boolean autoStart)
|
||||
{
|
||||
this(aProcess, WindowNo, AD_Process_ID, tableId, recordId, autoStart);
|
||||
} // ProcessDialog
|
||||
|
||||
private void initComponents() {
|
||||
|
@ -137,9 +160,6 @@ public class ProcessModalDialog extends Window implements EventListener
|
|||
private ASyncProcess m_ASyncProcess;
|
||||
private int m_WindowNo;
|
||||
private Properties m_ctx;
|
||||
private int m_tableId;
|
||||
private int m_recordId;
|
||||
private int m_AD_Process_ID;
|
||||
private String m_Name = null;
|
||||
private StringBuffer m_messageText = new StringBuffer();
|
||||
private String m_ShowHelp = null; // Determine if a Help Process Window is shown
|
||||
|
@ -206,7 +226,7 @@ public class ProcessModalDialog extends Window implements EventListener
|
|||
try
|
||||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, m_AD_Process_ID);
|
||||
pstmt.setInt(1, m_pi.getAD_Process_ID());
|
||||
if (trl)
|
||||
pstmt.setString(2, Env.getAD_Language(m_ctx));
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
|
@ -245,9 +265,9 @@ public class ProcessModalDialog extends Window implements EventListener
|
|||
|
||||
|
||||
// Move from APanel.actionButton
|
||||
m_pi = new ProcessInfo(m_Name, m_AD_Process_ID, m_tableId, m_recordId);
|
||||
m_pi.setAD_User_ID (Env.getAD_User_ID(Env.getCtx()));
|
||||
m_pi.setAD_Client_ID(Env.getAD_Client_ID(Env.getCtx()));
|
||||
m_pi.setTitle(m_Name);
|
||||
parameterPanel = new ProcessParameterPanel(m_WindowNo, m_pi);
|
||||
centerPanel.getChildren().clear();
|
||||
if ( parameterPanel.init() ) {
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, 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. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.apps;
|
||||
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.compiere.apps.IProcessParameter;
|
||||
import org.compiere.apps.ProcessCtl;
|
||||
import org.compiere.model.MPInstance;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.ASyncProcess;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Trx;
|
||||
|
||||
/**
|
||||
* Ported from org.compiere.apps.ProcessCtl
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class WProcessCtl {
|
||||
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(WProcessCtl.class);
|
||||
|
||||
/**
|
||||
* Process Control
|
||||
* <code>
|
||||
* - Get Instance ID
|
||||
* - Get Parameters
|
||||
* - execute (lock - start process - unlock)
|
||||
* </code>
|
||||
* Creates a ProcessCtl instance, which calls
|
||||
* lockUI and unlockUI if parent is a ASyncProcess
|
||||
* <br>
|
||||
*
|
||||
* @param aProcess ASyncProcess & Container
|
||||
* @param WindowNo window no
|
||||
* @param pi ProcessInfo process info
|
||||
* @param trx Transaction
|
||||
*/
|
||||
public static void process (ASyncProcess aProcess, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
log.fine("WindowNo=" + WindowNo + " - " + pi);
|
||||
|
||||
MPInstance instance = null;
|
||||
try
|
||||
{
|
||||
instance = new MPInstance(Env.getCtx(), pi.getAD_Process_ID(), pi.getRecord_ID());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pi.setSummary (e.getLocalizedMessage());
|
||||
pi.setError (true);
|
||||
log.warning(pi.toString());
|
||||
}
|
||||
catch (Error e)
|
||||
{
|
||||
pi.setSummary (e.getLocalizedMessage());
|
||||
pi.setError (true);
|
||||
log.warning(pi.toString());
|
||||
}
|
||||
if (!instance.save())
|
||||
{
|
||||
pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessNoInstance"));
|
||||
pi.setError (true);
|
||||
}
|
||||
pi.setAD_PInstance_ID (instance.getAD_PInstance_ID());
|
||||
|
||||
// Get Parameters (Dialog)
|
||||
ProcessModalDialog para = new ProcessModalDialog(aProcess, WindowNo, pi, false);
|
||||
if (para.isValid())
|
||||
{
|
||||
para.setWidth("500px");
|
||||
para.setVisible(true);
|
||||
para.setPosition("center");
|
||||
para.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
|
||||
AEnv.showWindow(para);
|
||||
}
|
||||
} // execute
|
||||
|
||||
/**
|
||||
* Async Process - Do it all.
|
||||
* <code>
|
||||
* - Get Instance ID
|
||||
* - Get Parameters
|
||||
* - execute (lock - start process - unlock)
|
||||
* </code>
|
||||
* Creates a ProcessCtl instance, which calls
|
||||
* lockUI and unlockUI if parent is a ASyncProcess
|
||||
* <br>
|
||||
* Called from ProcessDialog.actionPerformed
|
||||
*
|
||||
* @param parent ASyncProcess & Container
|
||||
* @param WindowNo window no
|
||||
* @param paraPanel Process Parameter Panel
|
||||
* @param pi ProcessInfo process info
|
||||
* @param trx Transaction
|
||||
*/
|
||||
public static void process(ASyncProcess parent, int WindowNo, IProcessParameter parameter, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
ProcessCtl.process(parent, WindowNo, parameter, pi, trx);
|
||||
}
|
||||
}
|
|
@ -22,14 +22,11 @@ import java.util.logging.Level;
|
|||
|
||||
import javax.sql.RowSet;
|
||||
|
||||
import org.adempiere.webui.component.Listbox;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.compiere.apps.ProcessCtl;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.PrintInfo;
|
||||
import org.compiere.print.AReport;
|
||||
import org.compiere.print.MPrintFormat;
|
||||
import org.compiere.print.ReportCtl;
|
||||
import org.compiere.print.ReportEngine;
|
||||
|
@ -92,13 +89,11 @@ public class WReport implements EventListener {
|
|||
|
||||
/** The Query */
|
||||
private MQuery m_query;
|
||||
/** The Popup */
|
||||
private Listbox m_listbox;
|
||||
private Menupopup m_popup;
|
||||
/** The Option List */
|
||||
private ArrayList<KeyNamePair> m_list = new ArrayList<KeyNamePair>();
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(AReport.class);
|
||||
private static CLogger log = CLogger.getCLogger(WReport.class);
|
||||
/** The parent window for locking/unlocking during process execution */
|
||||
Component parent;
|
||||
/** The parent window number */
|
||||
|
@ -213,7 +208,7 @@ public class WReport implements EventListener {
|
|||
ProcessInfo pi = new ProcessInfo ("", pf.getJasperProcess_ID());
|
||||
|
||||
// Execute Process
|
||||
ProcessCtl worker = ProcessCtl.process(null, WindowNo, pi, null);
|
||||
WProcessCtl.process(null, WindowNo, pi, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -239,5 +234,5 @@ public class WReport implements EventListener {
|
|||
Menuitem mi = (Menuitem) event.getTarget();
|
||||
launchReport(m_list.get(Integer.parseInt(mi.getValue().toString())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -376,7 +376,7 @@ public class WPaySelect extends PaySelect
|
|||
int AD_Proces_ID = 155; // C_PaySelection_CreatePayment
|
||||
|
||||
// Execute Process
|
||||
ProcessModalDialog dialog = new ProcessModalDialog(null, form.getFormName(), this, m_WindowNo,
|
||||
ProcessModalDialog dialog = new ProcessModalDialog(this, m_WindowNo,
|
||||
AD_Proces_ID, X_C_PaySelection.Table_ID, m_ps.getC_PaySelection_ID(), false);
|
||||
if (dialog.isValid()) {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue