merge revision 6275-6315 from branches/adempiere341

This commit is contained in:
Heng Sin Low 2008-09-03 02:50:56 +00:00
parent 7de7553dac
commit 3824014613
26 changed files with 1923 additions and 1767 deletions

View File

@ -519,15 +519,9 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
"Notice : " + noOfNotice + ", Request : " + noOfRequest + ", Workflow Activities : " + noOfWorkflow);
}
public void showWindowInTabPanel(Window window)
{
Tabpanel tabPanel = new Tabpanel();
window.setParent(tabPanel);
String title = window.getTitle();
window.setTitle(null);
windowContainer.addWindow(tabPanel, title, true);
}
/**
* @param event
*/
public void onEvent(Event event)
{
Component comp = event.getTarget();
@ -720,32 +714,16 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
if(menu.getAction().equals(MMenu.ACTION_Window))
{
ADWindow adWindow = new ADWindow(Env.getCtx(), menu.getAD_Window_ID());
DesktopTabpanel tabPanel = new DesktopTabpanel();
adWindow.createPart(tabPanel);
windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
openWindow(menu.getAD_Window_ID());
}
else if(menu.getAction().equals(MMenu.ACTION_Process) ||
menu.getAction().equals(MMenu.ACTION_Report))
{
ProcessDialog pd = new ProcessDialog (menu.getAD_Process_ID(), menu.isSOTrx());
if (pd.isValid()) {
pd.setPage(page);
pd.setClosable(true);
pd.setWidth("500px");
pd.doHighlighted();
}
openProcessDialog(menu.getAD_Process_ID(), menu.isSOTrx());
}
else if(menu.getAction().equals(MMenu.ACTION_Form))
{
ADForm form = ADForm.openForm(menu.getAD_Form_ID());
DesktopTabpanel tabPanel = new DesktopTabpanel();
form.setParent(tabPanel);
//do not show window title when open as tab
form.setTitle(null);
windowContainer.addWindow(tabPanel, form.getFormName(), true);
openForm(menu.getAD_Form_ID());
}
else
{
@ -753,17 +731,80 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
}
}
/**
*
* @param processId
* @param soTrx
* @return ProcessDialog
*/
public ProcessDialog openProcessDialog(int processId, boolean soTrx) {
ProcessDialog pd = new ProcessDialog (processId, soTrx);
if (pd.isValid()) {
pd.setPage(page);
pd.setClosable(true);
pd.setWidth("500px");
pd.doHighlighted();
}
return pd;
}
/**
*
* @param formId
* @return ADWindow
*/
public ADForm openForm(int formId) {
ADForm form = ADForm.openForm(formId);
DesktopTabpanel tabPanel = new DesktopTabpanel();
form.setParent(tabPanel);
//do not show window title when open as tab
form.setTitle(null);
windowContainer.addWindow(tabPanel, form.getFormName(), true);
return form;
}
/**
*
* @param windowId
* @return ADWindow
*/
public ADWindow openWindow(int windowId) {
ADWindow adWindow = new ADWindow(Env.getCtx(), windowId);
DesktopTabpanel tabPanel = new DesktopTabpanel();
adWindow.createPart(tabPanel);
windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
return adWindow;
}
/**
* @param url
*/
public void showURL(String url, boolean closeable)
{
showURL(url, url, closeable);
}
/**
*
* @param url
* @param title
* @param closeable
*/
public void showURL(String url, String title, boolean closeable)
{
Iframe iframe = new Iframe(url);
addWin(iframe, title, closeable);
}
/**
* @param webDoc
* @param title
* @param closeable
*/
public void showURL(WebDoc webDoc, String title, boolean closeable)
{
Iframe iframe = new Iframe();
@ -774,6 +815,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
addWin(iframe, title, closeable);
}
/**
*
* @param fr
* @param title
* @param closeable
*/
private void addWin(Iframe fr, String title, boolean closeable)
{
fr.setWidth("100%");
@ -791,7 +838,10 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
windowContainer.addWindow(tabPanel, title, closeable);
}
/**
* @param AD_Window_ID
* @param query
*/
public void showZoomWindow(int AD_Window_ID, MQuery query)
{
ADWindow wnd = new ADWindow(Env.getCtx(), AD_Window_ID, query);
@ -801,12 +851,19 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
windowContainer.addWindow(tabPanel, wnd.getTitle(), true);
}
/**
* @param win
*/
public void showWindow(Window win)
{
String pos = win.getPosition();
this.showWindow(win, pos);
}
/**
* @param win
* @param pos
*/
public void showWindow(Window win, String pos)
{
win.setPage(page);
@ -819,31 +876,33 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
mode = objMode.toString();
}
if ("modal".equals(mode))
if (Window.MODE_MODAL.equals(mode))
{
showModal(win);
}
else if ("popup".equals(mode))
else if (Window.MODE_POPUP.equals(mode))
{
showPopup(win, pos);
}
else if ("overlapped".equals(mode))
else if (Window.MODE_OVERLAPPED.equals(mode))
{
showOverlapped(win, pos);
}
else if ("embedded".equals(mode))
else if (Window.MODE_EMBEDDED.equals(mode))
{
showEmbedded(win, pos);
showEmbedded(win);
}
else if ("highlighted".equals(mode))
else if (Window.MODE_HIGHLIGHTED.equals(mode))
{
showHighlighted(win, pos);
}
// win.setVisible(true);
}
public void showModal(Window win)
/**
*
* @param win
*/
private void showModal(Window win)
{
try
{
@ -856,7 +915,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
}
public void showPopup(Window win, String position)
/**
*
* @param win
* @param position
*/
private void showPopup(Window win, String position)
{
if (position == null)
win.setPosition("center");
@ -866,7 +930,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
win.doPopup();
}
public void showOverlapped(Window win, String position)
/**
*
* @param win
* @param position
*/
private void showOverlapped(Window win, String position)
{
if (position == null)
win.setPosition("center");
@ -876,7 +945,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
win.doOverlapped();
}
public void showHighlighted(Window win, String position)
/**
*
* @param win
* @param position
*/
private void showHighlighted(Window win, String position)
{
if (position == null)
win.setPosition("center");
@ -886,36 +960,56 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
win.doHighlighted();
}
public void showEmbedded(Window win, String position)
/**
*
* @param window
*/
private void showEmbedded(Window window)
{
if (position == null)
win.setPosition("center");
else
win.setPosition(position);
win.doEmbedded();
Tabpanel tabPanel = new Tabpanel();
window.setParent(tabPanel);
String title = window.getTitle();
window.setTitle(null);
windowContainer.addWindow(tabPanel, title, true);
}
/**
* @return clientInfo
*/
public ClientInfo getClientInfo() {
return clientInfo;
}
/**
*
* @param clientInfo
*/
public void setClientInfo(ClientInfo clientInfo) {
this.clientInfo = clientInfo;
}
/**
* @param win
*/
public int registerWindow(Object win) {
int retValue = windows.size();
windows.add(win);
return retValue;
}
/**
* @param WindowNo
*/
public void unregisterWindow(int WindowNo) {
if (WindowNo < windows.size())
windows.set(WindowNo, null);
}
/**
*
* @param WindowNo
* @return Object
*/
public Object findWindow(int WindowNo) {
if (WindowNo < windows.size())
return windows.get(WindowNo);
@ -923,11 +1017,18 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
return null;
}
/**
* Close active tab
*/
public void removeWindow()
{
windowContainer.removeWindow();
}
/**
*
* @param page
*/
public void setPage(Page page) {
if (this.page != page) {
layout.setPage(page);
@ -935,6 +1036,10 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
}
}
/**
* Get the root component
* @return Component
*/
public Component getComponent() {
return layout;
}

View File

@ -1,30 +1,98 @@
package org.adempiere.webui;
import org.adempiere.webui.apps.ProcessDialog;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.panel.ADForm;
import org.adempiere.webui.window.ADWindow;
import org.compiere.model.MQuery;
import org.compiere.util.WebDoc;
public interface IDesktop {
/**
*
* @return ClientInfo
*/
public ClientInfo getClientInfo();
/**
*
* @param nodeId
*/
public void onMenuSelected(int nodeId);
/**
*
* @param window
* @return windowNo
*/
public int registerWindow(Object window);
/**
* close active window
*/
public void removeWindow();
/**
*
* @param url
* @param closeable
*/
public void showURL(String url, boolean closeable);
/**
*
* @param doc
* @param string
* @param closeable
*/
public void showURL(WebDoc doc, String string, boolean closeable);
/**
*
* @param win
*/
public void showWindow(Window win);
/**
*
* @param win
* @param position
*/
public void showWindow(Window win, String position);
/**
*
* @param window_ID
* @param query
*/
public void showZoomWindow(int window_ID, MQuery query);
/**
*
* @param windowNo
*/
public void unregisterWindow(int windowNo);
public void showWindowInTabPanel(Window win); // Elaine 2008/07/30
/**
*
* @param processId
* @param soTrx
* @return ProcessDialog
*/
public ProcessDialog openProcessDialog(int processId, boolean soTrx);
/**
*
* @param formId
* @return ADWindow
*/
public ADForm openForm(int formId);
/**
*
* @param windowId
* @return ADWindow
*/
public ADWindow openWindow(int windowId);
}

View File

@ -164,7 +164,8 @@ public class WArchive implements EventListener
else // all Reports
av.query(true, m_AD_Table_ID, 0);
SessionManager.getAppDesktop().showWindowInTabPanel(form);
form.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
SessionManager.getAppDesktop().showWindow(form);
}
}
}

View File

@ -17,6 +17,10 @@
package org.adempiere.webui.apps;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InvalidClassException;
import java.io.NotSerializableException;
import java.net.URI;
@ -26,6 +30,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.List;
import java.util.logging.Level;
import javax.servlet.ServletRequest;
@ -51,6 +56,13 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Execution;
import org.zkoss.zk.ui.Executions;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
/**
* Windows Application Environment and utilities
*
@ -735,4 +747,36 @@ public final class AEnv
return false;
}
/**
*
* @param pdfList
* @param outFile
* @throws IOException
* @throws DocumentException
* @throws FileNotFoundException
*/
public static void mergePdf(List<File> pdfList, File outFile) throws IOException,
DocumentException, FileNotFoundException {
Document document = null;
PdfWriter copy = null;
for (File f : pdfList)
{
PdfReader reader = new PdfReader(f.getAbsolutePath());
if (document == null)
{
document = new Document(reader.getPageSizeWithRotation(1));
copy = PdfWriter.getInstance(document, new FileOutputStream(outFile));
document.open();
}
int pages = reader.getNumberOfPages();
PdfContentByte cb = copy.getDirectContent();
for (int i = 1; i <= pages; i++) {
document.newPage();
PdfImportedPage page = copy.getImportedPage(reader, i);
cb.addTemplate(page, 0, 0);
}
}
document.close();
}
} // AEnv

View File

@ -252,13 +252,16 @@ public class ProcessModalDialog extends Window implements EventListener
m_autoStart = true;
}
if (m_autoStart) {
this.getFirstChild().setVisible(false);
startProcess();
return true;
}
}
// Check if the process is a silent one
if(isValid() && m_ShowHelp != null && m_ShowHelp.equals("S"))
{
this.getFirstChild().setVisible(false);
startProcess();
}
return true;
@ -269,21 +272,23 @@ public class ProcessModalDialog extends Window implements EventListener
*/
private void startProcess()
{
m_processRunnable = new ProcessRunnable(Executions.getCurrent().getDesktop());
m_pi.setPrintPreview(true);
if (m_ASyncProcess != null) {
m_ASyncProcess.lockUI(m_pi);
} else {
Clients.showBusy(null, true);
}
m_processRunnable = new ProcessRunnable(Executions.getCurrent().getDesktop());
//use echo, otherwise lock ui wouldn't work
Clients.response(new AuEcho(this, "runProcessBackground", null));
Clients.response(new AuEcho(this, "runASyncProcess", null));
}
/**
* internal use, don't call this directly
*/
public void runProcessBackground() {
public void runASyncProcess() {
new Thread(m_processRunnable).start();
}
@ -302,6 +307,8 @@ public class ProcessModalDialog extends Window implements EventListener
} finally {
if (m_ASyncProcess != null) {
m_ASyncProcess.unlockUI(m_pi);
} else {
Clients.showBusy(null, false);
}
//release full control of desktop
Executions.deactivate(desktop);

View File

@ -18,13 +18,13 @@ package org.adempiere.webui.apps.form;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.*;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.DesktopTabpanel;
import org.adempiere.webui.component.Label;
@ -68,12 +68,6 @@ import org.zkoss.zul.Div;
import org.zkoss.zul.Html;
import org.zkoss.zul.Space;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
/**
* Manual Shipment Selection
*
@ -706,26 +700,7 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe
if (pdfList.size() > 1) {
try {
File outFile = File.createTempFile("WInOutGen", ".pdf");
Document document = null;
PdfWriter copy = null;
for (File f : pdfList)
{
PdfReader reader = new PdfReader(f.getAbsolutePath());
if (document == null)
{
document = new Document(reader.getPageSizeWithRotation(1));
copy = PdfWriter.getInstance(document, new FileOutputStream(outFile));
document.open();
}
int pages = reader.getNumberOfPages();
PdfContentByte cb = copy.getDirectContent();
for (int i = 1; i <= pages; i++) {
document.newPage();
PdfImportedPage page = copy.getImportedPage(reader, i);
cb.addTemplate(page, 0, 0);
}
}
document.close();
AEnv.mergePdf(pdfList, outFile);
Clients.showBusy(null, false);
Window win = new SimplePDFViewer(this.getFormName(), new FileInputStream(outFile));
@ -745,7 +720,6 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe
}
}
/**************************************************************************
* Lock User Interface.
* Called from the Worker before processing

View File

@ -18,7 +18,6 @@ package org.adempiere.webui.apps.form;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -29,6 +28,7 @@ import java.util.List;
import java.util.logging.Level;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.DesktopTabpanel;
import org.adempiere.webui.component.Label;
@ -86,11 +86,6 @@ import org.zkoss.zul.Div;
import org.zkoss.zul.Html;
import org.zkoss.zul.Space;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
/**
* Manual Invoice Selection
@ -705,26 +700,7 @@ public class WInvoiceGen extends ADForm
if (pdfList.size() > 1) {
try {
File outFile = File.createTempFile("WInvoiceGen", ".pdf");
Document document = null;
PdfWriter copy = null;
for (File f : pdfList)
{
PdfReader reader = new PdfReader(f.getAbsolutePath());
if (document == null)
{
document = new Document(reader.getPageSizeWithRotation(1));
copy = PdfWriter.getInstance(document, new FileOutputStream(outFile));
document.open();
}
int pages = reader.getNumberOfPages();
PdfContentByte cb = copy.getDirectContent();
for (int i = 1; i <= pages; i++) {
document.newPage();
PdfImportedPage page = copy.getImportedPage(reader, i);
cb.addTemplate(page, 0, 0);
}
}
document.close();
AEnv.mergePdf(pdfList, outFile);
Clients.showBusy(null, false);
Window win = new SimplePDFViewer(this.getFormName(), new FileInputStream(outFile));

View File

@ -162,8 +162,8 @@ public class WMatch extends ADForm
private Label onlyProductLabel = new Label();
private Label dateFromLabel = new Label();
private Label dateToLabel = new Label();
private WDateEditor dateFrom = new WDateEditor("DateFrom", false, false, true, DisplayType.Date, "DateFrom");
private WDateEditor dateTo = new WDateEditor("DateTo", false, false, true, DisplayType.Date, "DateTo");
private WDateEditor dateFrom = new WDateEditor("DateFrom", false, false, true, "DateFrom");
private WDateEditor dateTo = new WDateEditor("DateTo", false, false, true, "DateTo");
private Button bSearch = new Button();
private Panel southPanel = new Panel();
private Grid southLayout = GridFactory.newGridLayout();

View File

@ -14,106 +14,71 @@
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
/**
* 2007, Modified by Posterita Ltd.
*/
package org.adempiere.webui.apps.form;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.*;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Grid;
import org.adempiere.webui.component.GridFactory;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.VerticalBox;
import org.adempiere.webui.component.ListboxFactory;
import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WNumberEditor;
import org.adempiere.webui.panel.ADForm;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.MLookupFactory;
import org.compiere.model.MLookupInfo;
import org.compiere.model.MPaySelectionCheck;
import org.compiere.model.MPaymentBatch;
import org.compiere.print.ReportCtl;
import org.compiere.print.ReportEngine;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Ini;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Language;
import org.compiere.util.Msg;
import org.compiere.util.ValueNamePair;
import org.adempiere.webui.window.SimplePDFViewer;
import org.compiere.model.*;
import org.compiere.print.*;
import org.compiere.util.*;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Filedownload;
import org.zkoss.zul.Hbox;
public class WPayPrint extends ADForm implements EventListener
/**
* Payment Print & Export
*
* @author Jorg Janke
* @version $Id: VPayPrint.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
*/
public class WPayPrint extends ADForm
implements EventListener
{
/** Used Bank Account */
private int m_C_BankAccount_ID = -1;
/** Payment Information */
private MPaySelectionCheck[] m_checks = null;
/** Payment Batch */
private MPaymentBatch m_batch = null;
/** Logger */
private static CLogger log = CLogger.getCLogger(WPayPrint.class);
// Static Variables
private Hbox centerPanel = new Hbox();
private Hbox southPanel = new Hbox();
private Button bPrint = new Button();
private Button bExport = new Button();
private Button bCancel = new Button();
private Button bProcess = new Button();//(Msg.getMsg(Env.getCtx(), "VPayPrintProcess"));
private Label lPaySelect = new Label();
private Listbox fPaySelect = new Listbox();
private Label lBank = new Label();
private Label fBank = new Label();
private Label lPaymentRule = new Label();
private Listbox fPaymentRule = new Listbox();
private Label lDocumentNo = new Label();
private Textbox fDocumentNo = new Textbox();
private Label lNoPayments = new Label();
private Label fNoPayments = new Label();
private Label lBalance = new Label();
private Textbox fBalance = new Textbox();
private Label lCurrency = new Label();
private Label fCurrency = new Label();
public WPayPrint()
{
}
/**
* Initialize Panel
*/
protected void initForm()
{
log.info("");
try
{
jbInit();
zkInit();
dynInit();
this.appendChild(centerPanel);
this.appendChild(southPanel);
fPaySelect.setSelectedIndex(0);
loadPaySelectInfo();
Borderlayout contentLayout = new Borderlayout();
contentLayout.setWidth("100%");
contentLayout.setHeight("100%");
this.appendChild(contentLayout);
Center center = new Center();
contentLayout.appendChild(center);
center.appendChild(centerPanel);
South south = new South();
south.setStyle("border: none");
contentLayout.appendChild(south);
south.appendChild(southPanel);
}
catch(Exception e)
{
@ -121,120 +86,104 @@ public class WPayPrint extends ADForm implements EventListener
}
} // init
/** Used Bank Account */
private int m_C_BankAccount_ID = -1;
/** Payment Information */
private MPaySelectionCheck[] m_checks = null;
/** Payment Batch */
private MPaymentBatch m_batch = null;
/** Logger */
private static CLogger log = CLogger.getCLogger(WPayPrint.class);
// Static Variables
private Panel centerPanel = new Panel();
private ConfirmPanel southPanel = new ConfirmPanel(true, false, false, false, false, false, false);
private Grid centerLayout = GridFactory.newGridLayout();
private Button bPrint = southPanel.createButton(ConfirmPanel.A_PRINT);
private Button bExport = southPanel.createButton(ConfirmPanel.A_EXPORT);
private Button bCancel = southPanel.getButton(ConfirmPanel.A_CANCEL);
private Button bProcess = southPanel.createButton(ConfirmPanel.A_PROCESS);
private Label lPaySelect = new Label();
private Listbox fPaySelect = ListboxFactory.newDropdownListbox();
private Label lBank = new Label();
private Label fBank = new Label();
private Label lPaymentRule = new Label();
private Listbox fPaymentRule = ListboxFactory.newDropdownListbox();
private Label lDocumentNo = new Label();
private WNumberEditor fDocumentNo = new WNumberEditor();
private Label lNoPayments = new Label();
private Label fNoPayments = new Label();
private Label lBalance = new Label();
private WNumberEditor fBalance = new WNumberEditor();
private Label lCurrency = new Label();
private Label fCurrency = new Label();
/**
* Static Init
* @throws Exception
*/
private void jbInit() throws Exception
private void zkInit() throws Exception
{
fPaySelect.setRows(1);
fPaySelect.setMold("select");
fPaymentRule.setRows(1);
fPaymentRule.setMold("select");
bCancel.setImage("/images/Cancel24.png");
bPrint.setImage("/images/Print24.png");
bExport.setImage("/images/ExportX24.png");
bPrint.addEventListener(Events.ON_CLICK, this);
bExport.addEventListener(Events.ON_CLICK, this);
bCancel.addEventListener(Events.ON_CLICK, this);
bProcess.setLabel(Msg.getMsg(Env.getCtx(), "EFT"));
//
centerPanel.appendChild(centerLayout);
//
bPrint.addActionListener(this);
bExport.addActionListener(this);
bCancel.addActionListener(this);
//
bProcess.setEnabled(false);
bProcess.addEventListener(Events.ON_CLICK, this);
bProcess.addActionListener(this);
//
lPaySelect.setText(Msg.translate(Env.getCtx(), "C_PaySelection_ID"));
fPaySelect.addActionListener(this);
//
lBank.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
//
lPaymentRule.setText(Msg.translate(Env.getCtx(), "PaymentRule"));
fPaymentRule.addActionListener(this);
//
lDocumentNo.setText(Msg.translate(Env.getCtx(), "DocumentNo"));
fDocumentNo.getComponent().setIntegral(true);
lNoPayments.setText(Msg.getMsg(Env.getCtx(), "NoOfPayments"));
fNoPayments.setText("0");
lBalance.setText(Msg.translate(Env.getCtx(), "CurrentBalance"));
fBalance.setReadWrite(false);
fBalance.getComponent().setIntegral(false);
lCurrency.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
//
southPanel.addButton(bExport);
southPanel.addButton(bPrint);
southPanel.addButton(bProcess);
//
Rows rows = centerLayout.newRows();
Row row = rows.newRow();
row.appendChild(lPaySelect.rightAlign());
row.appendChild(fPaySelect);
lPaySelect.setValue(Msg.translate(Env.getCtx(), "C_PaySelection_ID"));
fPaySelect.addEventListener(Events.ON_SELECT, this);
row = rows.newRow();
row.appendChild(lBank.rightAlign());
row.appendChild(fBank);
row.appendChild(lBalance.rightAlign());
row.appendChild(fBalance.getComponent());
lBank.setValue(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
row = rows.newRow();
row.appendChild(lPaymentRule.rightAlign());
row.appendChild(fPaymentRule);
row.appendChild(lCurrency.rightAlign());
row.appendChild(fCurrency);
lPaymentRule.setValue(Msg.translate(Env.getCtx(), "PaymentRule"));
fPaymentRule.addEventListener(Events.ON_SELECT, this);
row = rows.newRow();
row.appendChild(lDocumentNo.rightAlign());
row.appendChild(fDocumentNo.getComponent());
row.appendChild(lNoPayments.rightAlign());
row.appendChild(fNoPayments);
lDocumentNo.setValue(Msg.translate(Env.getCtx(), "DocumentNo"));
lNoPayments.setValue(Msg.getMsg(Env.getCtx(), "NoOfPayments"));
fNoPayments.setValue("0");
lBalance.setValue(Msg.translate(Env.getCtx(), "CurrentBalance"));
fBalance.setEnabled(false);
lCurrency.setValue(Msg.translate(Env.getCtx(), "C_Currency_ID"));
Hbox boxPaySelect = new Hbox();
fPaySelect.setWidth("100%");
boxPaySelect.setWidth("100%");
boxPaySelect.setWidths("40%, 60%");
boxPaySelect.appendChild(lPaySelect);
boxPaySelect.appendChild(fPaySelect);
Hbox boxBank = new Hbox();
boxBank.setWidth("100%");
boxBank.setWidths("40%, 60%");
boxBank.appendChild(lBank);
boxBank.appendChild(fBank);
Hbox boxPaymentRule = new Hbox();
boxPaymentRule.setWidth("100%");
boxPaymentRule.setWidths("40%, 60%");
boxPaymentRule.appendChild(lPaymentRule);
boxPaymentRule.appendChild(fPaymentRule);
Hbox boxDocNo = new Hbox();
boxDocNo.setWidth("100%");
boxDocNo.setWidths("40%, 60%");
boxDocNo.appendChild(lDocumentNo);
boxDocNo.appendChild(fDocumentNo);
Hbox boxNoPayments = new Hbox();
boxNoPayments.setWidth("100%");
boxNoPayments.setWidths("50%, 50%");
boxNoPayments.appendChild(lNoPayments);
boxNoPayments.appendChild(fNoPayments);
Hbox boxBalance = new Hbox();
boxBalance.setWidth("100%");
boxBalance.setWidths("50%, 50%");
boxBalance.appendChild(lBalance);
boxBalance.appendChild(fBalance);
Hbox boxCurrency = new Hbox();
boxCurrency.setWidth("100%");
boxCurrency.setWidths("50%, 50%");
boxCurrency.appendChild(lCurrency);
boxCurrency.appendChild(fCurrency);
centerPanel.setWidth("100%");
centerPanel.setWidths("65%, 35%");
VerticalBox vBox1 = new VerticalBox();
vBox1.setWidth("100%");
vBox1.appendChild(boxPaySelect);
vBox1.appendChild(boxBank);
vBox1.appendChild(boxPaymentRule);
vBox1.appendChild(boxDocNo);
VerticalBox vBox2 = new VerticalBox();
vBox2.setWidth("100%");
vBox2.appendChild(new Label(""));
vBox2.appendChild(boxBalance);
vBox2.appendChild(boxCurrency);
vBox2.appendChild(boxNoPayments);
centerPanel.appendChild(vBox1);
centerPanel.appendChild(vBox2);
southPanel.appendChild(bCancel);
southPanel.appendChild(bExport);
southPanel.appendChild(bPrint);
southPanel.appendChild(bProcess);
} // WPayPrint
} // VPayPrint
/**
* Dynamic Init
*/
private void dynInit()
{
log.config("");
@ -244,17 +193,16 @@ public class WPayPrint extends ADForm implements EventListener
String sql = "SELECT C_PaySelection_ID, Name || ' - ' || TotalAmt FROM C_PaySelection "
+ "WHERE AD_Client_ID=? AND Processed='Y' AND IsActive='Y'"
+ "ORDER BY PayDate DESC";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
//
while (rs.next())
{
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
fPaySelect.appendItem(pp.getName(), pp);
fPaySelect.addItem(pp);
}
rs.close();
pstmt.close();
@ -263,11 +211,23 @@ public class WPayPrint extends ADForm implements EventListener
{
log.log(Level.SEVERE, sql, e);
}
if (fPaySelect.getItemCount() == 0)
FDialog.info(m_WindowNo, this, "VPayPrintNoRecords");
else
{
fPaySelect.setSelectedIndex(0);
loadPaySelectInfo();
}
} // dynInit
/**
* Dispose
*/
public void dispose()
{
SessionManager.getAppDesktop().removeWindow();
} // dispose
/**
* Set Payment Selection
* @param C_PaySelection_ID id
@ -279,16 +239,11 @@ public class WPayPrint extends ADForm implements EventListener
//
for (int i = 0; i < fPaySelect.getItemCount(); i++)
{
ListItem listitem = fPaySelect.getItemAtIndex(i);
KeyNamePair pp = null;
if (listitem != null)
pp = (KeyNamePair)listitem.getValue();
KeyNamePair pp = fPaySelect.getItemAtIndex(i).toKeyNamePair();
if (pp.getKey() == C_PaySelection_ID)
{
fPaySelect.setSelectedIndex(i);
loadPaySelectInfo();
return;
}
}
@ -299,15 +254,16 @@ public class WPayPrint extends ADForm implements EventListener
* Action Listener
* @param e event
*/
public void onEvent(Event e)
{
// log.config( "VPayPrint.actionPerformed" + e.toString());
if (e.getTarget() == fPaySelect)
loadPaySelectInfo();
else if (e.getTarget() == fPaymentRule)
loadPaymentRuleInfo();
//
else if (e.getTarget() == bCancel)
SessionManager.getAppDesktop().removeWindow();
dispose();
else if (e.getTarget() == bExport)
cmd_export();
else if (e.getTarget() == bProcess)
@ -319,7 +275,6 @@ public class WPayPrint extends ADForm implements EventListener
/**
* PaySelect changed - load Bank
*/
private void loadPaySelectInfo()
{
log.info( "VPayPrint.loadPaySelectInfo");
@ -327,15 +282,7 @@ public class WPayPrint extends ADForm implements EventListener
return;
// load Banks from PaySelectLine
ListItem listitem = fPaySelect.getSelectedItem();
KeyNamePair key = null;
if (listitem != null)
key = (KeyNamePair)listitem.getValue();
int C_PaySelection_ID = key.getKey();
int C_PaySelection_ID = fPaySelect.getSelectedItem().toKeyNamePair().getKey();
m_C_BankAccount_ID = -1;
String sql = "SELECT ps.C_BankAccount_ID, b.Name || ' ' || ba.AccountNo," // 1..2
+ " c.ISO_Code, CurrentBalance " // 3..4
@ -344,26 +291,24 @@ public class WPayPrint extends ADForm implements EventListener
+ " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID)"
+ " INNER JOIN C_Currency c ON (ba.C_Currency_ID=c.C_Currency_ID) "
+ "WHERE ps.C_PaySelection_ID=? AND ps.Processed='Y' AND ba.IsActive='Y'";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_PaySelection_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
{
m_C_BankAccount_ID = rs.getInt(1);
fBank.setValue(rs.getString(2));
fCurrency.setValue(rs.getString(3));
fBalance.setValue(rs.getBigDecimal(4).toString());
fBank.setText(rs.getString(2));
fCurrency.setText(rs.getString(3));
fBalance.setValue(rs.getBigDecimal(4));
}
else
{
m_C_BankAccount_ID = -1;
fBank.setValue("");
fCurrency.setValue("");
fBalance.setValue("0");
fBank.setText("");
fCurrency.setText("");
fBalance.setValue(Env.ZERO);
log.log(Level.SEVERE, "No active BankAccount for C_PaySelection_ID=" + C_PaySelection_ID);
}
rs.close();
@ -373,7 +318,6 @@ public class WPayPrint extends ADForm implements EventListener
{
log.log(Level.SEVERE, sql, e);
}
loadPaymentRule();
} // loadPaySelectInfo
@ -383,23 +327,12 @@ public class WPayPrint extends ADForm implements EventListener
private void loadPaymentRule()
{
log.info("");
if (m_C_BankAccount_ID == -1)
return;
// load PaymentRule for Bank
ListItem listitem = fPaySelect.getSelectedItem();
KeyNamePair kp = null;
if (listitem != null)
kp = (KeyNamePair)listitem.getValue();
else
return;
int C_PaySelection_ID = kp.getKey();
fPaymentRule.getChildren().clear();
int C_PaySelection_ID = fPaySelect.getSelectedItem().toKeyNamePair().getKey();
fPaymentRule.removeAllItems();
int AD_Reference_ID = 195; // MLookupInfo.getAD_Reference_ID("All_Payment Rule");
Language language = Language.getLanguage(Env.getAD_Language(Env.getCtx()));
MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
@ -407,17 +340,16 @@ public class WPayPrint extends ADForm implements EventListener
+ " AND " + info.KeyColumn
+ " IN (SELECT PaymentRule FROM C_PaySelectionCheck WHERE C_PaySelection_ID=?) "
+ info.Query.substring(info.Query.indexOf(" ORDER BY"));
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_PaySelection_ID);
ResultSet rs = pstmt.executeQuery();
//
while (rs.next())
{
ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
fPaymentRule.appendItem(pp.getName(), pp);
fPaymentRule.addItem(pp);
}
rs.close();
pstmt.close();
@ -426,12 +358,10 @@ public class WPayPrint extends ADForm implements EventListener
{
log.log(Level.SEVERE, sql, e);
}
if (fPaymentRule.getItemCount() == 0)
log.config("PaySel=" + C_PaySelection_ID + ", BAcct=" + m_C_BankAccount_ID + " - " + sql);
else
fPaymentRule.setSelectedIndex(0);
loadPaymentRuleInfo();
} // loadPaymentRule
@ -439,33 +369,17 @@ public class WPayPrint extends ADForm implements EventListener
* PaymentRule changed - load DocumentNo, NoPayments,
* enable/disable EFT, Print
*/
private void loadPaymentRuleInfo()
{
ListItem listitem = fPaymentRule.getSelectedItem();
ValueNamePair pp = null;
if (listitem != null)
pp = (ValueNamePair)listitem.getValue();
ValueNamePair pp = fPaymentRule.getSelectedItem().toValueNamePair();
if (pp == null)
return;
String PaymentRule = pp.getValue();
log.info("PaymentRule=" + PaymentRule);
fNoPayments.setValue(" ");
listitem = fPaySelect.getSelectedItem();
KeyNamePair kp = null;
if (listitem != null)
kp = (KeyNamePair)listitem.getValue();
int C_PaySelection_ID = kp.getKey();
fNoPayments.setText(" ");
int C_PaySelection_ID = fPaySelect.getSelectedItem().toKeyNamePair().getKey();
String sql = "SELECT COUNT(*) "
+ "FROM C_PaySelectionCheck "
+ "WHERE C_PaySelection_ID=?";
@ -474,10 +388,9 @@ public class WPayPrint extends ADForm implements EventListener
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_PaySelection_ID);
ResultSet rs = pstmt.executeQuery();
//
if (rs.next())
fNoPayments.setValue(String.valueOf(rs.getInt(1)));
fNoPayments.setText(String.valueOf(rs.getInt(1)));
rs.close();
pstmt.close();
}
@ -485,23 +398,21 @@ public class WPayPrint extends ADForm implements EventListener
{
log.log(Level.SEVERE, sql, e);
}
bProcess.setEnabled(PaymentRule.equals("T"));
// DocumentNo
sql = "SELECT CurrentNext "
+ "FROM C_BankAccountDoc "
+ "WHERE C_BankAccount_ID=? AND PaymentRule=? AND IsActive='Y'";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_C_BankAccount_ID);
pstmt.setString(2, PaymentRule);
ResultSet rs = pstmt.executeQuery();
//
if (rs.next())
fDocumentNo.setValue(new Integer(rs.getInt(1)).toString());
fDocumentNo.setValue(new Integer(rs.getInt(1)));
else
{
log.log(Level.SEVERE, "VPayPrint.loadPaymentRuleInfo - No active BankAccountDoc for C_BankAccount_ID="
@ -517,51 +428,25 @@ public class WPayPrint extends ADForm implements EventListener
}
} // loadPaymentRuleInfo
/**************************************************************************
* Export payments to file
*/
private void cmd_export()
{
ListItem listitem = fPaymentRule.getSelectedItem();
ValueNamePair vp = null;
if (listitem != null)
vp = (ValueNamePair)listitem.getValue();
String PaymentRule = null;
if (vp != null)
PaymentRule = vp.getValue();
String PaymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
log.info(PaymentRule);
if (!getChecks(PaymentRule))
return;
File file = null;
FileInputStream fstream = null;
int no = -1;
try
{
file = File.createTempFile("temp", "txt");
no = MPaySelectionCheck.exportToFile(m_checks, file);
fstream = new FileInputStream(file);
}
catch (IOException e1)
{
e1.printStackTrace();
}
Filedownload.save(fstream, "", file.getAbsolutePath());
// Get File Info
File tempFile = File.createTempFile("paymentExport", ".txt");
// Create File
FDialog.info(m_WindowNo, this, "Saved",
file.getAbsolutePath() + "\n"
+ Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no);
MPaySelectionCheck.exportToFile(m_checks, tempFile);
Filedownload.save(new FileInputStream(tempFile), "plain/text", "paymentExport.txt");
if (FDialog.ask(m_WindowNo, this, "VPayPrintSuccess?"))
{
@ -569,67 +454,72 @@ public class WPayPrint extends ADForm implements EventListener
MPaySelectionCheck.confirmPrint (m_checks, m_batch);
// document No not updated
}
SessionManager.getAppDesktop().removeWindow();
dispose();
}
catch (Exception e)
{
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
} // cmd_export
/**
* Create EFT payment
*/
private void cmd_EFT()
{
ListItem listitem = fPaymentRule.getSelectedItem();
ValueNamePair vp = null;
if (listitem != null)
vp = (ValueNamePair)listitem.getValue();
String PaymentRule = vp.getValue();
String PaymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
log.info(PaymentRule);
if (!getChecks(PaymentRule))
return;
SessionManager.getAppDesktop().removeWindow();
dispose();
} // cmd_EFT
/**
* Print Checks and/or Remittance
*/
private void cmd_print()
{
ListItem listitem = fPaymentRule.getSelectedItem();
ValueNamePair vp = null;
if (listitem != null)
vp = (ValueNamePair)listitem.getValue();
String PaymentRule = vp.getValue();
String PaymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
log.info(PaymentRule);
if (!getChecks(PaymentRule))
return;
boolean somethingPrinted = false;
boolean directPrint = !Ini.isPropertyBool(Ini.P_PRINTPREVIEW);
// for all checks
List<File> pdfList = new ArrayList<File>();
for (int i = 0; i < m_checks.length; i++)
{
MPaySelectionCheck check = m_checks[i];
// ReportCtrl will check BankAccountDoc for PrintFormat
boolean ok = ReportCtl.startDocumentPrint(ReportEngine.CHECK, check.get_ID(), null, m_WindowNo, directPrint);
if (!somethingPrinted && ok)
somethingPrinted = true;
ReportEngine re = ReportEngine.get(Env.getCtx(), ReportEngine.CHECK, check.get_ID());
try
{
File file = File.createTempFile("WPayPrint", null);
re.getPDF(file);
pdfList.add(file);
}
catch (Exception e)
{
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
return;
}
}
// Confirm Print and Update BankAccountDoc
if (somethingPrinted && FDialog.ask(m_WindowNo, this, "VPayPrintSuccess?"))
SimplePDFViewer chequeViewer = null;
try
{
File outFile = File.createTempFile("WPayPrint", null);
AEnv.mergePdf(pdfList, outFile);
chequeViewer = new SimplePDFViewer(this.getFormName(), new FileInputStream(outFile));
chequeViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
chequeViewer.setWidth("100%");
}
catch (Exception e)
{
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
return;
}
// Update BankAccountDoc
int lastDocumentNo = MPaySelectionCheck.confirmPrint (m_checks, m_batch);
if (lastDocumentNo != 0)
{
@ -639,26 +529,57 @@ public class WPayPrint extends ADForm implements EventListener
.append(" AND PaymentRule='").append(PaymentRule).append("'");
DB.executeUpdate(sb.toString(), null);
}
} // confirm
SimplePDFViewer remitViewer = null;
if (FDialog.ask(m_WindowNo, this, "VPayPrintPrintRemittance"))
{
pdfList = new ArrayList<File>();
for (int i = 0; i < m_checks.length; i++)
{
MPaySelectionCheck check = m_checks[i];
ReportCtl.startDocumentPrint(ReportEngine.REMITTANCE, check.get_ID(), null, m_WindowNo, directPrint);
ReportEngine re = ReportEngine.get(Env.getCtx(), ReportEngine.REMITTANCE, check.get_ID());
try
{
File file = File.createTempFile("WPayPrint", null);
re.getPDF(file);
pdfList.add(file);
}
catch (Exception e)
{
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
try
{
File outFile = File.createTempFile("WPayPrint", null);
AEnv.mergePdf(pdfList, outFile);
String name = Msg.translate(Env.getCtx(), "Remittance");
remitViewer = new SimplePDFViewer(this.getFormName() + " - " + name, new FileInputStream(outFile));
remitViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
remitViewer.setWidth("100%");
}
catch (Exception e)
{
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
} // remittance
SessionManager.getAppDesktop().removeWindow();
dispose();
if (chequeViewer != null)
SessionManager.getAppDesktop().showWindow(chequeViewer);
if (remitViewer != null)
SessionManager.getAppDesktop().showWindow(remitViewer);
} // cmd_print
/**************************************************************************
* Get Checks
* @param PaymentRule Payment Rule
* @return true if payments were created
*/
private boolean getChecks(String PaymentRule)
{
// do we have values
@ -667,28 +588,19 @@ public class WPayPrint extends ADForm implements EventListener
{
FDialog.error(m_WindowNo, this, "VPayPrintNoRecords",
"(" + Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID") + "=0)");
return false;
}
// get data
ListItem listitem = fPaySelect.getSelectedItem();
KeyNamePair kp = null;
if (listitem != null)
kp = (KeyNamePair)listitem.getValue();
int C_PaySelection_ID = kp.getKey();
int startDocumentNo = new Integer(fDocumentNo.getValue());
int C_PaySelection_ID = fPaySelect.getSelectedItem().toKeyNamePair().getKey();
int startDocumentNo = ((Number)fDocumentNo.getValue()).intValue();
log.config("C_PaySelection_ID=" + C_PaySelection_ID + ", PaymentRule=" + PaymentRule + ", DocumentNo=" + startDocumentNo);
// get Selections
//
// get Slecetions
m_checks = MPaySelectionCheck.get(C_PaySelection_ID, PaymentRule, startDocumentNo, null);
//
if (m_checks == null || m_checks.length == 0)
{
FDialog.error(m_WindowNo, this, "VPayPrintNoRecords",
@ -696,7 +608,7 @@ public class WPayPrint extends ADForm implements EventListener
return false;
}
m_batch = MPaymentBatch.getForPaySelection (Env.getCtx(), C_PaySelection_ID, null);
return true;
} // getChecks
}
} // PayPrint

View File

@ -101,7 +101,7 @@ public class WPayment extends Window
m_mTab = mTab;
try
{
bDateField = new WDateEditor("DateAcct", false, false, true, DisplayType.Date, "DateAcct");
bDateField = new WDateEditor("DateAcct", false, false, true, "DateAcct");
zkInit();
m_initOK = dynInit(button); // Null Pointer if order/invoice not saved yet
}

View File

@ -184,8 +184,8 @@ public class WTrxMaterial extends ADForm
MLookup mtypeLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3666, DisplayType.List);
mtypeField = new WTableDirEditor("MovementType", false, false, true, mtypeLookup);
// Dates
dateFField = new WDateEditor("DateFrom", false, false, true, DisplayType.Date, Msg.getMsg(Env.getCtx(), "DateFrom"));
dateTField = new WDateEditor("DateTo", false, false, true, DisplayType.Date, Msg.getMsg(Env.getCtx(), "DateTo"));
dateFField = new WDateEditor("DateFrom", false, false, true, Msg.getMsg(Env.getCtx(), "DateFrom"));
dateTField = new WDateEditor("DateTo", false, false, true, Msg.getMsg(Env.getCtx(), "DateTo"));
//
confirmPanel.addActionListener(this);
statusBar.setStatusLine("");

View File

@ -28,6 +28,7 @@ public class WPerformanceDetail extends Window
WBarGraph barPanel = new WBarGraph(goal);
appendChild(barPanel);
SessionManager.getAppDesktop().showWindowInTabPanel(this);
this.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
SessionManager.getAppDesktop().showWindow(this);
} // PerformanceDetail
}

View File

@ -17,12 +17,14 @@
package org.adempiere.webui.component;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.ParseException;
import org.zkoss.zul.Bandpopup;
import org.zkoss.zul.Button;
import org.adempiere.webui.apps.AEnv;
import org.zkoss.zul.Decimalbox;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Popup;
import org.zkoss.zul.Vbox;
/**
@ -31,7 +33,7 @@ import org.zkoss.zul.Vbox;
* @date Mar 11, 2007
* @version $Revision: 0.10 $
*/
public class NumberBox extends Bandbox
public class NumberBox extends Panel
{
private static final long serialVersionUID = 1L;
@ -41,6 +43,9 @@ public class NumberBox extends Bandbox
NumberFormat format = null;
private Decimalbox decimalBox = null;
private Button btn;
public NumberBox(boolean integral)
{
super();
@ -50,10 +55,25 @@ public class NumberBox extends Bandbox
private void init()
{
this.setImage("/images/Calculator16.png");
decimalBox = new Decimalbox();
if (integral)
decimalBox.setScale(0);
btn = new Button();
btn.setImage("/images/Calculator16.png");
this.setAction("onKeyPress : return calc.validate('" +
this.getId() + "'," + integral + ", event);");
this.appendChild(getBandPopup());
decimalBox.getId() + "'," + integral + ", event);");
Popup popup = getCalculatorPopup();
btn.setHeight("22px");
btn.setWidth("26px");
btn.setPopup(popup);
appendChild(decimalBox);
appendChild(btn);
appendChild(popup);
String style = AEnv.isFirefox2() ? "display: inline" : "display: inline-block";
this.setStyle(style);
}
public void setFormat(NumberFormat format)
@ -61,31 +81,36 @@ public class NumberBox extends Bandbox
this.format = format;
}
public void setValue(Number value)
public void setValue(Object value)
{
if (format != null)
{
super.setValue(format.format(value));
}
if (value == null)
decimalBox.setValue(null);
else if (value instanceof BigDecimal)
decimalBox.setValue((BigDecimal) value);
else if (value instanceof Number)
decimalBox.setValue(new BigDecimal(((Number)value).doubleValue()));
else
{
super.setValue(value.toString());
}
decimalBox.setValue(new BigDecimal(value.toString()));
}
public void setRawValue(Object value)
public BigDecimal getValue()
{
super.setRawValue(value);
return decimalBox.getValue();
}
public String getText()
{
return super.getText();
BigDecimal value = decimalBox.getValue();
if (value == null) return null;
if (format != null)
return format.format(value);
else
return value.toPlainString();
}
public void setValue(String value)
{
String formattedValue = "";
Number numberValue = null;
if (format != null)
@ -93,38 +118,27 @@ public class NumberBox extends Bandbox
try
{
numberValue = format.parse(value);
formattedValue = format.format(numberValue);
setValue(numberValue);
}
catch (ParseException e)
{
formattedValue = value;
}
}
else
{
formattedValue = value;
decimalBox.setValue(new BigDecimal(value));
}
}
super.setValue(formattedValue);
}
/*
public void setReadonly(boolean readonly)
private Popup getCalculatorPopup()
{
// Due to bug in bandbox - once set readonly, setting to not readonly
// does not work
super.setDisabled(readonly);
}*/
private Bandpopup getBandPopup()
{
Bandpopup bandPopup = new Bandpopup();
Popup popup = new Popup();
Vbox vbox = new Vbox();
txtCalc = new Textbox();
txtCalc.setAction("onKeyPress : return calc.validate('" +
this.getId() + "!real','" + txtCalc.getId()
decimalBox.getId() + "','" + txtCalc.getId()
+ "'," + integral + ", event);");
txtCalc.setMaxlength(250);
txtCalc.setCols(30);
@ -252,7 +266,7 @@ public class NumberBox extends Bandbox
Button btnEqual = new Button();
btnEqual.setWidth("30px");
btnEqual.setLabel("=");
btnEqual.setAction("onClick : calc.evaluate('" + this.getId() + "!real','"
btnEqual.setAction("onClick : calc.evaluate('" + decimalBox.getId() + "','"
+ txtCalcId + "')");
Button btnAdd = new Button();
@ -271,7 +285,30 @@ public class NumberBox extends Bandbox
vbox.appendChild(row3);
vbox.appendChild(row4);
bandPopup.appendChild(vbox);
return bandPopup;
popup.appendChild(vbox);
return popup;
}
public boolean isIntegral() {
return integral;
}
public void setIntegral(boolean integral) {
this.integral = integral;
if (integral)
decimalBox.setScale(0);
else
decimalBox.setScale(Decimalbox.AUTO);
}
public void setEnabled(boolean enabled)
{
decimalBox.setReadonly(!enabled);
btn.setEnabled(enabled);
}
public boolean isEnabled()
{
return decimalBox.isReadonly();
}
}

View File

@ -287,8 +287,7 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
numberbox.setFormat(format);
numberbox.setValue((BigDecimal)field);
numberbox.setWidth("100px");
numberbox.setButtonVisible(true);
numberbox.setReadonly(false);
numberbox.setEnabled(true);
numberbox.setStyle("text-align:right; "
+ listcell.getStyle());
numberbox.addEventListener(Events.ON_CHANGE, this);
@ -578,7 +577,7 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
}
else if (source instanceof NumberBox)
{
value = new BigDecimal(((NumberBox)source).getValue());
value = ((NumberBox)source).getValue();
}
if(value != null)

View File

@ -35,6 +35,10 @@ public class Window extends org.zkoss.zul.Window
public static final String MODE_EMBEDDED = "embedded";
public static final String MODE_HIGHLIGHTED = "highlighted";
public static final String MODE_KEY = "mode";
public Window()
{
super();

View File

@ -46,6 +46,10 @@ public class WDateEditor extends WEditor
private Timestamp oldValue = new Timestamp(0);
/**
*
* @param gridField
*/
public WDateEditor(GridField gridField)
{
super(new Datebox(), gridField);
@ -83,16 +87,14 @@ public class WDateEditor extends WEditor
* @param mandatory
* @param readonly
* @param updateable
* @param displayType
* @param label
* @param title
*/
public WDateEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
int displayType, String label) {
//TODO: support for displayType
super(new Datebox(), columnName, label, null, mandatory, readonly, updateable);
String title)
{
super(new Datebox(), columnName, title, null, mandatory, readonly, updateable);
}
public void onEvent(Event event)
{
Date date = getComponent().getValue();

View File

@ -43,7 +43,7 @@ public class WNumberEditor extends WEditor
public static final int MAX_DISPLAY_LENGTH = 20;
private String oldValue;
private BigDecimal oldValue;
private boolean mandatory = false;
@ -95,11 +95,8 @@ public class WNumberEditor extends WEditor
{
if (gridField != null)
{
getComponent().setMaxlength(gridField.getFieldLength());
getComponent().setTooltiptext(gridField.getDescription());
}
getComponent().setCols(MAX_DISPLAY_LENGTH);
}
/**
@ -108,14 +105,8 @@ public class WNumberEditor extends WEditor
*/
public void onEvent(Event event)
{
String newValue = getComponent().getValue();
BigDecimal oldNumber = null;
if (oldValue != null && oldValue.trim().length() > 0)
oldNumber = new BigDecimal(oldValue);
BigDecimal newNumber = null;
if (newValue != null && newValue.trim().length() > 0)
newNumber = new BigDecimal(newValue);
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldNumber, newNumber);
BigDecimal newValue = getComponent().getValue();
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
super.fireValueChange(changeEvent);
oldValue = newValue;
}
@ -138,7 +129,7 @@ public class WNumberEditor extends WEditor
@Override
public String getDisplay()
{
return getComponent().getValue();
return getComponent().getText();
}
@Override
@ -162,14 +153,7 @@ public class WNumberEditor extends WEditor
@Override
public void setValue(Object value)
{
if (value != null)
{
getComponent().setValue(value.toString());
}
else
{
getComponent().setValue("0");
}
getComponent().setValue(value);
}
@Override

View File

@ -331,7 +331,7 @@ ContextMenuListener, IZoomableEditor
@Override
public void dynamicDisplay()
{
if (isReadWrite() && (!lookup.isValidated() || !lookup.isLoaded()))
if (isReadWrite() && (lookup != null) && (!lookup.isValidated() || !lookup.isLoaded()))
this.actionRefresh();
}
}

View File

@ -0,0 +1,174 @@
/******************************************************************************
* Copyright (C) 2008 Low Heng Sin *
* 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.editor;
import java.sql.Timestamp;
import java.util.Date;
import java.util.logging.Level;
import org.adempiere.webui.event.ValueChangeEvent;
import org.compiere.model.GridField;
import org.compiere.util.CLogger;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Timebox;
/**
*
* @author Low Heng Sin
*/
public class WTimeEditor extends WEditor
{
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
private static final CLogger logger;
static
{
logger = CLogger.getCLogger(WDateEditor.class);
}
private Timestamp oldValue = new Timestamp(0);
/**
*
* @param gridField
*/
public WTimeEditor(GridField gridField)
{
super(new Timebox(), gridField);
}
/**
*
* @param columnName
* @param mandatory
* @param readonly
* @param updateable
* @param title
*/
public WTimeEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
String title)
{
super(new Timebox(), columnName, title, null, mandatory, readonly, updateable);
}
/**
* Constructor for use if a grid field is unavailable
*
* @param label
* column name (not displayed)
* @param description
* description of component
* @param mandatory
* whether a selection must be made
* @param readonly
* whether or not the editor is read only
* @param updateable
* whether the editor contents can be changed
*/
public WTimeEditor (String label, String description, boolean mandatory, boolean readonly, boolean updateable)
{
super(new Timebox(), label, description, mandatory, readonly, updateable);
setColumnName("Time");
}
public WTimeEditor()
{
this("Time", "Time", false, false, true);
} // VDate
public void onEvent(Event event)
{
Date date = getComponent().getValue();
Timestamp newValue = null;
if (date != null)
{
newValue = new Timestamp(date.getTime());
}
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
super.fireValueChange(changeEvent);
oldValue = newValue;
}
@Override
public String getDisplay()
{
// Elaine 2008/07/29
return getComponent().getText();
//
}
@Override
public Object getValue()
{
// Elaine 2008/07/25
if(getComponent().getValue() == null) return null;
return new Timestamp(getComponent().getValue().getTime());
//
}
@Override
public boolean isMandatory()
{
return false;
}
@Override
public void setMandatory(boolean mandatory)
{
}
@Override
public void setValue(Object value)
{
if (value == null)
{
oldValue = null;
getComponent().setValue(null);
}
else if (value instanceof Timestamp)
{
getComponent().setValue((Timestamp)value);
oldValue = (Timestamp)value;
}
else
{
logger.log(Level.SEVERE, "New field value is not of type timestamp");
}
}
@Override
public Timebox getComponent() {
return (Timebox) component;
}
@Override
public boolean isReadWrite() {
return !getComponent().isReadonly();
}
@Override
public void setReadWrite(boolean readWrite) {
getComponent().setReadonly(!readWrite);
}
public String[] getEvents()
{
return LISTENER_EVENTS;
}
}

View File

@ -105,6 +105,9 @@ public class WebEditorFactory
/** Date */
else if (DisplayType.isDate(displayType))
{
if (displayType == DisplayType.Time)
editor = new WTimeEditor(gridField);
else
editor = new WDateEditor(gridField);
}

View File

@ -952,11 +952,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (dialog.isValid()) {
dialog.setPosition("center");
try {
dialog.setPage(this.getComponent().getPage());
dialog.doModal();
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
}
@ -1337,22 +1336,16 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
if (m_uiLocked) return;
m_uiLocked = true;
boolean notPrint = pi != null
&& pi.getAD_Process_ID() != curTab.getAD_Process_ID()
&& pi.isReportingProcess() == false;
//
// Process Result
if (notPrint) // refresh if not print
{
if (Executions.getCurrent() != null)
Clients.showBusy("Processing...", true);
Clients.showBusy(null, true);
else
{
try {
//get full control of desktop
Executions.activate(getComponent().getDesktop());
try {
Clients.showBusy("Processing...", true);
Clients.showBusy(null, true);
} catch(Error ex){
throw ex;
} finally{
@ -1364,7 +1357,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
}
}
}
}
public void unlockUI(ProcessInfo pi) {
if (!m_uiLocked) return;

View File

@ -63,7 +63,7 @@ public class SessionContextListener implements ExecutionInit,
if (parent == null)
{
exec.removeAttribute(SESSION_CTX);
ServerContext.dispose();
// ServerContext.dispose();
}
}

View File

@ -239,7 +239,7 @@ public class WAssignmentDialog extends Window implements EventListener
confirmPanel.getButton("Cancel").setVisible(readWrite);
fResource.setEnabled(readWrite);
fDateFrom.setReadonly(!readWrite);
fQty.setReadonly(!readWrite);
fQty.setEnabled(readWrite);
m_setting = false;
} // dynInit
@ -265,7 +265,7 @@ public class WAssignmentDialog extends Window implements EventListener
Calendar date = new GregorianCalendar();
getDateAndTimeFrom(date);
Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
BigDecimal qty = new BigDecimal(fQty.getValue());
BigDecimal qty = fQty.getValue();
KeyNamePair uom = (KeyNamePair)m_lookup.get(fResource.getSelectedItem());
int minutes = MUOMConversion.convertToMinutes(Env.getCtx(), uom.getKey(), qty);
Timestamp assignDateTo = TimeUtil.addMinutess(assignDateFrom, minutes);
@ -339,8 +339,8 @@ public class WAssignmentDialog extends Window implements EventListener
Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
if (assignDateFrom != null)
m_mAssignment.setAssignDateFrom (assignDateFrom);
if (fQty.getValue() != null && fQty.getValue().trim().length() > 0) {
BigDecimal qty = new BigDecimal(fQty.getValue());
if (fQty.getValue() != null) {
BigDecimal qty = fQty.getValue();
m_mAssignment.setQty(qty);
}
m_mAssignment.setName((String)fName.getValue());

View File

@ -486,7 +486,7 @@ public class WPAttributeDialog extends Window implements EventListener
editor.setValue(Env.ZERO);
row.appendChild(editor);
if (readOnly)
editor.setReadonly(true);
editor.setEnabled(false);
else
m_editors.add (editor);
}
@ -773,7 +773,7 @@ public class WPAttributeDialog extends Window implements EventListener
else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributes[i].getAttributeValueType()))
{
NumberBox editor = (NumberBox)m_editors.get(i);
BigDecimal value = new BigDecimal(editor.getValue());
BigDecimal value = editor.getValue();
log.fine(attributes[i].getName() + "=" + value);
if (attributes[i].isMandatory() && value == null)
mandatory += " - " + attributes[i].getName();

View File

@ -34,7 +34,7 @@ public class ZkReportViewerProvider implements ReportViewerProvider {
viewer.setClosable(true);
viewer.setWidth("95%");
SessionManager.getAppDesktop().showWindowInTabPanel(viewer);
// AEnv.showWindow(viewer);
viewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
SessionManager.getAppDesktop().showWindow(viewer);
}
}