IDEMPIERE-392 Redesign payment button - use OSGI service driven instead of hard-coded static to register payment form for each payment rule
This commit is contained in:
parent
d7aa548502
commit
d68ddd64dd
|
@ -86,3 +86,5 @@ Import-Package: javax.net.ssl,
|
|||
org.restlet.security,
|
||||
org.restlet.service,
|
||||
org.restlet.util
|
||||
Service-Component: OSGI-INF/paymentformcash.xml, OSGI-INF/paymentformcheck.xml, OSGI-INF/paymentformcreditcard.xml, OSGI-INF/paymentformdirectdebit.xml, OSGI-INF/paymentformdirectdeposit.xml, OSGI-INF/paymentformmixedpos.xml, OSGI-INF/paymentformoncredit.xml
|
||||
Bundle-ActivationPolicy: lazy
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.swing.payment.form.cash">
|
||||
<implementation class="org.compiere.grid.VPaymentFormCash"/>
|
||||
<property name="paymentRule" type="String" value="B"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.swing.payment.form.check">
|
||||
<implementation class="org.compiere.grid.VPaymentFormCheck"/>
|
||||
<property name="paymentRule" type="String" value="S"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.swing.payment.form.creditcard">
|
||||
<implementation class="org.compiere.grid.VPaymentFormCreditCard"/>
|
||||
<property name="paymentRule" type="String" value="K"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.swing.payment.form.directdebit">
|
||||
<implementation class="org.compiere.grid.VPaymentFormDirectDebit"/>
|
||||
<property name="paymentRule" type="String" value="D"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.swing.payment.form.directdeposit">
|
||||
<implementation class="org.compiere.grid.VPaymentFormDirectDeposit"/>
|
||||
<property name="paymentRule" type="String" value="T"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.swing.payment.form.mixedpos">
|
||||
<implementation class="org.compiere.grid.VPaymentFormMixedPOS"/>
|
||||
<property name="paymentRule" type="String" value="M"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.swing.payment.form.oncredit">
|
||||
<implementation class="org.compiere.grid.VPaymentFormOnCredit"/>
|
||||
<property name="paymentRule" type="String" value="P"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -1,9 +1,17 @@
|
|||
bin.includes = META-INF/,\
|
||||
client.jar,\
|
||||
plugin.xml,\
|
||||
swingx-1.6.jar,\
|
||||
looks-2.0.4.jar,\
|
||||
miglayout-3.7.1-swing.jar,\
|
||||
jpedal.jar
|
||||
source.client.jar = src/
|
||||
output.client.jar = build/
|
||||
bin.includes = META-INF/,\
|
||||
client.jar,\
|
||||
plugin.xml,\
|
||||
swingx-1.6.jar,\
|
||||
looks-2.0.4.jar,\
|
||||
miglayout-3.7.1-swing.jar,\
|
||||
jpedal.jar,\
|
||||
OSGI-INF/,\
|
||||
OSGI-INF/paymentformcash.xml,\
|
||||
OSGI-INF/paymentformcheck.xml,\
|
||||
OSGI-INF/paymentformcreditcard.xml,\
|
||||
OSGI-INF/paymentformdirectdebit.xml,\
|
||||
OSGI-INF/paymentformdirectdeposit.xml,\
|
||||
OSGI-INF/paymentformmixedpos.xml,\
|
||||
OSGI-INF/paymentformoncredit.xml
|
||||
source.client.jar = src/
|
||||
output.client.jar = build/
|
||||
|
|
|
@ -56,8 +56,12 @@ public class VPaymentFormCash extends PaymentFormCash implements ActionListener
|
|||
private CLabel bAmountLabel = new CLabel();
|
||||
private VNumber bAmountField = new VNumber();
|
||||
|
||||
public VPaymentFormCash(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab);
|
||||
public VPaymentFormCash() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
bDateField = new VDate("DateAcct", false, false, true, DisplayType.Date, "DateAcct");
|
||||
dialog = new VPaymentFormDialog(this, windowNo);
|
||||
init();
|
||||
|
|
|
@ -64,8 +64,12 @@ public class VPaymentFormCheck extends PaymentFormCheck implements ActionListene
|
|||
private CButton sOnline = new CButton();
|
||||
private CLabel sStatus = new CLabel();
|
||||
|
||||
public VPaymentFormCheck(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab);
|
||||
public VPaymentFormCheck() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
dialog = new VPaymentFormDialog(this, windowNo);
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -63,8 +63,12 @@ public class VPaymentFormCreditCard extends PaymentFormCreditCard implements Act
|
|||
private CLabel kStatus = new CLabel();
|
||||
|
||||
|
||||
public VPaymentFormCreditCard(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab);
|
||||
public VPaymentFormCreditCard() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
dialog = new VPaymentFormDialog(this, windowNo);
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -50,8 +50,12 @@ public abstract class VPaymentFormDirect extends PaymentFormDirect implements Ac
|
|||
private CLabel tRoutingText = new CLabel();
|
||||
private CLabel tNumberText = new CLabel();
|
||||
|
||||
public VPaymentFormDirect(int windowNo, GridTab mTab, boolean isDebit) {
|
||||
super(windowNo, mTab, isDebit);
|
||||
public VPaymentFormDirect(boolean isDebit) {
|
||||
super(isDebit);
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
dialog = new VPaymentFormDialog(this, windowNo);
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ import org.compiere.model.GridTab;
|
|||
*/
|
||||
public class VPaymentFormDirectDebit extends VPaymentFormDirect {
|
||||
|
||||
public VPaymentFormDirectDebit(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab, true);
|
||||
public VPaymentFormDirectDebit() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.compiere.model.GridTab;
|
|||
*/
|
||||
public class VPaymentFormDirectDeposit extends VPaymentFormDirect {
|
||||
|
||||
public VPaymentFormDirectDeposit(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab, false);
|
||||
public VPaymentFormDirectDeposit() {
|
||||
super(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,12 +13,9 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.grid;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.ServiceQuery;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -26,57 +23,19 @@ import org.compiere.util.CLogger;
|
|||
*
|
||||
*/
|
||||
public class VPaymentFormFactory {
|
||||
/** Static Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (VPaymentFormFactory.class);
|
||||
|
||||
private static HashMap<String, Class<? extends IPaymentForm>> s_registeredClasses = null;
|
||||
|
||||
/**
|
||||
* Register custom VPaymentForm* class
|
||||
* @param ad_table_id
|
||||
* @param cl custom class
|
||||
*/
|
||||
public static final void registerClass(String paymentRule, Class<? extends IPaymentForm> cl)
|
||||
|
||||
public static IPaymentForm getPaymentForm(int windowNo, GridTab mTab, String paymentRule)
|
||||
{
|
||||
s_registeredClasses.put(paymentRule, cl);
|
||||
s_log.info("Registered PaymentRule="+paymentRule+", Class="+cl);
|
||||
ServiceQuery query = new ServiceQuery();
|
||||
query.put("paymentRule", paymentRule);
|
||||
return Service.locator().locate(IPaymentForm.class, query).getService();
|
||||
}
|
||||
|
||||
static
|
||||
public static IPaymentForm create(int windowNo, GridTab mTab, String paymentRule)
|
||||
{
|
||||
// Register defaults:
|
||||
s_registeredClasses = new HashMap<String, Class<? extends IPaymentForm>>();
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_Cash, VPaymentFormCash.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_Check, VPaymentFormCheck.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_CreditCard, VPaymentFormCreditCard.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_DirectDebit, VPaymentFormDirectDebit.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_DirectDeposit, VPaymentFormDirectDeposit.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_MixedPOSPayment, VPaymentFormMixedPOS.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_OnCredit, VPaymentFormOnCredit.class);
|
||||
IPaymentForm form = getPaymentForm(windowNo, mTab, paymentRule);
|
||||
if (form != null)
|
||||
form.init(windowNo, mTab);
|
||||
return form;
|
||||
}
|
||||
|
||||
public static IPaymentForm create (int windowNo, GridTab mTab, String paymentRule)
|
||||
{
|
||||
IPaymentForm retValue = null;
|
||||
Class<? extends IPaymentForm> cl = s_registeredClasses.get(paymentRule);
|
||||
if (cl != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
java.lang.reflect.Constructor<? extends IPaymentForm> ctor = cl.getConstructor(int.class, GridTab.class);
|
||||
retValue = ctor.newInstance(windowNo, mTab);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (retValue == null)
|
||||
{
|
||||
s_log.info("Unsupported PaymentRule=" + paymentRule);
|
||||
return null;
|
||||
}
|
||||
return retValue;
|
||||
} // create
|
||||
}
|
||||
|
|
|
@ -23,8 +23,12 @@ import org.compiere.model.GridTab;
|
|||
public class VPaymentFormMixedPOS extends PaymentFormMixedPOS {
|
||||
private VPaymentFormDialog dialog;
|
||||
|
||||
public VPaymentFormMixedPOS(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab);
|
||||
public VPaymentFormMixedPOS() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
dialog = new VPaymentFormDialog(this, windowNo);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,12 @@ public class VPaymentFormOnCredit extends PaymentFormOnCredit {
|
|||
private CLabel pTermLabel = new CLabel();
|
||||
private CComboBox pTermCombo = new CComboBox();
|
||||
|
||||
public VPaymentFormOnCredit(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab);
|
||||
public VPaymentFormOnCredit() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
dialog = new VPaymentFormDialog(this, windowNo);
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -57,4 +57,4 @@ Bundle-Activator: org.adempiere.webui.WebUIActivator
|
|||
Eclipse-ExtensibleAPI: true
|
||||
Eclipse-RegisterBuddy: org.zkoss.zk.library
|
||||
Web-ContextPath: webui
|
||||
Service-Component: OSGI-INF/reportviewerprovider.xml, OSGI-INF/defaultinfofactory.xml, OSGI-INF/defaulteditorfactory.xml, OSGI-INF/jrviewerprovider.xml, OSGI-INF/resourcefinder.xml
|
||||
Service-Component: OSGI-INF/reportviewerprovider.xml, OSGI-INF/defaultinfofactory.xml, OSGI-INF/defaulteditorfactory.xml, OSGI-INF/jrviewerprovider.xml, OSGI-INF/resourcefinder.xml, OSGI-INF/paymentformcash.xml, OSGI-INF/paymentformcheck.xml, OSGI-INF/paymentformcreditcard.xml, OSGI-INF/paymentformdirectdebit.xml, OSGI-INF/paymentformdirectdeposit.xml, OSGI-INF/paymentformmixedpos.xml, OSGI-INF/paymentformoncredit.xml
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.zk.payment.form.cash">
|
||||
<implementation class="org.adempiere.webui.apps.form.WPaymentFormCash"/>
|
||||
<property name="paymentRule" type="String" value="B"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.zk.payment.form.check">
|
||||
<implementation class="org.adempiere.webui.apps.form.WPaymentFormCheck"/>
|
||||
<property name="paymentRule" type="String" value="S"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.zk.payment.form.creditcard">
|
||||
<implementation class="org.adempiere.webui.apps.form.WPaymentFormCreditCard"/>
|
||||
<property name="paymentRule" type="String" value="K"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.zk.payment.form.directdebit">
|
||||
<implementation class="org.adempiere.webui.apps.form.WPaymentFormDirectDebit"/>
|
||||
<property name="paymentRule" type="String" value="D"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.zk.payment.form.directdeposit">
|
||||
<implementation class="org.adempiere.webui.apps.form.WPaymentFormDirectDeposit"/>
|
||||
<property name="paymentRule" type="String" value="T"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.zk.payment.form.mixedpos">
|
||||
<implementation class="org.adempiere.webui.apps.form.WPaymentFormMixedPOS"/>
|
||||
<property name="paymentRule" type="String" value="M"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.ui.zk.payment.form.oncredit">
|
||||
<implementation class="org.adempiere.webui.apps.form.WPaymentFormOnCredit"/>
|
||||
<property name="paymentRule" type="String" value="P"/>
|
||||
<service>
|
||||
<provide interface="org.compiere.grid.IPaymentForm"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -61,8 +61,12 @@ public class WPaymentFormCash extends PaymentFormCash implements EventListener<E
|
|||
private Label bAmountLabel = new Label();
|
||||
private WNumberEditor bAmountField = new WNumberEditor();
|
||||
|
||||
public WPaymentFormCash(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab);
|
||||
public WPaymentFormCash() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
bDateField = new WDateEditor("DateAcct", false, false, true, "DateAcct");
|
||||
window = new WPaymentFormWindow(this, windowNo);
|
||||
init();
|
||||
|
|
|
@ -74,8 +74,12 @@ public class WPaymentFormCheck extends PaymentFormCheck implements EventListener
|
|||
private Label sStatus = new Label();
|
||||
private Panel customizePanel = new Panel();
|
||||
|
||||
public WPaymentFormCheck(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab);
|
||||
public WPaymentFormCheck() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
window = new WPaymentFormWindow(this, windowNo);
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -70,8 +70,12 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
|
|||
private Label kStatus = new Label();
|
||||
private Panel customizePanel = new Panel();
|
||||
|
||||
public WPaymentFormCreditCard(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab);
|
||||
public WPaymentFormCreditCard() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
window = new WPaymentFormWindow(this, windowNo);
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -61,8 +61,12 @@ public abstract class WPaymentFormDirect extends PaymentFormDirect implements Ev
|
|||
private Label tNumberText = new Label();
|
||||
private Panel customizePanel = new Panel();
|
||||
|
||||
public WPaymentFormDirect(int windowNo, GridTab mTab, boolean isDebit) {
|
||||
super(windowNo, mTab, isDebit);
|
||||
public WPaymentFormDirect(boolean isDebit) {
|
||||
super(isDebit);
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
window = new WPaymentFormWindow(this, windowNo);
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.compiere.model.GridTab;
|
|||
*/
|
||||
public class WPaymentFormDirectDebit extends WPaymentFormDirect {
|
||||
|
||||
public WPaymentFormDirectDebit(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab, true);
|
||||
public WPaymentFormDirectDebit() {
|
||||
super(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.compiere.model.GridTab;
|
|||
*/
|
||||
public class WPaymentFormDirectDeposit extends WPaymentFormDirect {
|
||||
|
||||
public WPaymentFormDirectDeposit(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab, false);
|
||||
public WPaymentFormDirectDeposit() {
|
||||
super(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,13 +13,10 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.apps.form;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.base.ServiceQuery;
|
||||
import org.compiere.grid.IPaymentForm;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -28,57 +25,18 @@ import org.compiere.util.CLogger;
|
|||
*/
|
||||
public class WPaymentFormFactory {
|
||||
|
||||
/** Static Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger (WPaymentFormFactory.class);
|
||||
|
||||
private static HashMap<String, Class<? extends IPaymentForm>> s_registeredClasses = null;
|
||||
|
||||
/**
|
||||
* Register custom WPaymentForm* class
|
||||
* @param ad_table_id
|
||||
* @param cl custom class
|
||||
*/
|
||||
public static final void registerClass(String paymentRule, Class<? extends IPaymentForm> cl)
|
||||
public static IPaymentForm getPaymentForm(int windowNo, GridTab mTab, String paymentRule)
|
||||
{
|
||||
s_registeredClasses.put(paymentRule, cl);
|
||||
s_log.info("Registered PaymentRule="+paymentRule+", Class="+cl);
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
// Register defaults:
|
||||
s_registeredClasses = new HashMap<String, Class<? extends IPaymentForm>>();
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_Cash, WPaymentFormCash.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_Check, WPaymentFormCheck.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_CreditCard, WPaymentFormCreditCard.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_DirectDebit, WPaymentFormDirectDebit.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_DirectDeposit, WPaymentFormDirectDeposit.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_MixedPOSPayment, WPaymentFormMixedPOS.class);
|
||||
s_registeredClasses.put(MInvoice.PAYMENTRULE_OnCredit, WPaymentFormOnCredit.class);
|
||||
ServiceQuery query = new ServiceQuery();
|
||||
query.put("paymentRule", paymentRule);
|
||||
return Service.locator().locate(IPaymentForm.class, query).getService();
|
||||
}
|
||||
|
||||
public static IPaymentForm create(int windowNo, GridTab mTab, String paymentRule)
|
||||
{
|
||||
IPaymentForm retValue = null;
|
||||
Class<? extends IPaymentForm> cl = s_registeredClasses.get(paymentRule);
|
||||
if (cl != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
java.lang.reflect.Constructor<? extends IPaymentForm> ctor = cl.getConstructor(int.class, GridTab.class);
|
||||
retValue = ctor.newInstance(windowNo, mTab);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (retValue == null)
|
||||
{
|
||||
s_log.info("Unsupported PaymentRule=" + paymentRule);
|
||||
return null;
|
||||
}
|
||||
return retValue;
|
||||
} // create
|
||||
IPaymentForm form = getPaymentForm(windowNo, mTab, paymentRule);
|
||||
if (form != null)
|
||||
form.init(windowNo, mTab);
|
||||
return form;
|
||||
}
|
||||
}
|
|
@ -25,8 +25,12 @@ public class WPaymentFormMixedPOS extends PaymentFormMixedPOS {
|
|||
|
||||
private WPaymentFormWindow window;
|
||||
|
||||
public WPaymentFormMixedPOS(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab);
|
||||
public WPaymentFormMixedPOS() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
window = new WPaymentFormWindow(this, windowNo);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,12 @@ public class WPaymentFormOnCredit extends PaymentFormOnCredit {
|
|||
private Label pTermLabel = new Label();
|
||||
private Listbox pTermCombo = ListboxFactory.newDropdownListbox();
|
||||
|
||||
public WPaymentFormOnCredit(int windowNo, GridTab mTab) {
|
||||
super(windowNo, mTab);
|
||||
public WPaymentFormOnCredit() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void init(int windowNo, GridTab mTab) {
|
||||
super.init(windowNo, mTab);
|
||||
window = new WPaymentFormWindow(this, windowNo);
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -311,18 +311,7 @@ public class WPaymentEditor extends WEditor implements ListDataListener {
|
|||
Events.sendEvent(comp, new Event(ON_SAVE_PAYMENT, comp));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Events.sendEvent(new Event("onSave", this));
|
||||
|
||||
// onSave(false, false, new Callback<Boolean>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onCallback(Boolean result) {
|
||||
// onRefresh(false, false);
|
||||
// }
|
||||
//
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,50 +1,58 @@
|
|||
output.. = WEB-INF/classes/
|
||||
bin.includes = META-INF/,\
|
||||
WEB-INF/,\
|
||||
css/,\
|
||||
images/,\
|
||||
index.zul,\
|
||||
js/,\
|
||||
theme/,\
|
||||
theme.zs,\
|
||||
zul/,\
|
||||
timeout.zul,\
|
||||
plugin.xml,\
|
||||
WEB-INF/classes/,\
|
||||
WEB-INF/lib/atmosphere-runtime-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-jbossweb-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat7-0.9.jar,\
|
||||
metainfo/,\
|
||||
WEB-INF/lib/calendar.jar,\
|
||||
calendar.css,\
|
||||
calendar.zul,\
|
||||
calendar_mini.zul,\
|
||||
divarrow.zul,\
|
||||
divtab.zul,\
|
||||
OSGI-INF/reportviewerprovider.xml,\
|
||||
OSGI-INF/defaultinfofactory.xml,\
|
||||
OSGI-INF/defaulteditorfactory.xml,\
|
||||
OSGI-INF/jrviewerprovider.xml,\
|
||||
OSGI-INF/resourcefinder.xml
|
||||
src.includes = WEB-INF/classes/,\
|
||||
WEB-INF/tld/,\
|
||||
WEB-INF/web.xml,\
|
||||
WEB-INF/xsd/,\
|
||||
WEB-INF/zk.xml,\
|
||||
css/,\
|
||||
images/,\
|
||||
index.zul,\
|
||||
js/,\
|
||||
theme/,\
|
||||
theme.zs,\
|
||||
zul/,\
|
||||
metainfo/,\
|
||||
calendar.css,\
|
||||
calendar.zul,\
|
||||
calendar_mini.zul,\
|
||||
divarrow.zul,\
|
||||
divtab.zul
|
||||
source.. = WEB-INF/src/
|
||||
bin.excludes = WEB-INF/src/,\
|
||||
WEB-INF/web-2.5.xml
|
||||
output.. = WEB-INF/classes/
|
||||
bin.includes = META-INF/,\
|
||||
WEB-INF/,\
|
||||
css/,\
|
||||
images/,\
|
||||
index.zul,\
|
||||
js/,\
|
||||
theme/,\
|
||||
theme.zs,\
|
||||
zul/,\
|
||||
timeout.zul,\
|
||||
plugin.xml,\
|
||||
WEB-INF/classes/,\
|
||||
WEB-INF/lib/atmosphere-runtime-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-jbossweb-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat7-0.9.jar,\
|
||||
metainfo/,\
|
||||
WEB-INF/lib/calendar.jar,\
|
||||
calendar.css,\
|
||||
calendar.zul,\
|
||||
calendar_mini.zul,\
|
||||
divarrow.zul,\
|
||||
divtab.zul,\
|
||||
OSGI-INF/,\
|
||||
OSGI-INF/reportviewerprovider.xml,\
|
||||
OSGI-INF/defaultinfofactory.xml,\
|
||||
OSGI-INF/defaulteditorfactory.xml,\
|
||||
OSGI-INF/jrviewerprovider.xml,\
|
||||
OSGI-INF/resourcefinder.xml,\
|
||||
OSGI-INF/paymentformcash.xml,\
|
||||
OSGI-INF/paymentformcheck.xml,\
|
||||
OSGI-INF/paymentformcreditcard.xml,\
|
||||
OSGI-INF/paymentformdirectdebit.xml,\
|
||||
OSGI-INF/paymentformdirectdeposit.xml,\
|
||||
OSGI-INF/paymentformmixedpos.xml,\
|
||||
OSGI-INF/paymentformoncredit.xml
|
||||
src.includes = WEB-INF/classes/,\
|
||||
WEB-INF/tld/,\
|
||||
WEB-INF/web.xml,\
|
||||
WEB-INF/xsd/,\
|
||||
WEB-INF/zk.xml,\
|
||||
css/,\
|
||||
images/,\
|
||||
index.zul,\
|
||||
js/,\
|
||||
theme/,\
|
||||
theme.zs,\
|
||||
zul/,\
|
||||
metainfo/,\
|
||||
calendar.css,\
|
||||
calendar.zul,\
|
||||
calendar_mini.zul,\
|
||||
divarrow.zul,\
|
||||
divtab.zul
|
||||
source.. = WEB-INF/src/
|
||||
bin.excludes = WEB-INF/src/,\
|
||||
WEB-INF/web-2.5.xml
|
||||
|
|
|
@ -13,9 +13,12 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.grid;
|
||||
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MBankAccountProcessor;
|
||||
|
||||
public interface IPaymentForm {
|
||||
|
||||
public void init(int WindowNo, GridTab mTab);
|
||||
|
||||
public boolean dynInit() throws Exception;
|
||||
|
||||
|
|
|
@ -77,7 +77,10 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
|
||||
public Hashtable<Integer,KeyNamePair> s_Currencies = null;
|
||||
|
||||
public PaymentForm(int WindowNo, GridTab mTab) {
|
||||
public PaymentForm() {
|
||||
}
|
||||
|
||||
public void init(int WindowNo, GridTab mTab) {
|
||||
m_WindowNo = WindowNo;
|
||||
m_isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), WindowNo, "IsSOTrx"));
|
||||
m_mTab = mTab;
|
||||
|
|
|
@ -57,8 +57,7 @@ public abstract class PaymentFormCash extends PaymentForm {
|
|||
/** Start CashBook */
|
||||
public int m_C_CashBook_ID = 0;
|
||||
|
||||
public PaymentFormCash(int WindowNo, GridTab mTab) {
|
||||
super(WindowNo, mTab);
|
||||
public PaymentFormCash() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -48,8 +48,7 @@ public abstract class PaymentFormCheck extends PaymentForm {
|
|||
/** Start Bank Account */
|
||||
public int m_C_BankAccount_ID = 0;
|
||||
|
||||
public PaymentFormCheck(int WindowNo, GridTab mTab) {
|
||||
super(WindowNo, mTab);
|
||||
public PaymentFormCheck() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,8 +45,7 @@ public abstract class PaymentFormCreditCard extends PaymentForm {
|
|||
/** Start CreditCard */
|
||||
public String m_CCType = "";
|
||||
|
||||
public PaymentFormCreditCard(int WindowNo, GridTab mTab) {
|
||||
super(WindowNo, mTab);
|
||||
public PaymentFormCreditCard() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,8 +45,7 @@ public abstract class PaymentFormDirect extends PaymentForm {
|
|||
public MPayment m_mPayment = null;
|
||||
public MPayment m_mPaymentOriginal = null;
|
||||
|
||||
public PaymentFormDirect(int WindowNo, GridTab mTab, boolean isDebit) {
|
||||
super(WindowNo, mTab);
|
||||
public PaymentFormDirect(boolean isDebit) {
|
||||
PAYMENTRULE = isDebit ? MInvoice.PAYMENTRULE_DirectDebit : MInvoice.PAYMENTRULE_DirectDeposit;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.compiere.model.GridTab;
|
|||
*/
|
||||
public abstract class PaymentFormMixedPOS extends PaymentForm {
|
||||
|
||||
public PaymentFormMixedPOS(int WindowNo, GridTab mTab) {
|
||||
super(WindowNo, mTab);
|
||||
public PaymentFormMixedPOS() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,7 @@ public abstract class PaymentFormOnCredit extends PaymentForm {
|
|||
/** Start Payment Term */
|
||||
public int m_C_PaymentTerm_ID = 0;
|
||||
|
||||
public PaymentFormOnCredit(int WindowNo, GridTab mTab) {
|
||||
super(WindowNo, mTab);
|
||||
public PaymentFormOnCredit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue