gt:             return new JPaymentRefund(JPaymentSelect.this, "chequerefund");
context: //    Openbravo POS is a point of sales application designed for touch screens.
  //    Copyright (C) 2007-2009 Openbravo, S.L.
  //    http://www.openbravo.com/product/pos
  //
  //    This file is part of Openbravo POS.
  //
  //    Openbravo POS is free software: you can redistribute it and/or modify
  //    it under the terms of the GNU General Public License as published by
  //    the Free Software Foundation, either version 3 of the License, or
  //    (at your option) any later version.
  //
  //    Openbravo POS 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 Openbravo POS.  If not, see <http://www.gnu.org/licenses/>.
  
  package com.openbravo.pos.payment;
  
  import java.awt.Component;
  import java.awt.Dialog;
  import java.awt.Frame;
  import java.awt.Window;
  import javax.swing.JFrame;
  import com.openbravo.pos.forms.AppView;
  import com.openbravo.pos.forms.AppLocal;
  import com.openbravo.format.Formats;
  import com.openbravo.pos.customers.CustomerInfoExt;
  import com.openbravo.pos.forms.DataLogicSystem;
  import java.awt.ComponentOrientation;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  /**
   *
   * @author adrianromero
   */
  public abstract class JPaymentSelect extends javax.swing.JDialog 
                              implements JPaymentNotifier {
      
      private PaymentInfoList m_aPaymentInfo;
      private boolean printselected;
      
      private boolean accepted;
      
      private AppView app;
      private double m_dTotal; 
      private CustomerInfoExt customerext;
      private DataLogicSystem dlSystem;
      
      private Map<String, JPaymentInterface> payments = new HashMap<String, JPaymentInterface>();
      private String m_sTransactionID;
      
      
      /** Creates new form JPaymentSelect */
      protected JPaymentSelect(java.awt.Frame parent, boolean modal, ComponentOrientation o) {
          super(parent, modal);
          initComponents();    
          
          this.applyComponentOrientation(o);
          
          getRootPane().setDefaultButton(m_jButtonOK); 
      }
      /** Creates new form JPaymentSelect */
      protected JPaymentSelect(java.awt.Dialog parent, boolean modal, ComponentOrientation o) {
          super(parent, modal);
          initComponents();       
          
          this.applyComponentOrientation(o);        
      }    
      
      public void init(AppView app) {
          this.app = app;
          dlSystem = (DataLogicSystem) app.getBean("com.openbravo.pos.forms.DataLogicSystem");
          printselected = true;
      }
      
      public void setPrintSelected(boolean value) {
          printselected = value;
      }
      
      public boolean isPrintSelected() {
          return printselected;
      }
  
      public List<PaymentInfo> getSelectedPayments() {
          return m_aPaymentInfo.getPayments();
      }
              
      public boolean showDialog(double total, CustomerInfoExt customerext) {
          
          m_aPaymentInfo = new PaymentInfoList();
          accepted = false;
          
          m_dTotal = total;
          
          this.customerext = customerext;        
  
          m_jButtonPrint.setSelected(printselected);
          m_jTotalEuros.setText(Formats.CURRENCY.formatValue(new Double(m_dTotal)));
          
          addTabs();
  
          if (m_jTabPayment.getTabCount() == 0) {
              // No payment panels available            
              m_aPaymentInfo.add(getDefaultPayment(total));
              accepted = true;            
          } else {
              getRootPane().setDefaultButton(m_jButtonOK);
              printState();
              setVisible(true);
          }
          
          // gets the print button state
          printselected = m_jButtonPrint.isSelected();
          
          // remove all tabs        
          m_jTabPayment.removeAll();
          
          return accepted;
      }  
      
      protected abstract void addTabs();
      protected abstract void setStatusPanel(boolean isPositive, boolean isComplete);
      protected abstract PaymentInfo getDefaultPayment(double total);
      
      protected void setOKEnabled(boolean value) {
          m_jButtonOK.setEnabled(value);        
      }
      
      protected void setAddEnabled(boolean value) {
          m_jButtonAdd.setEnabled(value);
      }
          
      protected void addTabPayment(JPaymentCreator jpay) {
          if (app.getAppUserView().getUser().hasPermission(jpay.getKey())) {
              
              JPaymentInterface jpayinterface = payments.get(jpay.getKey());
              if (jpayinterface == null) {
                  jpayinterface = jpay.createJPayment();
                  payments.put(jpay.getKey(), jpayinterface);
              }
              
              jpayinterface.getComponent().applyComponentOrientation(getComponentOrientation());
              m_jTabPayment.addTab(
                      AppLocal.getIntString(jpay.getLabelKey()),
                      new javax.swing.ImageIcon(getClass().getResource(jpay.getIconKey())),
                      jpayinterface.getComponent());
          }
      }
      
      
      public interface JPaymentCreator {
          public JPaymentInterface createJPayment();
          public String getKey();
          public String getLabelKey();
          public String getIconKey();
      }
  
      public class JPaymentCashCreator implements JPaymentCreator {
          public JPaymentInterface createJPayment() {
              return new JPaymentCashPos(JPaymentSelect.this, dlSystem);
          }
          public String getKey() { return "payment.cash"; }
          public String getLabelKey() { return "tab.cash"; }
          public String getIconKey() { return "/com/openbravo/images/cash.png"; }
      }
          
      public class JPaymentChequeCreator implements JPaymentCreator {
          public JPaymentInterface createJPayment() {
              return new JPaymentCheque(JPaymentSelect.this);
          }
          public String getKey() { return "payment.cheque"; }
          public String getLabelKey() { return "tab.cheque"; }
          public String getIconKey() { return "/com/openbravo/images/desktop.png"; }
      }  
          
      public class JPaymentPaperCreator implements JPaymentCreator {
          public JPaymentInterface createJPayment() {
              return new JPaymentPaper(JPaymentSelect.this, "paperin");
          }
          public String getKey() { return "payment.paper"; }
          public String getLabelKey() { return "tab.paper"; }
          public String getIconKey() { return "/com/openbravo/images/knotes.png"; }
      }
     
      public class JPaymentMagcardCreator implements JPaymentCreator {
          public JPaymentInterface createJPayment() {
              return new JPaymentMagcard(app, JPaymentSelect.this);
          }
          public String getKey() { return "payment.magcard"; }
          public String getLabelKey() { return "tab.magcard"; }
          public String getIconKey() { return "/com/openbravo/images/vcard.png"; }
      }
          
      public class JPaymentFreeCreator implements JPaymentCreator {
          public JPaymentInterface createJPayment() {
              return new JPaymentFree(JPaymentSelect.this);
          }
          public String getKey() { return "payment.free"; }
          public String getLabelKey() { return "tab.free"; }
          public String getIconKey() { return "/com/openbravo/images/package_toys.png"; }
      }
          
      public class JPaymentDebtCreator implements JPaymentCreator {
          public JPaymentInterface createJPayment() {
              return new JPaymentDebt(JPaymentSelect.this);
          }
          public String getKey() { return "payment.debt"; }
          public String getLabelKey() { return "tab.debt"; }
          public String getIconKey() { return "/com/openbravo/images/kdmconfig32.png"; }
      }   
          
      public class JPaymentCashRefundCreator implements JPaymentCreator {
          public JPaymentInterface createJPayment() {
              return new JPaymentRefund(JPaymentSelect.this, "cashrefund");
          }
          public String getKey() { return "refund.cash"; }
          public String getLabelKey() { return "tab.cashrefund"; }
          public String getIconKey() { return "/com/openbravo/images/cash.png"; }
      }
          
      public class JPaymentChequeRefundCreator implements JPaymentCreator {
          public JPaymentInterface createJPayment() {
  