IDEMPIERE-309 Process UI: Add ask and file download dialog support
This commit is contained in:
parent
f66d47695a
commit
59eefcc345
|
@ -11,7 +11,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.util;
|
||||
package org.adempiere.util;
|
||||
|
||||
/**
|
||||
*
|
|
@ -1,33 +0,0 @@
|
|||
package org.adempiere.util;
|
||||
|
||||
import org.compiere.process.ProcessInfo;
|
||||
|
||||
public interface IProcessMonitor {
|
||||
|
||||
/**
|
||||
* Lock User Interface.
|
||||
* Called from the Worker before processing
|
||||
* @param pi process info
|
||||
*/
|
||||
public void lockUI (ProcessInfo pi);
|
||||
|
||||
/**
|
||||
* Unlock User Interface.
|
||||
* Called from the Worker when processing is done
|
||||
* @param pi process info
|
||||
*/
|
||||
public void unlockUI (ProcessInfo pi);
|
||||
|
||||
/**
|
||||
* Is the UI locked
|
||||
* @return true, if UI is locked
|
||||
*/
|
||||
public boolean isUILocked();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
public void statusUpdate(String message);
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Heng Sin Low *
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* 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. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.compiere.process.ProcessInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public interface IProcessUI {
|
||||
|
||||
/**
|
||||
* Lock User Interface.
|
||||
* Called from the Worker before processing
|
||||
* @param pi process info
|
||||
*/
|
||||
public void lockUI (ProcessInfo pi);
|
||||
|
||||
/**
|
||||
* Unlock User Interface.
|
||||
* Called from the Worker when processing is done
|
||||
* @param pi process info
|
||||
*/
|
||||
public void unlockUI (ProcessInfo pi);
|
||||
|
||||
/**
|
||||
* Is the UI locked
|
||||
* @return true, if UI is locked
|
||||
*/
|
||||
public boolean isUILocked();
|
||||
|
||||
/**
|
||||
* Provide status feedback to user
|
||||
* @param message
|
||||
*/
|
||||
public void statusUpdate(String message);
|
||||
|
||||
/**
|
||||
* Prompt for user input.
|
||||
*
|
||||
* Example Usage in process:
|
||||
* <pre>
|
||||
* final StringBuffer answer = new StringBuffer();
|
||||
* aProcessMonitor.ask(adMessage, new Callback<String>() {
|
||||
* @Override
|
||||
* public void onCallback(String result) {
|
||||
* answer.append(result != null ? result : "-");
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* //wait for answer
|
||||
* while (answer.length() == 0) {
|
||||
* try {
|
||||
* Thread.sleep(200);
|
||||
* } catch (InterruptedException e) {}
|
||||
* }
|
||||
*
|
||||
* //process answer from user
|
||||
* ...
|
||||
* </pre>
|
||||
* @param message
|
||||
* @param callback
|
||||
*/
|
||||
public void ask(String message, Callback<String> callback);
|
||||
|
||||
/**
|
||||
* add to list of file available for download after process end
|
||||
* @param file
|
||||
*/
|
||||
public void download(File file);
|
||||
}
|
|
@ -144,7 +144,7 @@ public final class ProcessUtil {
|
|||
* @param managedTrx false if trx is managed by caller
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean startJavaProcess(Properties ctx, ProcessInfo pi, Trx trx, boolean managedTrx, IProcessMonitor processMonitor) {
|
||||
public static boolean startJavaProcess(Properties ctx, ProcessInfo pi, Trx trx, boolean managedTrx, IProcessUI processMonitor) {
|
||||
String className = pi.getClassName();
|
||||
if (className == null) {
|
||||
MProcess proc = new MProcess(ctx, pi.getAD_Process_ID(), trx.getTrxName());
|
||||
|
@ -208,14 +208,14 @@ public final class ProcessUtil {
|
|||
boolean success = false;
|
||||
try
|
||||
{
|
||||
process.setProcessMonitor(processMonitor);
|
||||
process.setProcessUI(processMonitor);
|
||||
success = process.startProcess(ctx, pi, trx);
|
||||
if (success && trx != null && managedTrx)
|
||||
{
|
||||
trx.commit(true);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Throwable e)
|
||||
{
|
||||
pi.setSummary (Msg.getMsg(Env.getCtx(), "ProcessError") + " " + e.getLocalizedMessage(), true);
|
||||
log.log(Level.SEVERE, pi.getClassName(), e);
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.compiere.process;
|
|||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.util.Trx;
|
||||
|
||||
/**
|
||||
|
@ -49,6 +49,6 @@ public interface ProcessCall
|
|||
/**
|
||||
* @param processMonitor
|
||||
*/
|
||||
public void setProcessMonitor(IProcessMonitor processMonitor);
|
||||
public void setProcessUI(IProcessUI processUI);
|
||||
|
||||
} // ProcessCall
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.sql.Timestamp;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.model.MPInstance;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
|
@ -52,7 +52,7 @@ import org.compiere.util.Trx;
|
|||
public abstract class SvrProcess implements ProcessCall
|
||||
{
|
||||
public static final String PROCESS_INFO_CTX_KEY = "ProcessInfo";
|
||||
public static final String PROCESS_MONITOR_CTX_KEY = "ProcessMonitor";
|
||||
public static final String PROCESS_UI_CTX_KEY = "ProcessUI";
|
||||
|
||||
/**
|
||||
* Server Process.
|
||||
|
@ -75,7 +75,7 @@ public abstract class SvrProcess implements ProcessCall
|
|||
private PO m_lockedObject = null;
|
||||
/** Process Main transaction */
|
||||
private Trx m_trx;
|
||||
private IProcessMonitor processMonitor;
|
||||
protected IProcessUI processUI;
|
||||
|
||||
/** Common Error Message */
|
||||
protected static String MSG_SaveErrorRowNotFound = "@SaveErrorRowNotFound@";
|
||||
|
@ -111,14 +111,14 @@ public abstract class SvrProcess implements ProcessCall
|
|||
try
|
||||
{
|
||||
m_ctx.put(PROCESS_INFO_CTX_KEY, m_pi);
|
||||
if (processMonitor != null)
|
||||
m_ctx.put(PROCESS_MONITOR_CTX_KEY, processMonitor);
|
||||
if (processUI != null)
|
||||
m_ctx.put(PROCESS_UI_CTX_KEY, processUI);
|
||||
success = process();
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_ctx.remove(PROCESS_INFO_CTX_KEY);
|
||||
m_ctx.remove(PROCESS_MONITOR_CTX_KEY);
|
||||
m_ctx.remove(PROCESS_UI_CTX_KEY);
|
||||
if (localTrx)
|
||||
{
|
||||
if (success)
|
||||
|
@ -536,9 +536,9 @@ public abstract class SvrProcess implements ProcessCall
|
|||
} // get_TrxName
|
||||
|
||||
@Override
|
||||
public void setProcessMonitor(IProcessMonitor monitor)
|
||||
public void setProcessUI(IProcessUI monitor)
|
||||
{
|
||||
processMonitor = monitor;
|
||||
processUI = monitor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -547,9 +547,9 @@ public abstract class SvrProcess implements ProcessCall
|
|||
*/
|
||||
protected void statusUpdate(String message)
|
||||
{
|
||||
if (processMonitor != null)
|
||||
if (processUI != null)
|
||||
{
|
||||
processMonitor.statusUpdate(message);
|
||||
processUI.statusUpdate(message);
|
||||
}
|
||||
}
|
||||
} // SvrProcess
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.util;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +38,7 @@ import org.compiere.process.ProcessInfo;
|
|||
* @version $Id: ASyncProcess.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
|
||||
* @deprecated
|
||||
*/
|
||||
public interface ASyncProcess extends IProcessMonitor
|
||||
public interface ASyncProcess extends IProcessUI
|
||||
{
|
||||
/**
|
||||
* Method to be executed async.
|
||||
|
|
|
@ -97,17 +97,10 @@ public class PackOutProcess extends SvrProcess
|
|||
|
||||
if (packageExp.getAD_Package_Exp_ID() == p_PackOut_ID){
|
||||
//Create the package documentation
|
||||
packoutDirectory = packageExp.getFile_Directory();
|
||||
if (packoutDirectory == null || packoutDirectory.trim().length() == 0) {
|
||||
packoutDirectory = Adempiere.getAdempiereHome().trim();
|
||||
if (!packoutDirectory.endsWith("/") && !packoutDirectory.endsWith("\\"))
|
||||
packoutDirectory+= File.separator;
|
||||
packoutDirectory = packoutDirectory + "packout" + File.separator;
|
||||
} else {
|
||||
packoutDirectory = packoutDirectory.trim();
|
||||
if (!packoutDirectory.endsWith("/") && !packoutDirectory.endsWith("\\"))
|
||||
packoutDirectory+= File.separator;
|
||||
}
|
||||
packoutDirectory = Adempiere.getAdempiereHome().trim();
|
||||
if (!packoutDirectory.endsWith("/") && !packoutDirectory.endsWith("\\"))
|
||||
packoutDirectory+= File.separator;
|
||||
packoutDirectory = packoutDirectory + "packout" + File.separator;
|
||||
|
||||
//create packout folder if needed
|
||||
File packoutDirectoryFile = new File(packoutDirectory);
|
||||
|
@ -152,6 +145,9 @@ public class PackOutProcess extends SvrProcess
|
|||
throw e;
|
||||
}
|
||||
|
||||
if (processUI != null)
|
||||
processUI.download(new File(exportFile));
|
||||
|
||||
return "Exported="+processedCount + " File=" + exportFile;
|
||||
} // doIt
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ import net.sf.jasperreports.engine.util.JRSwapFile;
|
|||
import org.adempiere.base.Service;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.model.MAttachment;
|
||||
import org.compiere.model.MAttachmentEntry;
|
||||
import org.compiere.model.MProcess;
|
||||
|
@ -120,7 +120,8 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
|||
|
||||
private ProcessInfo processInfo;
|
||||
private MAttachment attachment;
|
||||
private IProcessMonitor m_processMonitor;
|
||||
@SuppressWarnings("unused")
|
||||
private IProcessUI m_processUI;
|
||||
|
||||
/**
|
||||
* @author rlemeill
|
||||
|
@ -1164,8 +1165,8 @@ public class ReportStarter implements ProcessCall, ClientProcess
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setProcessMonitor(IProcessMonitor processMonitor) {
|
||||
m_processMonitor = processMonitor;
|
||||
public void setProcessUI(IProcessUI processUI) {
|
||||
m_processUI = processUI;
|
||||
}
|
||||
|
||||
}
|
|
@ -29,6 +29,7 @@ import java.awt.event.ActionEvent;
|
|||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -59,7 +60,8 @@ import javax.swing.SwingUtilities;
|
|||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.apps.form.FormFrame;
|
||||
import org.compiere.apps.search.Find;
|
||||
import org.compiere.grid.APanelTab;
|
||||
|
@ -144,7 +146,7 @@ import org.compiere.util.Util;
|
|||
* @sponsor www.metas.de
|
||||
*/
|
||||
public final class APanel extends CPanel
|
||||
implements DataStatusListener, ChangeListener, ActionListener, IProcessMonitor, SystemIDs
|
||||
implements DataStatusListener, ChangeListener, ActionListener, IProcessUI, SystemIDs
|
||||
{
|
||||
/**
|
||||
*
|
||||
|
@ -2968,4 +2970,16 @@ public final class APanel extends CPanel
|
|||
|
||||
} // updateToolBarAndMenuWithRestriction
|
||||
|
||||
@Override
|
||||
public void ask(String message, Callback<String> callback) {
|
||||
boolean b = ADialog.ask(m_curWindowNo, this, message);
|
||||
if (callback != null) {
|
||||
callback.onCallback(b ? "OK" : "CANCEL");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(File file) {
|
||||
}
|
||||
|
||||
} // APanel
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.compiere.apps;
|
|||
|
||||
import java.awt.Container;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.model.MPInstance;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.CLogger;
|
||||
|
@ -34,7 +34,7 @@ public class ClientProcessCtrl {
|
|||
* @param trx Transaction
|
||||
* @return worker started ProcessCtl instance or null for workflow
|
||||
*/
|
||||
public static ProcessCtl process (IProcessMonitor parent, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
public static ProcessCtl process (IProcessUI parent, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
log.fine("WindowNo=" + WindowNo + " - " + pi);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.awt.Container;
|
|||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.model.MPInstance;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.CLogger;
|
||||
|
@ -64,7 +64,7 @@ public class ProcessCtl extends AbstractProcessCtl
|
|||
* @param trx Transaction
|
||||
* @return worker started ProcessCtl instance or null for workflow
|
||||
*/
|
||||
public static ProcessCtl process (IProcessMonitor parent, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
public static ProcessCtl process (IProcessUI parent, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
log.fine("WindowNo=" + WindowNo + " - " + pi);
|
||||
|
||||
|
@ -142,7 +142,7 @@ public class ProcessCtl extends AbstractProcessCtl
|
|||
* @param trx Transaction
|
||||
* @return worker started ProcessCtl instance or null for workflow
|
||||
*/
|
||||
public static ProcessCtl process(IProcessMonitor parent, int WindowNo, IProcessParameter parameter, ProcessInfo pi, Trx trx)
|
||||
public static ProcessCtl process(IProcessUI parent, int WindowNo, IProcessParameter parameter, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
log.fine("WindowNo=" + WindowNo + " - " + pi);
|
||||
|
||||
|
@ -206,7 +206,7 @@ public class ProcessCtl extends AbstractProcessCtl
|
|||
* @param trx Transaction
|
||||
* Created in process(), VInvoiceGen.generateInvoices
|
||||
*/
|
||||
public ProcessCtl (IProcessMonitor parent, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
public ProcessCtl (IProcessUI parent, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
super(parent, WindowNo, pi, trx);
|
||||
} // ProcessCtl
|
||||
|
@ -317,14 +317,14 @@ public class ProcessCtl extends AbstractProcessCtl
|
|||
abstract class ProcessUpdateRunnable implements Runnable
|
||||
{
|
||||
protected ProcessInfo pi = null;
|
||||
protected IProcessMonitor parent = null;
|
||||
protected IProcessUI parent = null;
|
||||
|
||||
public void setProcessInfo(ProcessInfo pi)
|
||||
{
|
||||
this.pi = pi;
|
||||
}
|
||||
|
||||
public void setParent(IProcessMonitor parent)
|
||||
public void setParent(IProcessUI parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.awt.FlowLayout;
|
|||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
@ -36,7 +37,8 @@ import javax.swing.JSeparator;
|
|||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.model.SystemIDs;
|
||||
import org.compiere.print.ReportCtl;
|
||||
import org.compiere.print.ReportEngine;
|
||||
|
@ -68,7 +70,7 @@ import org.compiere.util.Msg;
|
|||
* <li>BF [ 1963128 ] Running a process w/o trl should display an error
|
||||
*/
|
||||
public class ProcessDialog extends CFrame
|
||||
implements ActionListener, IProcessMonitor, SystemIDs
|
||||
implements ActionListener, IProcessUI, SystemIDs
|
||||
{
|
||||
/**
|
||||
*
|
||||
|
@ -523,4 +525,18 @@ public class ProcessDialog extends CFrame
|
|||
message.setText(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ask(String message, Callback<String> callback) {
|
||||
boolean b = ADialog.ask(m_WindowNo, this, message);
|
||||
if (callback != null) {
|
||||
callback.onCallback(b ? "OK" : "CANCEL");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(File file) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
} // ProcessDialog
|
||||
|
|
|
@ -32,7 +32,7 @@ import javax.swing.JScrollPane;
|
|||
import javax.swing.JSeparator;
|
||||
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.swing.CButton;
|
||||
import org.compiere.swing.CDialog;
|
||||
|
@ -76,13 +76,13 @@ public class ProcessModalDialog extends CDialog
|
|||
* @param autoStart
|
||||
*/
|
||||
public ProcessModalDialog (Properties ctx, Frame parent, String title,
|
||||
IProcessMonitor aProcess, int WindowNo, int AD_Process_ID,
|
||||
IProcessUI aProcess, int WindowNo, int AD_Process_ID,
|
||||
int tableId, int recordId, boolean autoStart)
|
||||
{
|
||||
super(parent, title, true);
|
||||
log.info("Process=" + AD_Process_ID );
|
||||
m_ctx = ctx;
|
||||
m_processMonitor = aProcess;
|
||||
m_processUI = aProcess;
|
||||
m_WindowNo = WindowNo;
|
||||
m_AD_Process_ID = AD_Process_ID;
|
||||
m_tableId = tableId;
|
||||
|
@ -99,7 +99,7 @@ public class ProcessModalDialog extends CDialog
|
|||
}
|
||||
} // ProcessDialog
|
||||
|
||||
private IProcessMonitor m_processMonitor;
|
||||
private IProcessUI m_processUI;
|
||||
private int m_WindowNo;
|
||||
private Properties m_ctx;
|
||||
private int m_tableId;
|
||||
|
@ -333,7 +333,7 @@ public class ProcessModalDialog extends CDialog
|
|||
{
|
||||
if (e.getSource() == bOK)
|
||||
{
|
||||
ProcessCtl.process(m_processMonitor, m_WindowNo, parameterPanel, m_pi, null);
|
||||
ProcessCtl.process(m_processUI, m_WindowNo, parameterPanel, m_pi, null);
|
||||
dispose();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.awt.Cursor;
|
|||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
@ -28,7 +29,8 @@ import javax.swing.event.TableModelEvent;
|
|||
import javax.swing.event.TableModelListener;
|
||||
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.apps.ADialog;
|
||||
import org.compiere.apps.ADialogDialog;
|
||||
import org.compiere.apps.AEnv;
|
||||
|
@ -58,7 +60,7 @@ import org.compiere.util.Msg;
|
|||
* Generate custom form panel
|
||||
*
|
||||
*/
|
||||
public class VGenPanel extends CPanel implements ActionListener, ChangeListener, TableModelListener, IProcessMonitor
|
||||
public class VGenPanel extends CPanel implements ActionListener, ChangeListener, TableModelListener, IProcessUI
|
||||
{
|
||||
/**
|
||||
*
|
||||
|
@ -385,4 +387,18 @@ public class VGenPanel extends CPanel implements ActionListener, ChangeListener,
|
|||
public void statusUpdate(String message) {
|
||||
statusBar.setStatusLine(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ask(String message, Callback<String> callback) {
|
||||
boolean b = ADialog.ask(m_WindowNo, this, message);
|
||||
if (callback != null) {
|
||||
callback.onCallback(b ? "OK" : "CANCEL");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(File file) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ import java.awt.GridBagLayout;
|
|||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
@ -35,7 +36,8 @@ import javax.swing.JScrollPane;
|
|||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.apps.ADialog;
|
||||
import org.compiere.apps.AEnv;
|
||||
import org.compiere.apps.ConfirmPanel;
|
||||
|
@ -66,7 +68,7 @@ import org.compiere.util.ValueNamePair;
|
|||
* @author Jorg Janke
|
||||
* @version $Id: VPaySelect.java,v 1.2 2008/07/11 08:20:12 cruiz Exp $
|
||||
*/
|
||||
public class VPaySelect extends PaySelect implements FormPanel, ActionListener, TableModelListener, IProcessMonitor, SystemIDs
|
||||
public class VPaySelect extends PaySelect implements FormPanel, ActionListener, TableModelListener, IProcessUI, SystemIDs
|
||||
{
|
||||
/** @todo withholding */
|
||||
private CPanel panel = new CPanel();
|
||||
|
@ -444,4 +446,18 @@ public class VPaySelect extends PaySelect implements FormPanel, ActionListener,
|
|||
public void statusUpdate(String message) {
|
||||
dataStatus.setText(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ask(String message, Callback<String> callback) {
|
||||
boolean b = ADialog.ask(m_WindowNo, null, message);
|
||||
if (callback != null) {
|
||||
callback.onCallback(b ? "OK" : "CANCEL");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(File file) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
} // VPaySelect
|
||||
|
|
|
@ -27,7 +27,7 @@ import javax.sql.RowSet;
|
|||
import javax.swing.JComponent;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.apps.ADialog;
|
||||
import org.compiere.apps.ClientProcessCtrl;
|
||||
import org.compiere.apps.ProcessCtl;
|
||||
|
@ -73,7 +73,7 @@ public class AReport implements ActionListener
|
|||
* @param parent The invoking parent window
|
||||
* @param WindowNo The invoking parent window number
|
||||
*/
|
||||
public AReport (int AD_Table_ID, JComponent invoker, MQuery query, IProcessMonitor parent, int WindowNo)
|
||||
public AReport (int AD_Table_ID, JComponent invoker, MQuery query, IProcessUI parent, int WindowNo)
|
||||
{
|
||||
log.config("AD_Table_ID=" + AD_Table_ID + " " + query);
|
||||
if (!MRole.getDefault().isCanReport(AD_Table_ID))
|
||||
|
@ -100,7 +100,7 @@ public class AReport implements ActionListener
|
|||
* @param whereExtended The filtering where clause
|
||||
* @param WindowNo The invoking parent window number
|
||||
*/
|
||||
public AReport (int AD_Table_ID, JComponent invoker, MQuery query, IProcessMonitor parent, int WindowNo, String whereExtended)
|
||||
public AReport (int AD_Table_ID, JComponent invoker, MQuery query, IProcessUI parent, int WindowNo, String whereExtended)
|
||||
{
|
||||
log.config("AD_Table_ID=" + AD_Table_ID + " " + query);
|
||||
if (!MRole.getDefault().isCanReport(AD_Table_ID))
|
||||
|
@ -129,7 +129,7 @@ public class AReport implements ActionListener
|
|||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(AReport.class);
|
||||
/** The parent window for locking/unlocking during process execution */
|
||||
IProcessMonitor parent;
|
||||
IProcessUI parent;
|
||||
/** The filter to apply to this report */
|
||||
String m_whereExtended;
|
||||
/** The parent window number */
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.awt.event.ActionEvent;
|
|||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.VetoableChangeListener;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -38,7 +39,8 @@ import javax.swing.event.TableModelEvent;
|
|||
import javax.swing.event.TableModelListener;
|
||||
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.apps.ADialog;
|
||||
import org.compiere.apps.ADialogDialog;
|
||||
import org.compiere.apps.AEnv;
|
||||
|
@ -84,7 +86,7 @@ import org.compiere.util.Trx;
|
|||
*/
|
||||
public class VInOutInvoiceGen extends CPanel
|
||||
implements FormPanel, ActionListener, VetoableChangeListener,
|
||||
ChangeListener, TableModelListener, IProcessMonitor, SystemIDs
|
||||
ChangeListener, TableModelListener, IProcessUI, SystemIDs
|
||||
{
|
||||
/**
|
||||
*
|
||||
|
@ -901,4 +903,18 @@ public class VInOutInvoiceGen extends CPanel
|
|||
public void statusUpdate(String message) {
|
||||
statusBar.setStatusLine(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ask(String message, Callback<String> callback) {
|
||||
boolean b = ADialog.ask(m_WindowNo, this, message);
|
||||
if (callback != null) {
|
||||
callback.onCallback(b ? "OK" : "CANCEL");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(File file) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
} // VInOutGen
|
||||
|
|
|
@ -12,7 +12,8 @@ import java.util.Properties;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.adempiere.util.ServerContext;
|
||||
import org.adempiere.webui.AdempiereWebUI;
|
||||
import org.adempiere.webui.component.Button;
|
||||
|
@ -22,6 +23,7 @@ import org.adempiere.webui.desktop.IDesktop;
|
|||
import org.adempiere.webui.process.WProcessInfo;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.adempiere.webui.window.MultiFileDownloadDialog;
|
||||
import org.adempiere.webui.window.SimplePDFViewer;
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.model.SystemIDs;
|
||||
|
@ -81,7 +83,7 @@ import com.lowagie.text.pdf.PdfWriter;
|
|||
* @author arboleda - globalqss
|
||||
* - Implement ShowHelp option on processes and reports
|
||||
*/
|
||||
public class ProcessDialog extends Window implements EventListener<Event>, IProcessMonitor, SystemIDs
|
||||
public class ProcessDialog extends Window implements EventListener<Event>, IProcessUI, SystemIDs
|
||||
{
|
||||
/**
|
||||
* generate serial version ID
|
||||
|
@ -92,6 +94,7 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
|
|||
private Center center;
|
||||
private North north;
|
||||
|
||||
private List<File> downloadFiles;
|
||||
|
||||
/**
|
||||
* Dialog to start a process/report
|
||||
|
@ -315,6 +318,9 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
|
|||
m_pi.setPrintPreview(true);
|
||||
|
||||
this.lockUI(m_pi);
|
||||
|
||||
downloadFiles = new ArrayList<File>();
|
||||
|
||||
Clients.response(new AuEcho(this, "runProcess", null));
|
||||
}
|
||||
|
||||
|
@ -344,6 +350,12 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
|
|||
future = null;
|
||||
processDialogRunnable = null;
|
||||
unlockUI(m_pi);
|
||||
if (downloadFiles.size() > 0) {
|
||||
MultiFileDownloadDialog downloadDialog = new MultiFileDownloadDialog(downloadFiles.toArray(new File[0]));
|
||||
downloadDialog.setPage(this.getPage());
|
||||
downloadDialog.setTitle(m_pi.getTitle());
|
||||
Events.postEvent(downloadDialog, new Event(MultiFileDownloadDialog.ON_SHOW));
|
||||
}
|
||||
}
|
||||
|
||||
private void onStatusUpdate(Event event) {
|
||||
|
@ -664,4 +676,19 @@ public class ProcessDialog extends Window implements EventListener<Event>, IProc
|
|||
public void statusUpdate(String message) {
|
||||
Executions.schedule(getDesktop(), this, new Event(ON_STATUS_UPDATE, this, message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ask(final String message, final Callback<String> callback) {
|
||||
Executions.schedule(getDesktop(), new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
FDialog.ask(m_WindowNo, null, message, callback);
|
||||
}
|
||||
}, new Event("onAsk"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(File file) {
|
||||
downloadFiles.add(file);
|
||||
}
|
||||
} // ProcessDialog
|
||||
|
|
|
@ -16,14 +16,18 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.apps;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.adempiere.util.ServerContext;
|
||||
import org.adempiere.webui.AdempiereWebUI;
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
|
@ -32,6 +36,8 @@ import org.adempiere.webui.component.Panel;
|
|||
import org.adempiere.webui.component.VerticalBox;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.event.DialogEvents;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.adempiere.webui.window.MultiFileDownloadDialog;
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.CLogger;
|
||||
|
@ -61,7 +67,7 @@ import org.zkoss.zul.Html;
|
|||
* @author arboleda - globalqss
|
||||
* - Implement ShowHelp option on processes and reports
|
||||
*/
|
||||
public class ProcessModalDialog extends Window implements EventListener<Event>, IProcessMonitor, DialogEvents
|
||||
public class ProcessModalDialog extends Window implements EventListener<Event>, IProcessUI, DialogEvents
|
||||
{
|
||||
private static final String ON_STATUS_UPDATE = "onStatusUpdate";
|
||||
private static final String ON_COMPLETE = "onComplete";
|
||||
|
@ -73,20 +79,37 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
|
|||
private boolean m_autoStart;
|
||||
private VerticalBox dialogBody;
|
||||
|
||||
private List<File> downloadFiles;
|
||||
|
||||
/**
|
||||
* @param aProcess
|
||||
* @param WindowNo
|
||||
* @param pi
|
||||
* @param autoStart
|
||||
*/
|
||||
public ProcessModalDialog(IProcessMonitor aProcess, int WindowNo, ProcessInfo pi, boolean autoStart)
|
||||
public ProcessModalDialog(int WindowNo, ProcessInfo pi, boolean autoStart)
|
||||
{
|
||||
this(null, WindowNo, pi, autoStart);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aProcess
|
||||
* @param WindowNo
|
||||
* @param pi
|
||||
* @param autoStart
|
||||
*/
|
||||
public ProcessModalDialog(EventListener<Event> listener, int WindowNo, ProcessInfo pi, boolean autoStart)
|
||||
{
|
||||
m_ctx = Env.getCtx();
|
||||
m_processMonitor = aProcess;
|
||||
m_WindowNo = WindowNo;
|
||||
m_pi = pi;
|
||||
m_autoStart = autoStart;
|
||||
|
||||
if (listener != null)
|
||||
{
|
||||
addEventListener(ON_MODAL_CLOSE, listener);
|
||||
}
|
||||
|
||||
log.info("Process=" + pi.getAD_Process_ID());
|
||||
try
|
||||
{
|
||||
|
@ -99,19 +122,22 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
|
|||
}
|
||||
}
|
||||
|
||||
public ProcessModalDialog (int WindowNo, int AD_Process_ID, int tableId, int recordId, boolean autoStart)
|
||||
{
|
||||
this(null, WindowNo, AD_Process_ID, tableId, recordId, autoStart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialog to start a process/report
|
||||
* @param ctx
|
||||
* @param aProcess
|
||||
* @param WindowNo
|
||||
* @param AD_Process_ID
|
||||
* @param tableId
|
||||
* @param recordId
|
||||
* @param autoStart
|
||||
*/
|
||||
public ProcessModalDialog ( IProcessMonitor aProcess, int WindowNo, int AD_Process_ID, int tableId, int recordId, boolean autoStart)
|
||||
public ProcessModalDialog (EventListener<Event> listener, int WindowNo, int AD_Process_ID, int tableId, int recordId, boolean autoStart)
|
||||
{
|
||||
this(aProcess, WindowNo, new ProcessInfo("", AD_Process_ID, tableId, recordId), autoStart);
|
||||
this(listener, WindowNo, new ProcessInfo("", AD_Process_ID, tableId, recordId), autoStart);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,7 +145,6 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
|
|||
* @param ctx
|
||||
* @param parent not used
|
||||
* @param title not used
|
||||
* @param aProcess
|
||||
* @param WindowNo
|
||||
* @param AD_Process_ID
|
||||
* @param tableId
|
||||
|
@ -128,10 +153,10 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
|
|||
* @deprecated
|
||||
*/
|
||||
public ProcessModalDialog (Window parent, String title,
|
||||
IProcessMonitor aProcess, int WindowNo, int AD_Process_ID,
|
||||
int WindowNo, int AD_Process_ID,
|
||||
int tableId, int recordId, boolean autoStart)
|
||||
{
|
||||
this(aProcess, WindowNo, AD_Process_ID, tableId, recordId, autoStart);
|
||||
this(WindowNo, AD_Process_ID, tableId, recordId, autoStart);
|
||||
} // ProcessDialog
|
||||
|
||||
private void initComponents() {
|
||||
|
@ -145,8 +170,6 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
|
|||
dialogBody.appendChild(div);
|
||||
centerPanel = new Panel();
|
||||
dialogBody.appendChild(centerPanel);
|
||||
// div = new Div();
|
||||
// div.setStyle("text-align: right");
|
||||
Hbox hbox = new Hbox();
|
||||
hbox.setWidth("100%");
|
||||
hbox.setStyle("margin-top: 10px");
|
||||
|
@ -163,13 +186,11 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
|
|||
|
||||
hbox.appendChild(btn);
|
||||
hbox.setPack("end");
|
||||
// div.appendChild(hbox);
|
||||
dialogBody.appendChild(hbox);
|
||||
this.appendChild(dialogBody);
|
||||
|
||||
}
|
||||
|
||||
private IProcessMonitor m_processMonitor;
|
||||
private int m_WindowNo;
|
||||
private Properties m_ctx;
|
||||
private String m_Name = null;
|
||||
|
@ -326,13 +347,10 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
|
|||
{
|
||||
m_pi.setPrintPreview(true);
|
||||
|
||||
if (m_processMonitor != null) {
|
||||
m_processMonitor.lockUI(m_pi);
|
||||
Clients.clearBusy();
|
||||
}
|
||||
|
||||
lockUI(m_pi);
|
||||
|
||||
downloadFiles = new ArrayList<File>();
|
||||
|
||||
//use echo, otherwise lock ui wouldn't work
|
||||
Clients.response(new AuEcho(this, "runProcess", null));
|
||||
}
|
||||
|
@ -416,11 +434,14 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
|
|||
Env.getCtx().putAll(processDialogRunnable.getProperties());
|
||||
future = null;
|
||||
processDialogRunnable = null;
|
||||
dispose();
|
||||
if (m_processMonitor != null) {
|
||||
m_processMonitor.unlockUI(m_pi);
|
||||
}
|
||||
unlockUI(m_pi);
|
||||
if (downloadFiles.size() > 0) {
|
||||
MultiFileDownloadDialog downloadDialog = new MultiFileDownloadDialog(downloadFiles.toArray(new File[0]));
|
||||
downloadDialog.setPage(this.getPage());
|
||||
downloadDialog.setTitle(m_pi.getTitle());
|
||||
Events.postEvent(downloadDialog, new Event(MultiFileDownloadDialog.ON_SHOW));
|
||||
}
|
||||
dispose();
|
||||
Events.sendEvent(this, new Event(ON_MODAL_CLOSE, this, null));
|
||||
}
|
||||
|
||||
|
@ -482,4 +503,19 @@ public class ProcessModalDialog extends Window implements EventListener<Event>,
|
|||
return properties;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ask(final String message, final Callback<String> callback) {
|
||||
Executions.schedule(getDesktop(), new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
FDialog.ask(m_WindowNo, null, message, callback);
|
||||
}
|
||||
}, new Event("onAsk"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(File file) {
|
||||
downloadFiles.add(file);
|
||||
}
|
||||
} // ProcessDialog
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.apps;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.compiere.apps.AbstractProcessCtl;
|
||||
import org.compiere.apps.IProcessParameter;
|
||||
|
@ -48,12 +48,11 @@ public class WProcessCtl extends AbstractProcessCtl {
|
|||
* lockUI and unlockUI if parent is a ASyncProcess
|
||||
* <br>
|
||||
*
|
||||
* @param aProcessMonitor ASyncProcess & Container
|
||||
* @param WindowNo window no
|
||||
* @param pi ProcessInfo process info
|
||||
* @param trx Transaction
|
||||
*/
|
||||
public static void process (IProcessMonitor aProcessMonitor, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
public static void process (int WindowNo, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
log.fine("WindowNo=" + WindowNo + " - " + pi);
|
||||
|
||||
|
@ -82,7 +81,7 @@ public class WProcessCtl extends AbstractProcessCtl {
|
|||
pi.setAD_PInstance_ID (instance.getAD_PInstance_ID());
|
||||
|
||||
// Get Parameters (Dialog)
|
||||
ProcessModalDialog para = new ProcessModalDialog(aProcessMonitor, WindowNo, pi, false);
|
||||
ProcessModalDialog para = new ProcessModalDialog(WindowNo, pi, false);
|
||||
if (para.isValid())
|
||||
{
|
||||
para.setWidth("500px");
|
||||
|
@ -105,13 +104,13 @@ public class WProcessCtl extends AbstractProcessCtl {
|
|||
* <br>
|
||||
* Called from ProcessDialog.actionPerformed
|
||||
*
|
||||
* @param aProcessMonitor ASyncProcess & Container
|
||||
* @param aProcessUI ASyncProcess & Container
|
||||
* @param WindowNo window no
|
||||
* @param paraPanel Process Parameter Panel
|
||||
* @param pi ProcessInfo process info
|
||||
* @param trx Transaction
|
||||
*/
|
||||
public static void process(IProcessMonitor aProcessMonitor, int WindowNo, IProcessParameter parameter, ProcessInfo pi, Trx trx)
|
||||
public static void process(IProcessUI aProcessUI, int WindowNo, IProcessParameter parameter, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
log.fine("WindowNo=" + WindowNo + " - " + pi);
|
||||
|
||||
|
@ -153,7 +152,7 @@ public class WProcessCtl extends AbstractProcessCtl {
|
|||
}
|
||||
|
||||
// execute
|
||||
WProcessCtl worker = new WProcessCtl(aProcessMonitor, WindowNo, pi, trx);
|
||||
WProcessCtl worker = new WProcessCtl(aProcessUI, WindowNo, pi, trx);
|
||||
worker.run();
|
||||
}
|
||||
|
||||
|
@ -163,9 +162,9 @@ public class WProcessCtl extends AbstractProcessCtl {
|
|||
* @param pi
|
||||
* @param trx
|
||||
*/
|
||||
public WProcessCtl(IProcessMonitor aProcessMonitor, int WindowNo, ProcessInfo pi,
|
||||
public WProcessCtl(IProcessUI aProcessUI, int WindowNo, ProcessInfo pi,
|
||||
Trx trx) {
|
||||
super(aProcessMonitor, WindowNo, pi, trx);
|
||||
super(aProcessUI, WindowNo, pi, trx);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.zkoss.zul.Menupopup;
|
|||
* @author Low Heng Sin
|
||||
*
|
||||
*/
|
||||
public class WReport implements EventListener {
|
||||
public class WReport implements EventListener<Event> {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -227,7 +227,7 @@ public class WReport implements EventListener {
|
|||
ProcessInfo pi = new ProcessInfo ("", pf.getJasperProcess_ID(), pf.getAD_Table_ID(), Record_ID);
|
||||
|
||||
// Execute Process
|
||||
WProcessCtl.process(null, WindowNo, pi, null);
|
||||
WProcessCtl.process(WindowNo, pi, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -18,11 +18,13 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.apps.form;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.adempiere.webui.apps.ProcessModalDialog;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.Checkbox;
|
||||
|
@ -52,6 +54,7 @@ import org.compiere.util.Env;
|
|||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.ValueNamePair;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.SuspendNotAllowedException;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
|
@ -73,15 +76,10 @@ import org.zkoss.zul.Space;
|
|||
* @version $Id: VPaySelect.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $
|
||||
*/
|
||||
public class WPaySelect extends PaySelect
|
||||
implements IFormController, EventListener, WTableModelListener, IProcessMonitor, SystemIDs
|
||||
implements IFormController, EventListener<Event>, WTableModelListener, IProcessUI, SystemIDs
|
||||
{
|
||||
/** @todo withholding */
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6031404894392912610L;
|
||||
|
||||
private CustomForm form = new CustomForm();
|
||||
|
||||
//
|
||||
|
@ -447,4 +445,20 @@ public class WPaySelect extends PaySelect
|
|||
@Override
|
||||
public void statusUpdate(String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ask(final String message, final Callback<String> callback) {
|
||||
Executions.schedule(form.getDesktop(), new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
FDialog.ask(m_WindowNo, null, message, callback);
|
||||
}
|
||||
}, new Event("onAsk"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(File file) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
} // VPaySelect
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Heng Sin Low *
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* 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. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.component;
|
||||
|
||||
|
||||
import org.zkoss.util.media.AMedia;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zul.A;
|
||||
import org.zkoss.zul.Filedownload;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class DynamicMediaLink extends A {
|
||||
|
||||
/**
|
||||
* generated serial id
|
||||
*/
|
||||
private static final long serialVersionUID = 5017833977652241179L;
|
||||
|
||||
private AMedia media;
|
||||
|
||||
public DynamicMediaLink() {
|
||||
super();
|
||||
this.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Filedownload.save(media);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public DynamicMediaLink(String label, String image) {
|
||||
super(label, image);
|
||||
}
|
||||
|
||||
public DynamicMediaLink(String label) {
|
||||
super(label);
|
||||
}
|
||||
|
||||
public void setMedia(AMedia media) {
|
||||
this.media = media;
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ package org.adempiere.webui.component;
|
|||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -39,7 +40,7 @@ import org.zkoss.zul.Separator;
|
|||
* @date Jul 31, 2007
|
||||
*/
|
||||
|
||||
public class Messagebox extends Window implements EventListener
|
||||
public class Messagebox extends Window implements EventListener<Event>
|
||||
{
|
||||
/**
|
||||
* generated serial version ID
|
||||
|
@ -62,6 +63,8 @@ public class Messagebox extends Window implements EventListener
|
|||
private Image img = new Image();
|
||||
|
||||
private int returnValue;
|
||||
private Callback<String> callback;
|
||||
private String callbackValue;
|
||||
|
||||
/** A OK button. */
|
||||
public static final int OK = 0x0001;
|
||||
|
@ -192,9 +195,15 @@ public class Messagebox extends Window implements EventListener
|
|||
}
|
||||
|
||||
public int show(String message, String title, int buttons, String icon)
|
||||
{
|
||||
return show(message, title, buttons, icon, null);
|
||||
}
|
||||
|
||||
public int show(String message, String title, int buttons, String icon, Callback<String> callback)
|
||||
{
|
||||
this.msg = message;
|
||||
this.imgSrc = icon;
|
||||
this.callback = callback;
|
||||
|
||||
btnOk.setVisible(false);
|
||||
btnCancel.setVisible(false);
|
||||
|
@ -243,10 +252,15 @@ public class Messagebox extends Window implements EventListener
|
|||
}
|
||||
|
||||
public static int showDialog(String message, String title, int buttons, String icon) throws InterruptedException
|
||||
{
|
||||
return showDialog(message, title, buttons, icon, null);
|
||||
}
|
||||
|
||||
public static int showDialog(String message, String title, int buttons, String icon, Callback<String> callback) throws InterruptedException
|
||||
{
|
||||
Messagebox msg = new Messagebox();
|
||||
|
||||
return msg.show(message, title, buttons, icon);
|
||||
return msg.show(message, title, buttons, icon, callback);
|
||||
}
|
||||
|
||||
public void onEvent(Event event) throws Exception
|
||||
|
@ -254,35 +268,53 @@ public class Messagebox extends Window implements EventListener
|
|||
if (event == null)
|
||||
return;
|
||||
|
||||
callbackValue = null;
|
||||
|
||||
if (event.getTarget() == btnOk)
|
||||
{
|
||||
returnValue = OK;
|
||||
callbackValue = "OK";
|
||||
}
|
||||
else if (event.getTarget() == btnCancel)
|
||||
{
|
||||
returnValue = CANCEL;
|
||||
callbackValue = "CANCEL";
|
||||
}
|
||||
else if (event.getTarget() == btnYes)
|
||||
{
|
||||
returnValue = YES;
|
||||
callbackValue = "YES";
|
||||
}
|
||||
else if (event.getTarget() == btnNo)
|
||||
{
|
||||
returnValue = NO;
|
||||
callbackValue = "NO";
|
||||
}
|
||||
else if (event.getTarget() == btnAbort)
|
||||
{
|
||||
returnValue = ABORT;
|
||||
callbackValue = "ABORT";
|
||||
}
|
||||
else if (event.getTarget() == btnRetry)
|
||||
{
|
||||
returnValue = RETRY;
|
||||
callbackValue = "RETRY";
|
||||
}
|
||||
else if (event.getTarget() == btnIgnore)
|
||||
{
|
||||
returnValue = IGNORE;
|
||||
callbackValue = "IGNORE";
|
||||
}
|
||||
|
||||
this.detach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
super.detach();
|
||||
if (callback != null)
|
||||
{
|
||||
callback.onCallback(callbackValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.TreeMap;
|
|||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.webui.WArchive;
|
||||
import org.adempiere.webui.WRequest;
|
||||
import org.adempiere.webui.WZoomAcross;
|
||||
|
@ -54,7 +54,6 @@ import org.adempiere.webui.exception.ApplicationException;
|
|||
import org.adempiere.webui.panel.action.ExportAction;
|
||||
import org.adempiere.webui.part.AbstractUIPart;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.util.Callback;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.adempiere.webui.window.FindWindow;
|
||||
import org.adempiere.webui.window.WChat;
|
||||
|
@ -90,7 +89,6 @@ import org.zkoss.zk.ui.Session;
|
|||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.util.Clients;
|
||||
import org.zkoss.zul.Button;
|
||||
import org.zkoss.zul.Div;
|
||||
import org.zkoss.zul.Hbox;
|
||||
|
@ -122,7 +120,7 @@ import org.zkoss.zul.Menupopup;
|
|||
* https://sourceforge.net/tracker/?func=detail&aid=2985892&group_id=176962&atid=955896
|
||||
*/
|
||||
public abstract class AbstractADWindowPanel extends AbstractUIPart implements ToolbarListener,
|
||||
EventListener<Event>, DataStatusListener, ActionListener, IProcessMonitor, SystemIDs
|
||||
EventListener<Event>, DataStatusListener, ActionListener, SystemIDs
|
||||
{
|
||||
private static final CLogger logger;
|
||||
|
||||
|
@ -161,8 +159,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
|
||||
private Component parent;
|
||||
|
||||
private boolean m_uiLocked;
|
||||
|
||||
private boolean m_findCancelled;
|
||||
|
||||
private int embeddedTabindex = -1;
|
||||
|
@ -996,44 +992,50 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
*/
|
||||
public void onEvent(Event event)
|
||||
{
|
||||
if (!Events.ON_SELECT.equals(event.getName()))
|
||||
return;
|
||||
|
||||
IADTabList tabList = null;
|
||||
Component target = event.getTarget();
|
||||
if (target instanceof IADTabList)
|
||||
if (Events.ON_SELECT.equals(event.getName()))
|
||||
{
|
||||
tabList = (IADTabList) target;
|
||||
IADTabList tabList = null;
|
||||
Component target = event.getTarget();
|
||||
if (target instanceof IADTabList)
|
||||
{
|
||||
tabList = (IADTabList) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
target = target.getParent();
|
||||
while(target != null)
|
||||
{
|
||||
if (target instanceof IADTabList)
|
||||
{
|
||||
tabList = (IADTabList) target;
|
||||
break;
|
||||
}
|
||||
target = target.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
if (tabList != null)
|
||||
{
|
||||
int newTabIndex = tabList.getSelectedIndex();
|
||||
|
||||
if (setActiveTab(newTabIndex))
|
||||
{
|
||||
//force sync model
|
||||
tabList.refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
//reset to original
|
||||
tabList.setSelectedIndex(curTabIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (event.getTarget() instanceof ProcessModalDialog)
|
||||
{
|
||||
target = target.getParent();
|
||||
while(target != null)
|
||||
{
|
||||
if (target instanceof IADTabList)
|
||||
{
|
||||
tabList = (IADTabList) target;
|
||||
break;
|
||||
}
|
||||
target = target.getParent();
|
||||
}
|
||||
ProcessModalDialog dialog = (ProcessModalDialog) event.getTarget();
|
||||
onModalClose(dialog.getProcessInfo());
|
||||
onRefresh(false);
|
||||
}
|
||||
|
||||
if (tabList != null)
|
||||
{
|
||||
int newTabIndex = tabList.getSelectedIndex();
|
||||
|
||||
if (setActiveTab(newTabIndex))
|
||||
{
|
||||
//force sync model
|
||||
tabList.refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
//reset to original
|
||||
tabList.setSelectedIndex(curTabIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean setActiveTab(int newTabIndex) {
|
||||
|
@ -1935,12 +1937,11 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
int table_ID = curTab.getAD_Table_ID();
|
||||
int record_ID = curTab.getRecord_ID();
|
||||
|
||||
ProcessModalDialog dialog = new ProcessModalDialog(this,getWindowNo(),
|
||||
AD_Process_ID,table_ID, record_ID, true);
|
||||
ProcessModalDialog dialog = new ProcessModalDialog(this, getWindowNo(), AD_Process_ID,table_ID, record_ID, true);
|
||||
if (dialog.isValid()) {
|
||||
dialog.setPosition("center");
|
||||
dialog.setPage(this.getComponent().getPage());
|
||||
dialog.doModal();
|
||||
dialog.setPage(this.getComponent().getPage());
|
||||
dialog.doHighlighted();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2349,8 +2350,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
}
|
||||
else
|
||||
{
|
||||
ProcessModalDialog dialog = new ProcessModalDialog(this, curWindowNo,
|
||||
wButton.getProcess_ID(), table_ID, record_ID, startWOasking);
|
||||
ProcessModalDialog dialog = new ProcessModalDialog(this, curWindowNo, wButton.getProcess_ID(), table_ID, record_ID, startWOasking);
|
||||
|
||||
if (dialog.isValid())
|
||||
{
|
||||
|
@ -2358,12 +2358,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
dialog.setVisible(true);
|
||||
dialog.setPosition("center");
|
||||
dialog.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
||||
dialog.addEventListener(DialogEvents.ON_MODAL_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
onRefresh(false);
|
||||
}
|
||||
});
|
||||
AEnv.showWindow(dialog);
|
||||
}
|
||||
else
|
||||
|
@ -2427,49 +2421,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
public void executeASync(ProcessInfo pi) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isUILocked() {
|
||||
return m_uiLocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pi
|
||||
*/
|
||||
public void lockUI(ProcessInfo pi) {
|
||||
if (m_uiLocked) return;
|
||||
|
||||
m_uiLocked = true;
|
||||
|
||||
if (Executions.getCurrent() != null)
|
||||
Clients.showBusy(null);
|
||||
else
|
||||
{
|
||||
try {
|
||||
//acquire desktop, 2 second timeout
|
||||
Executions.activate(getComponent().getDesktop(), 2000);
|
||||
try {
|
||||
Clients.showBusy(null);
|
||||
} catch(Error ex){
|
||||
throw ex;
|
||||
} finally{
|
||||
//release full control of desktop
|
||||
Executions.deactivate(getComponent().getDesktop());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING, "Failed to lock UI.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pi
|
||||
*/
|
||||
public void unlockUI(ProcessInfo pi) {
|
||||
if (!m_uiLocked) return;
|
||||
|
||||
m_uiLocked = false;
|
||||
private void onModalClose(ProcessInfo pi) {
|
||||
boolean notPrint = pi != null
|
||||
&& pi.getAD_Process_ID() != curTab.getAD_Process_ID()
|
||||
&& pi.isReportingProcess() == false;
|
||||
|
@ -2482,7 +2437,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
{
|
||||
updateUI(pi);
|
||||
}
|
||||
Clients.clearBusy(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2494,7 +2448,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
{
|
||||
updateUI(pi);
|
||||
}
|
||||
Clients.clearBusy(null);
|
||||
} catch(Error ex){
|
||||
throw ex;
|
||||
} finally{
|
||||
|
@ -2502,23 +2455,15 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
Executions.deactivate(getComponent().getDesktop());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING, "Failed to update UI upon unloc.", e);
|
||||
logger.log(Level.WARNING, "Failed to update UI upon unlock.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void statusUpdate(String message) {
|
||||
statusBar.setStatusLine(message);
|
||||
}
|
||||
|
||||
private void updateUI(ProcessInfo pi) {
|
||||
// Refresh data
|
||||
curTab.dataRefresh(false);
|
||||
// Timeout
|
||||
if (pi.isTimeout()) // set temporarily to R/O
|
||||
Env.setContext(ctx, curWindowNo, "Processed", "Y");
|
||||
curTabpanel.dynamicDisplay(0);
|
||||
// Update Status Line
|
||||
String summary = pi.getSummary();
|
||||
if (summary != null && summary.indexOf('@') != -1)
|
||||
|
@ -2553,5 +2498,4 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
public int getWindowNo() {
|
||||
return curWindowNo;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.compiere.util.Msg;
|
|||
import org.compiere.util.Trace;
|
||||
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.adempiere.util.Callback;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.Messagebox;
|
||||
|
||||
|
@ -267,7 +268,7 @@ public class FDialog
|
|||
return ask(windowNo, comp, s);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
/**************************************************************************
|
||||
* Ask Question with question icon and (OK) (Cancel) buttons
|
||||
*
|
||||
* @param WindowNo Number of Window
|
||||
|
@ -278,11 +279,27 @@ public class FDialog
|
|||
*/
|
||||
|
||||
public static boolean ask(int windowNo, Component comp, String adMessage)
|
||||
{
|
||||
return ask(windowNo, comp, adMessage, (Callback<String>)null);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Ask Question with question icon and (OK) (Cancel) buttons
|
||||
*
|
||||
* @param WindowNo Number of Window
|
||||
* @param c Container (owner)
|
||||
* @param AD_Message Message to be translated
|
||||
*
|
||||
* @return true, if OK
|
||||
*/
|
||||
|
||||
public static boolean ask(int windowNo, Component comp, String adMessage, Callback<String> callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
String s = Msg.getMsg(Env.getCtx(), adMessage).replace("\n", "<br>");
|
||||
int response = Messagebox.showDialog(s, AEnv.getDialogHeader(Env.getCtx(), windowNo), Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION);
|
||||
int response = Messagebox.showDialog(s, AEnv.getDialogHeader(Env.getCtx(), windowNo),
|
||||
Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION, callback);
|
||||
|
||||
return (response == Messagebox.OK);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Heng Sin Low *
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* 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. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.window;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import javax.activation.MimetypesFileTypeMap;
|
||||
|
||||
import org.adempiere.webui.component.DynamicMediaLink;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.zkoss.util.media.AMedia;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zul.Vlayout;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class MultiFileDownloadDialog extends Window {
|
||||
|
||||
public static final String ON_SHOW = "onShow";
|
||||
/**
|
||||
* generated serial dialog
|
||||
*/
|
||||
private static final long serialVersionUID = -6078788264410182680L;
|
||||
private File[] files;
|
||||
|
||||
public MultiFileDownloadDialog(File[] files) {
|
||||
super();
|
||||
this.files = files;
|
||||
this.addEventListener(ON_SHOW, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
MultiFileDownloadDialog.this.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void show() {
|
||||
Vlayout layout = new Vlayout();
|
||||
layout.setStyle("padding-top: 10px; padding-bottom: 10px;");
|
||||
appendChild(layout);
|
||||
MimetypesFileTypeMap mimeMap = new MimetypesFileTypeMap();
|
||||
for(File file : files) {
|
||||
try {
|
||||
AMedia media = new AMedia(file, mimeMap.getContentType(file), null);
|
||||
DynamicMediaLink link = new DynamicMediaLink();
|
||||
layout.appendChild(link);
|
||||
link.setMedia(media);
|
||||
link.setLabel(media.getName());
|
||||
link.setStyle("margin: 5px;");
|
||||
} catch (FileNotFoundException e) {
|
||||
}
|
||||
}
|
||||
|
||||
this.setClosable(true);
|
||||
this.setSizable(true);
|
||||
this.setMaximizable(true);
|
||||
this.setBorder("normal");
|
||||
this.setContentStyle("min-height: 200px; min-width:300px");
|
||||
this.setPosition("center");
|
||||
if (this.getTitle() == null || this.getTitle().length() == 0) {
|
||||
this.setTitle("Downloads");
|
||||
}
|
||||
this.doHighlighted();
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.adempiere.util.ProcessUtil;
|
||||
import org.compiere.db.CConnection;
|
||||
import org.compiere.interfaces.Server;
|
||||
|
@ -62,10 +62,10 @@ public abstract class AbstractProcessCtl implements Runnable
|
|||
* @param trx Transaction
|
||||
* Created in process(), VInvoiceGen.generateInvoices
|
||||
*/
|
||||
public AbstractProcessCtl (IProcessMonitor aProcessMonitor, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
public AbstractProcessCtl (IProcessUI aProcessUI, int WindowNo, ProcessInfo pi, Trx trx)
|
||||
{
|
||||
windowno = WindowNo;
|
||||
m_processMonitor = aProcessMonitor;
|
||||
m_processUI = aProcessUI;
|
||||
m_pi = pi;
|
||||
m_trx = trx; // handeled correctly
|
||||
} // ProcessCtl
|
||||
|
@ -73,7 +73,7 @@ public abstract class AbstractProcessCtl implements Runnable
|
|||
/** Windowno */
|
||||
private int windowno;
|
||||
/** Parenr */
|
||||
private IProcessMonitor m_processMonitor;
|
||||
private IProcessUI m_processUI;
|
||||
/** Process Info */
|
||||
private ProcessInfo m_pi;
|
||||
private Trx m_trx;
|
||||
|
@ -276,7 +276,7 @@ public abstract class AbstractProcessCtl implements Runnable
|
|||
{
|
||||
m_pi.setReportingProcess(true);
|
||||
// Start Report -----------------------------------------------
|
||||
boolean ok = ReportCtl.start(m_processMonitor, windowno, m_pi, IsDirectPrint);
|
||||
boolean ok = ReportCtl.start(m_processUI, windowno, m_pi, IsDirectPrint);
|
||||
m_pi.setSummary("Report", !ok);
|
||||
unlock ();
|
||||
}
|
||||
|
@ -322,12 +322,12 @@ public abstract class AbstractProcessCtl implements Runnable
|
|||
return m_pi;
|
||||
}
|
||||
|
||||
protected IProcessMonitor getProcessMonitor()
|
||||
protected IProcessUI getProcessMonitor()
|
||||
{
|
||||
return m_processMonitor;
|
||||
return m_processUI;
|
||||
}
|
||||
|
||||
protected IProcessMonitor getParent()
|
||||
protected IProcessUI getParent()
|
||||
{
|
||||
return getProcessMonitor();
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ public abstract class AbstractProcessCtl implements Runnable
|
|||
if (m_pi.getClassName().toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) {
|
||||
return ProcessUtil.startScriptProcess(Env.getCtx(), m_pi, m_trx);
|
||||
} else {
|
||||
return ProcessUtil.startJavaProcess(Env.getCtx(), m_pi, m_trx, true, m_processMonitor);
|
||||
return ProcessUtil.startJavaProcess(Env.getCtx(), m_pi, m_trx, true, m_processUI);
|
||||
}
|
||||
}
|
||||
return !m_pi.isError();
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.logging.Level;
|
|||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.util.IProcessMonitor;
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.model.MPaySelectionCheck;
|
||||
import org.compiere.model.MProcess;
|
||||
import org.compiere.model.MQuery;
|
||||
|
@ -92,7 +92,7 @@ public class ReportCtl implements SystemIDs
|
|||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @return true if created
|
||||
*/
|
||||
static public boolean start (IProcessMonitor parent, int WindowNo, ProcessInfo pi, boolean IsDirectPrint)
|
||||
static public boolean start (IProcessUI parent, int WindowNo, ProcessInfo pi, boolean IsDirectPrint)
|
||||
{
|
||||
pi.setPrintPreview(!IsDirectPrint);
|
||||
return start(parent, WindowNo, pi);
|
||||
|
@ -109,7 +109,7 @@ public class ReportCtl implements SystemIDs
|
|||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @return true if created
|
||||
*/
|
||||
static public boolean start (IProcessMonitor parent, int WindowNo, ProcessInfo pi)
|
||||
static public boolean start (IProcessUI parent, int WindowNo, ProcessInfo pi)
|
||||
{
|
||||
s_log.info("start - " + pi);
|
||||
|
||||
|
@ -261,7 +261,7 @@ public class ReportCtl implements SystemIDs
|
|||
* @param printerName Specified printer name
|
||||
* @return true if success
|
||||
*/
|
||||
public static boolean startDocumentPrint(int type, MPrintFormat customPrintFormat, int Record_ID, IProcessMonitor parent, int WindowNo, String printerName)
|
||||
public static boolean startDocumentPrint(int type, MPrintFormat customPrintFormat, int Record_ID, IProcessUI parent, int WindowNo, String printerName)
|
||||
{
|
||||
return(startDocumentPrint(type, customPrintFormat, Record_ID, parent, WindowNo, true, printerName));
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ public class ReportCtl implements SystemIDs
|
|||
* @param IsDirectPrint if true, prints directly - otherwise View
|
||||
* @return true if success
|
||||
*/
|
||||
public static boolean startDocumentPrint(int type, int Record_ID, IProcessMonitor parent, int WindowNo,
|
||||
public static boolean startDocumentPrint(int type, int Record_ID, IProcessUI parent, int WindowNo,
|
||||
boolean IsDirectPrint)
|
||||
{
|
||||
return(startDocumentPrint(type, null, Record_ID, parent, WindowNo, IsDirectPrint, null ));
|
||||
|
@ -291,7 +291,7 @@ public class ReportCtl implements SystemIDs
|
|||
* @param printerName Specified printer name
|
||||
* @return true if success
|
||||
*/
|
||||
public static boolean startDocumentPrint (int type, MPrintFormat customPrintFormat, int Record_ID, IProcessMonitor parent, int WindowNo,
|
||||
public static boolean startDocumentPrint (int type, MPrintFormat customPrintFormat, int Record_ID, IProcessUI parent, int WindowNo,
|
||||
boolean IsDirectPrint, String printerName)
|
||||
{
|
||||
ReportEngine re = ReportEngine.get (Env.getCtx(), type, Record_ID);
|
||||
|
|
Loading…
Reference in New Issue