0001: /*
0002: * CreditCardWindow.java Criado em 15 de Fevereiro de 2004, 08:04
0003: */
0004:
0005: package br.com.gfp.windows;
0006:
0007: import java.awt.BorderLayout;
0008: import java.awt.Dimension;
0009: import java.awt.GridBagConstraints;
0010: import java.awt.Insets;
0011: import java.awt.event.ActionEvent;
0012: import java.awt.event.ActionListener;
0013: import java.awt.event.ItemEvent;
0014: import java.awt.event.ItemListener;
0015: import java.sql.SQLException;
0016: import java.text.ParseException;
0017: import java.util.HashMap;
0018: import java.util.Map;
0019:
0020: import javax.swing.JButton;
0021: import javax.swing.JCheckBox;
0022: import javax.swing.JFrame;
0023: import javax.swing.JOptionPane;
0024: import javax.swing.SpinnerNumberModel;
0025: import javax.swing.WindowConstants;
0026: import javax.swing.event.ListSelectionEvent;
0027: import javax.swing.event.ListSelectionListener;
0028: import javax.swing.text.DefaultFormatterFactory;
0029: import javax.swing.text.MaskFormatter;
0030:
0031: import org.flexdock.docking.DockingConstants;
0032: import org.flexdock.view.View;
0033:
0034: import br.com.gfp.actions.AbrirTelaParaInsercaoAction;
0035: import br.com.gfp.dao.CreditCardDAO;
0036: import br.com.gfp.dao.GFPController;
0037: import br.com.gfp.dao.TransactionTypeDAO;
0038: import br.com.gfp.data.Bank;
0039: import br.com.gfp.data.CheckingAccount;
0040: import br.com.gfp.data.Contact;
0041: import br.com.gfp.data.CreditCard;
0042: import br.com.gfp.data.TransactionType;
0043: import br.com.gfp.internationalization.ErrosDeDadosMessages;
0044: import br.com.gfp.internationalization.TelaCartaoCreditoMessages;
0045: import br.com.gfp.internationalization.TipoDeLancamentosMessages;
0046: import br.com.gfp.reports.ReportFactory;
0047: import br.com.gfp.util.SimpleLog;
0048: import br.com.gfp.windows.componentes.GFPHeaderRenderer;
0049: import br.com.gfp.windows.componentes.GFPTableCellRenderer;
0050: import br.com.gfp.windows.views.CreditCardBestDayView;
0051: import br.com.gfpshare.beans.DBComboBox;
0052: import br.com.gfpshare.beans.GeneralEventHandler;
0053: import br.com.gfpshare.beans.ZCalendarTextField;
0054: import br.com.gfpshare.beans.ZFormattedTextField;
0055: import br.com.gfpshare.beans.ZLabel;
0056: import br.com.gfpshare.beans.ZMoneyTextField;
0057: import br.com.gfpshare.beans.ZSpinner;
0058: import br.com.gfpshare.beans.aplicativos.IconeFactory;
0059: import br.com.gfpshare.beans.aplicativos.PainelTelaBasica;
0060: import br.com.gfpshare.beans.table.DBTable;
0061: import br.com.gfpshare.db.DAOCreationException;
0062: import br.com.gfpshare.db.DAOListener;
0063:
0064: /**
0065: * @author Igor Regis da Silva Simoes
0066: */
0067: public class CreditCardWindow extends GFPInternalFrame<CreditCard> {
0068: private JFrame owner = null;
0069:
0070: private CreditCard creditCard = new CreditCard();
0071:
0072: private PainelTelaBasica telaPrincipal;
0073:
0074: private ZLabel jlAbertura;
0075:
0076: private ZCalendarTextField ictfAbertura;
0077:
0078: private ZLabel jlFechamento;
0079:
0080: private ZCalendarTextField ictfFechamento;
0081:
0082: private ZLabel jlDiasParaPagar;
0083:
0084: private ZSpinner jsDiasParaPagar;
0085:
0086: private ZLabel jlPagamento;
0087:
0088: private ZSpinner jsPagamento;
0089:
0090: private ZLabel jlValidade;
0091:
0092: private ZCalendarTextField ictfValidade;
0093:
0094: private JCheckBox jcheckBanco;
0095:
0096: private DBComboBox jcbBanco;
0097:
0098: private ZLabel jlNumero;
0099:
0100: private ZFormattedTextField jftfNumero;
0101:
0102: private DBTable jtLancamentos;
0103:
0104: private ZLabel jlLimite;
0105:
0106: private ZMoneyTextField mtfLimite;
0107:
0108: private ZLabel jlLimiteExtra;
0109:
0110: private ZMoneyTextField mtfLimiteExtra;
0111:
0112: private ZLabel jlJurosFinanciamento;
0113:
0114: private ZSpinner jsJurosFinanciamento;
0115:
0116: private ZLabel jlJurosRotativo;
0117:
0118: private ZSpinner jsJurosRotativo;
0119:
0120: private ZLabel jlOperadora;
0121:
0122: private DBComboBox jcbOperadora;
0123:
0124: private JButton jbBesteDayToBuy;
0125:
0126: //private JCheckBox jcheckTemPlanoFidelidade;
0127:
0128: //private JLabel jlQuantoValeCadaPonto;
0129:
0130: //private JSpinner jsQuantoValeCadaPonto;
0131:
0132: private DBComboBox ccDebitoAutomatico;
0133:
0134: private JCheckBox jcbRealizarDebitoAutomatico;
0135:
0136: /**
0137: * Cria um novo form TelaCadastroCartaoCredito
0138: * @param owner
0139: */
0140: public CreditCardWindow(JFrame owner) {
0141: controller = new CreditCardDAO();
0142: this .owner = owner;
0143: contaCorrenteInit();
0144: initComponents();
0145: setSize(700, 360);
0146: }
0147:
0148: public CreditCardWindow(JFrame owner,
0149: DAOListener<CreditCard> listener) {
0150: this (owner);
0151: setListener(listener);
0152: }
0153:
0154: /**
0155: * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always
0156: * regenerated by the Form Editor.
0157: */
0158: private void initComponents() {
0159: setClosable(true);
0160: setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
0161: setIconifiable(true);
0162: setMaximizable(true);
0163: setResizable(true);
0164: setTitle(TelaCartaoCreditoMessages.getMessages().getString(
0165: "CreditCard"));
0166: setFrameIcon(IconeFactory.getIconeFactory().getImageIcon(
0167: "tamanho=pequena;/icones/32x32/contents.png"));
0168:
0169: GridBagConstraints gridBagConstraints;
0170: telaPrincipal = new PainelTelaBasica();
0171: telaPrincipal.addPrintButtonListener(new PrintListener());
0172:
0173: jtLancamentos = new DBTable(new CreditCard(),
0174: new GFPHeaderRenderer());
0175: jtLancamentos.hideColumn("Id");
0176: jtLancamentos.hideColumn("TipoConta");
0177: jtLancamentos.hideColumn("TemBanco");
0178: jtLancamentos.hideColumn("TemPlanoDeFidelidade");
0179: jtLancamentos.hideColumn("QuantoValeCadaPonto");
0180: jtLancamentos.hideColumn("ContaDebito");
0181: jtLancamentos.hideColumn("EhDeSistema"); //$NON-NLS-1$
0182:
0183: jtLancamentos.getColumn(jtLancamentos.getColumnName(2))
0184: .setCellRenderer(
0185: new GFPTableCellRenderer(
0186: GFPTableCellRenderer.ENTIDADE, -1));
0187: jtLancamentos.getColumn(jtLancamentos.getColumnName(4))
0188: .setCellRenderer(
0189: new GFPTableCellRenderer(
0190: GFPTableCellRenderer.BANCO, -1));
0191: jtLancamentos.getColumn(jtLancamentos.getColumnName(13))
0192: .setCellRenderer(
0193: new GFPTableCellRenderer(
0194: GFPTableCellRenderer.PORCENTAGEM, -1));
0195: jtLancamentos.getColumn(jtLancamentos.getColumnName(14))
0196: .setCellRenderer(
0197: new GFPTableCellRenderer(
0198: GFPTableCellRenderer.PORCENTAGEM, -1));
0199:
0200: telaPrincipal.setJtDados(jtLancamentos);
0201:
0202: telaPrincipal.setDescricaoRequired(true, null);
0203: jlAbertura = new ZLabel();
0204: ictfAbertura = new ZCalendarTextField();
0205: jlFechamento = new ZLabel();
0206: ictfFechamento = new ZCalendarTextField();
0207: jlDiasParaPagar = new ZLabel();
0208: jsDiasParaPagar = new ZSpinner();
0209: jlPagamento = new ZLabel();
0210: jsPagamento = new ZSpinner();
0211: jlValidade = new ZLabel();
0212: ictfValidade = new ZCalendarTextField();
0213: jcheckBanco = new JCheckBox();
0214: jcbBanco = new DBComboBox(new Bank());
0215: jlNumero = new ZLabel();
0216: jftfNumero = new ZFormattedTextField();
0217: jlLimite = new ZLabel();
0218: mtfLimite = new ZMoneyTextField(owner);
0219: jlLimiteExtra = new ZLabel();
0220: mtfLimiteExtra = new ZMoneyTextField(owner);
0221: jlJurosFinanciamento = new ZLabel();
0222: jsJurosFinanciamento = new ZSpinner();
0223: jlJurosRotativo = new ZLabel();
0224: jsJurosRotativo = new ZSpinner();
0225: jlOperadora = new ZLabel();
0226: jcbOperadora = new DBComboBox(new Contact());
0227: jcbRealizarDebitoAutomatico = new JCheckBox();
0228: ccDebitoAutomatico = new DBComboBox(new CheckingAccount());
0229: jbBesteDayToBuy = new JButton();
0230: //jcheckTemPlanoFidelidade = new JCheckBox();
0231: //jlQuantoValeCadaPonto = new JLabel();
0232: //jsQuantoValeCadaPonto = new JSpinner();
0233:
0234: jtLancamentos
0235: .getSelectionModel()
0236: .addListSelectionListener(
0237: (ListSelectionListener) GeneralEventHandler
0238: .makeProxy(
0239: this ,
0240: "loadFromTable", ListSelectionListener.class, "valueChanged")); //$NON-NLS-1$ //$NON-NLS-2$
0241:
0242: jlOperadora.setText(TelaCartaoCreditoMessages.getMessages()
0243: .getString("Operadora"));
0244: jlOperadora
0245: .setDisplayedMnemonic(TelaCartaoCreditoMessages
0246: .getMessages().getString("OperadoraMnemonic")
0247: .charAt(0));
0248: jlOperadora.setRequiredField(jcbOperadora);
0249: jlOperadora.setValidationNotNull(true);
0250: gridBagConstraints = new GridBagConstraints();
0251: gridBagConstraints.gridx = 0;
0252: gridBagConstraints.gridy = 0;
0253: gridBagConstraints.anchor = GridBagConstraints.WEST;
0254: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0255: telaPrincipal.addComponent(jlOperadora, gridBagConstraints,
0256: PainelTelaBasica.DATA_COMPONENTS_AREA);
0257:
0258: jcbOperadora.setToolTipText(TelaCartaoCreditoMessages
0259: .getMessages().getString("OperadoraToolTip"));
0260: jcbOperadora.setInsertNewListener(AbrirTelaParaInsercaoAction
0261: .getAction(), ContactsWindow.class.getName());
0262: gridBagConstraints = new GridBagConstraints();
0263: gridBagConstraints.gridx = 1;
0264: gridBagConstraints.gridy = 0;
0265: gridBagConstraints.gridwidth = 6;
0266: gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
0267: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0268: telaPrincipal.addComponent(jcbOperadora, gridBagConstraints,
0269: PainelTelaBasica.DATA_COMPONENTS_AREA);
0270:
0271: jcheckBanco.setText(TelaCartaoCreditoMessages.getMessages()
0272: .getString("Banco"));
0273: jcheckBanco.setMnemonic(TelaCartaoCreditoMessages.getMessages()
0274: .getString("BancoMnemonic").charAt(0));
0275: jcheckBanco.addItemListener((ItemListener) GeneralEventHandler
0276: .makeProxy(this , "BancoStateChanged",
0277: ItemListener.class, "itemStateChanged"));
0278: gridBagConstraints = new GridBagConstraints();
0279: gridBagConstraints.gridx = 0;
0280: gridBagConstraints.gridy = 1;
0281: gridBagConstraints.anchor = GridBagConstraints.WEST;
0282: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0283: telaPrincipal.addComponent(jcheckBanco, gridBagConstraints,
0284: PainelTelaBasica.DATA_COMPONENTS_AREA);
0285:
0286: jcbBanco.setToolTipText(TelaCartaoCreditoMessages.getMessages()
0287: .getString("BancoToolTip"));
0288: jcbBanco.setEnabled(false);
0289: jcbBanco.setInsertNewListener(AbrirTelaParaInsercaoAction
0290: .getAction(), BankWindow.class.getName());
0291: gridBagConstraints = new GridBagConstraints();
0292: gridBagConstraints.gridx = 1;
0293: gridBagConstraints.gridy = 1;
0294: gridBagConstraints.gridwidth = 6;
0295: gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
0296: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0297: telaPrincipal.addComponent(jcbBanco, gridBagConstraints,
0298: PainelTelaBasica.DATA_COMPONENTS_AREA);
0299:
0300: jlNumero.setText(TelaCartaoCreditoMessages.getMessages()
0301: .getString("NumeroCartao")); //$NON-NLS-1$
0302: jlNumero.setDisplayedMnemonic(TelaCartaoCreditoMessages
0303: .getMessages()
0304: .getString("NumeroCartaoMnemonic").charAt(0)); //$NON-NLS-1$
0305: jlNumero.setRequiredField(jftfNumero);
0306: jlNumero
0307: .setValidationAction(creditCard, "validateNumeroCartao");
0308: gridBagConstraints = new GridBagConstraints();
0309: gridBagConstraints.gridx = 0;
0310: gridBagConstraints.gridy = 2;
0311: gridBagConstraints.anchor = GridBagConstraints.WEST;
0312: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0313: telaPrincipal.addComponent(jlNumero, gridBagConstraints,
0314: PainelTelaBasica.DATA_COMPONENTS_AREA);
0315:
0316: try {
0317: MaskFormatter formato = new MaskFormatter(
0318: TelaCartaoCreditoMessages.getMessages().getString(
0319: "MascaraCartao")); //$NON-NLS-1$
0320: formato
0321: .setValidCharacters(TelaCartaoCreditoMessages
0322: .getMessages().getString(
0323: "CaracteresValidosCartao")); //$NON-NLS-1$
0324: formato.setPlaceholderCharacter('0');
0325: formato.setValueContainsLiteralCharacters(false);
0326: jftfNumero.setFormatterFactory(new DefaultFormatterFactory(
0327: formato));
0328: } catch (ParseException e) {
0329: ((SimpleLog) GFPController.getGFPController().getContexto()
0330: .get(GFPController.LOG))
0331: .log("Erro ao aplicar mascara de numero de cartao de credito!");
0332: ((SimpleLog) GFPController.getGFPController().getContexto()
0333: .get(GFPController.LOG)).log(e
0334: .getLocalizedMessage());
0335: ((SimpleLog) GFPController.getGFPController().getContexto()
0336: .get(GFPController.LOG)).log(e);
0337: }
0338: jftfNumero.setMinimumSize(new Dimension(100, 20));
0339: jftfNumero.setPreferredSize(new Dimension(100, 20));
0340: jftfNumero.setToolTipText(TelaCartaoCreditoMessages
0341: .getMessages().getString("NumeroCartaoToolTip"));
0342: gridBagConstraints = new GridBagConstraints();
0343: gridBagConstraints.gridx = 1;
0344: gridBagConstraints.gridy = 2;
0345: gridBagConstraints.gridwidth = 3;
0346: gridBagConstraints.weightx = 1;
0347: gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
0348: gridBagConstraints.anchor = GridBagConstraints.WEST;
0349: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0350: telaPrincipal.addComponent(jftfNumero, gridBagConstraints,
0351: PainelTelaBasica.DATA_COMPONENTS_AREA);
0352:
0353: jlAbertura.setText(TelaCartaoCreditoMessages.getMessages()
0354: .getString("DataAbertura")); //$NON-NLS-1$
0355: jlAbertura.setDisplayedMnemonic(TelaCartaoCreditoMessages
0356: .getMessages().getString("DataAberturaMnemonic")
0357: .charAt(0));
0358: jlAbertura.setRequiredField(ictfAbertura);
0359: jlAbertura.setValidationNotNull(true);
0360: gridBagConstraints = new GridBagConstraints();
0361: gridBagConstraints.gridx = 4;
0362: gridBagConstraints.gridy = 2;
0363: gridBagConstraints.anchor = GridBagConstraints.WEST;
0364: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0365: telaPrincipal.addComponent(jlAbertura, gridBagConstraints,
0366: PainelTelaBasica.DATA_COMPONENTS_AREA);
0367:
0368: ictfAbertura.setMinimumSize(new Dimension(100, 26));
0369: ictfAbertura.setToolTipText(TelaCartaoCreditoMessages
0370: .getMessages().getString("DataAberturaToolTip"));
0371: gridBagConstraints = new GridBagConstraints();
0372: gridBagConstraints.gridx = 5;
0373: gridBagConstraints.gridy = 2;
0374: gridBagConstraints.gridwidth = 2;
0375: gridBagConstraints.weightx = 1;
0376: gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
0377: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0378: telaPrincipal.addComponent(ictfAbertura, gridBagConstraints,
0379: PainelTelaBasica.DATA_COMPONENTS_AREA);
0380:
0381: jlValidade.setText(TelaCartaoCreditoMessages.getMessages()
0382: .getString("DataValidade"));
0383: jlValidade.setDisplayedMnemonic(TelaCartaoCreditoMessages
0384: .getMessages().getString("DataValidadeMnemonic")
0385: .charAt(0));
0386: jlValidade.setRequiredField(ictfValidade);
0387: jlValidade.setValidationNotNull(true);
0388: gridBagConstraints = new GridBagConstraints();
0389: gridBagConstraints.gridx = 0;
0390: gridBagConstraints.gridy = 3;
0391: gridBagConstraints.anchor = GridBagConstraints.WEST;
0392: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0393: telaPrincipal.addComponent(jlValidade, gridBagConstraints,
0394: PainelTelaBasica.DATA_COMPONENTS_AREA);
0395:
0396: ictfValidade.setMinimumSize(new Dimension(100, 26));
0397: ictfValidade.setToolTipText(TelaCartaoCreditoMessages
0398: .getMessages().getString("DataValidadeToolTip"));
0399: gridBagConstraints = new GridBagConstraints();
0400: gridBagConstraints.gridx = 1;
0401: gridBagConstraints.gridy = 3;
0402: gridBagConstraints.gridwidth = 2;
0403: gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
0404: gridBagConstraints.anchor = GridBagConstraints.WEST;
0405: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0406: telaPrincipal.addComponent(ictfValidade, gridBagConstraints,
0407: PainelTelaBasica.DATA_COMPONENTS_AREA);
0408:
0409: jlFechamento.setText(TelaCartaoCreditoMessages.getMessages()
0410: .getString("DataFechamento"));
0411: jlFechamento.setDisplayedMnemonic(TelaCartaoCreditoMessages
0412: .getMessages().getString("DataFechamentoMnemonic")
0413: .charAt(0));
0414: jlFechamento.setLabelFor(ictfFechamento);
0415: gridBagConstraints = new GridBagConstraints();
0416: gridBagConstraints.gridx = 3;
0417: gridBagConstraints.gridy = 3;
0418: gridBagConstraints.gridwidth = 2;
0419: gridBagConstraints.anchor = GridBagConstraints.WEST;
0420: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0421: telaPrincipal.addComponent(jlFechamento, gridBagConstraints,
0422: PainelTelaBasica.DATA_COMPONENTS_AREA);
0423:
0424: ictfFechamento.setMinimumSize(new Dimension(100, 26));
0425: ictfFechamento.setToolTipText(TelaCartaoCreditoMessages
0426: .getMessages().getString("DataFechamentoToolTip"));
0427: gridBagConstraints = new GridBagConstraints();
0428: gridBagConstraints.gridx = 5;
0429: gridBagConstraints.gridy = 3;
0430: gridBagConstraints.gridwidth = 2;
0431: gridBagConstraints.weightx = 1;
0432: gridBagConstraints.fill = GridBagConstraints.BOTH;
0433: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0434: telaPrincipal.addComponent(ictfFechamento, gridBagConstraints,
0435: PainelTelaBasica.DATA_COMPONENTS_AREA);
0436:
0437: jlLimite.setText(TelaCartaoCreditoMessages.getMessages()
0438: .getString("Limite"));
0439: jlLimite.setDisplayedMnemonic(TelaCartaoCreditoMessages
0440: .getMessages().getString("LimiteMnemonic").charAt(0));
0441: jlLimite.setRequiredField(mtfLimite);
0442: jlLimite
0443: .setValidationAction(creditCard, "validateLimiteCartao");
0444: gridBagConstraints = new GridBagConstraints();
0445: gridBagConstraints.gridx = 0;
0446: gridBagConstraints.gridy = 4;
0447: gridBagConstraints.anchor = GridBagConstraints.WEST;
0448: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0449: telaPrincipal.addComponent(jlLimite, gridBagConstraints,
0450: PainelTelaBasica.DATA_COMPONENTS_AREA);
0451:
0452: mtfLimite.setMinimumSize(new Dimension(100, 20));
0453: mtfLimite.setPreferredSize(new Dimension(70, 20));
0454: mtfLimite.setToolTipText(TelaCartaoCreditoMessages
0455: .getMessages().getString("LimiteToolTip"));
0456: gridBagConstraints = new GridBagConstraints();
0457: gridBagConstraints.gridx = 1;
0458: gridBagConstraints.gridy = 4;
0459: gridBagConstraints.gridwidth = 2;
0460: gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
0461: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0462: telaPrincipal.addComponent(mtfLimite, gridBagConstraints,
0463: PainelTelaBasica.DATA_COMPONENTS_AREA);
0464:
0465: jlLimiteExtra.setText(TelaCartaoCreditoMessages.getMessages()
0466: .getString("LimiteExtra"));
0467: jlLimiteExtra.setDisplayedMnemonic(TelaCartaoCreditoMessages
0468: .getMessages().getString("LimiteExtraMnemonic").charAt(
0469: 0));
0470: jlLimiteExtra.setLabelFor(mtfLimiteExtra);
0471: gridBagConstraints = new GridBagConstraints();
0472: gridBagConstraints.gridx = 3;
0473: gridBagConstraints.gridy = 4;
0474: gridBagConstraints.gridwidth = 2;
0475: gridBagConstraints.anchor = GridBagConstraints.WEST;
0476: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0477: telaPrincipal.addComponent(jlLimiteExtra, gridBagConstraints,
0478: PainelTelaBasica.DATA_COMPONENTS_AREA);
0479:
0480: mtfLimiteExtra.setMinimumSize(new Dimension(100, 20));
0481: mtfLimiteExtra.setPreferredSize(new Dimension(70, 20));
0482: mtfLimiteExtra.setToolTipText(TelaCartaoCreditoMessages
0483: .getMessages().getString("LimiteExtraToolTip"));
0484: gridBagConstraints = new GridBagConstraints();
0485: gridBagConstraints.gridx = 5;
0486: gridBagConstraints.gridy = 4;
0487: gridBagConstraints.gridwidth = 2;
0488: gridBagConstraints.weightx = 1;
0489: gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
0490: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0491: telaPrincipal.addComponent(mtfLimiteExtra, gridBagConstraints,
0492: PainelTelaBasica.DATA_COMPONENTS_AREA);
0493:
0494: jlDiasParaPagar.setText(TelaCartaoCreditoMessages.getMessages()
0495: .getString("DiasParaPagar"));
0496: jlDiasParaPagar.setDisplayedMnemonic(TelaCartaoCreditoMessages
0497: .getMessages().getString("DiasParaPagarMnemonic")
0498: .charAt(0));
0499: jlDiasParaPagar.setValidationAction(creditCard,
0500: "validateDiasParaPagar");
0501: gridBagConstraints = new GridBagConstraints();
0502: gridBagConstraints.gridx = 0;
0503: gridBagConstraints.gridy = 5;
0504: gridBagConstraints.gridwidth = 2;
0505: gridBagConstraints.anchor = GridBagConstraints.WEST;
0506: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0507: telaPrincipal.addComponent(jlDiasParaPagar, gridBagConstraints,
0508: PainelTelaBasica.DATA_COMPONENTS_AREA);
0509:
0510: jsDiasParaPagar.setMinimumSize(new Dimension(100, 26));
0511: jsDiasParaPagar.setModel(new SpinnerNumberModel(0, 0, 365, 1));
0512: jlDiasParaPagar.setRequiredField(jsDiasParaPagar);//Esta chamada deve ser aqui pois quando setamos um model o jspinner cria um novo editor perdendo os listeners anteriores
0513: jsDiasParaPagar.setToolTipText(TelaCartaoCreditoMessages
0514: .getMessages().getString("DiasParaPagarToolTip"));
0515: gridBagConstraints = new GridBagConstraints();
0516: gridBagConstraints.gridx = 2;
0517: gridBagConstraints.gridy = 5;
0518: gridBagConstraints.anchor = GridBagConstraints.WEST;
0519: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0520: telaPrincipal.addComponent(jsDiasParaPagar, gridBagConstraints,
0521: PainelTelaBasica.DATA_COMPONENTS_AREA);
0522:
0523: jlPagamento.setText(TelaCartaoCreditoMessages.getMessages()
0524: .getString("DataPagamento"));
0525: jlPagamento.setDisplayedMnemonic(TelaCartaoCreditoMessages
0526: .getMessages().getString("DataPagamentoMnemonic")
0527: .charAt(0));
0528: jlPagamento.setValidationAction(creditCard,
0529: "validateDataPagamento");
0530: gridBagConstraints = new GridBagConstraints();
0531: gridBagConstraints.gridx = 3;
0532: gridBagConstraints.gridy = 5;
0533: gridBagConstraints.gridwidth = 3;
0534: gridBagConstraints.weightx = 1;
0535: gridBagConstraints.fill = GridBagConstraints.BOTH;
0536: gridBagConstraints.anchor = GridBagConstraints.WEST;
0537: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0538: telaPrincipal.addComponent(jlPagamento, gridBagConstraints,
0539: PainelTelaBasica.DATA_COMPONENTS_AREA);
0540:
0541: jsPagamento.setMinimumSize(new Dimension(100, 26));
0542: jsPagamento.setModel(new SpinnerNumberModel(0, 0, 31, 1));
0543: jlPagamento.setRequiredField(jsPagamento);//Esta chamada deve ser aqui pois quando setamos um model o jspinner cria um novo editor perdendo os listeners anteriores
0544: jsPagamento.setToolTipText(TelaCartaoCreditoMessages
0545: .getMessages().getString("DataPagamentoToolTip"));
0546: gridBagConstraints = new GridBagConstraints();
0547: gridBagConstraints.gridx = 6;
0548: gridBagConstraints.gridy = 5;
0549: gridBagConstraints.anchor = GridBagConstraints.EAST;
0550: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0551: telaPrincipal.addComponent(jsPagamento, gridBagConstraints,
0552: PainelTelaBasica.DATA_COMPONENTS_AREA);
0553:
0554: jlJurosRotativo.setText(TelaCartaoCreditoMessages.getMessages()
0555: .getString("JurosRotativo"));
0556: jlJurosRotativo.setDisplayedMnemonic(TelaCartaoCreditoMessages
0557: .getMessages().getString("JurosRotativoMnemonic")
0558: .charAt(0));
0559: jlJurosRotativo.setValidationAction(creditCard,
0560: "validateJurosRotativo");
0561: gridBagConstraints = new GridBagConstraints();
0562: gridBagConstraints.gridx = 0;
0563: gridBagConstraints.gridy = 6;
0564: gridBagConstraints.anchor = GridBagConstraints.WEST;
0565: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0566: telaPrincipal.addComponent(jlJurosRotativo, gridBagConstraints,
0567: PainelTelaBasica.DATA_COMPONENTS_AREA);
0568:
0569: jsJurosRotativo.setMinimumSize(new Dimension(100, 26));
0570: jsJurosRotativo.setModel(new SpinnerNumberModel(0d, 0d, 99d,
0571: 0.01d));
0572: jlJurosRotativo.setRequiredField(jsJurosRotativo);//Esta chamada deve ser aqui pois quando setamos um model o jspinner cria um novo editor perdendo os listeners anteriores
0573: jsJurosRotativo.setToolTipText(TelaCartaoCreditoMessages
0574: .getMessages().getString("JurosRotativoToolTip"));
0575: gridBagConstraints = new GridBagConstraints();
0576: gridBagConstraints.gridx = 2;
0577: gridBagConstraints.gridy = 6;
0578: gridBagConstraints.anchor = GridBagConstraints.WEST;
0579: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0580: telaPrincipal.addComponent(jsJurosRotativo, gridBagConstraints,
0581: PainelTelaBasica.DATA_COMPONENTS_AREA);
0582:
0583: jlJurosFinanciamento.setText(TelaCartaoCreditoMessages
0584: .getMessages().getString("JurosFinanciamento"));
0585: jlJurosFinanciamento
0586: .setDisplayedMnemonic(TelaCartaoCreditoMessages
0587: .getMessages().getString(
0588: "JurosFinanciamentoMnemonic").charAt(0));
0589: jlJurosFinanciamento.setRequiredField(jsJurosFinanciamento);
0590: jlJurosFinanciamento.setValidationAction(creditCard,
0591: "validateJurosFinanciamento");
0592: gridBagConstraints = new GridBagConstraints();
0593: gridBagConstraints.gridx = 3;
0594: gridBagConstraints.gridy = 6;
0595: gridBagConstraints.weightx = 1;
0596: gridBagConstraints.gridwidth = 3;
0597: gridBagConstraints.weightx = 1;
0598: gridBagConstraints.fill = GridBagConstraints.BOTH;
0599: gridBagConstraints.anchor = GridBagConstraints.WEST;
0600: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0601: telaPrincipal.addComponent(jlJurosFinanciamento,
0602: gridBagConstraints,
0603: PainelTelaBasica.DATA_COMPONENTS_AREA);
0604:
0605: jsJurosFinanciamento.setMinimumSize(new Dimension(100, 26));
0606: jsJurosFinanciamento.setModel(new SpinnerNumberModel(0d, 0d,
0607: 99d, 0.01d));
0608: jlJurosFinanciamento.setRequiredField(jsJurosFinanciamento);//Esta chamada deve ser aqui pois quando setamos um model o jspinner cria um novo editor perdendo os listeners anteriores
0609: jsJurosFinanciamento.setToolTipText(TelaCartaoCreditoMessages
0610: .getMessages().getString("JurosFinanciamentoToolTip"));
0611: gridBagConstraints = new GridBagConstraints();
0612: gridBagConstraints.gridx = 6;
0613: gridBagConstraints.gridy = 6;
0614: gridBagConstraints.anchor = GridBagConstraints.EAST;
0615: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0616: telaPrincipal.addComponent(jsJurosFinanciamento,
0617: gridBagConstraints,
0618: PainelTelaBasica.DATA_COMPONENTS_AREA);
0619:
0620: jcbRealizarDebitoAutomatico.setText(TelaCartaoCreditoMessages
0621: .getMessages().getString("RealizarDebitoAutomatico"));
0622: jcbRealizarDebitoAutomatico
0623: .setToolTipText(TelaCartaoCreditoMessages.getMessages()
0624: .getString("RealizarDebitoAutomaticoToolTip"));
0625: jcbRealizarDebitoAutomatico
0626: .setMnemonic(TelaCartaoCreditoMessages.getMessages()
0627: .getString("RealizarDebitoAutomaticoMnemonic")
0628: .charAt(0));
0629: jcbRealizarDebitoAutomatico
0630: .addItemListener((ItemListener) GeneralEventHandler
0631: .makeProxy(this , "AutoDebitStateChanged",
0632: ItemListener.class, "itemStateChanged"));
0633: gridBagConstraints = new GridBagConstraints();
0634: gridBagConstraints.gridx = 0;
0635: gridBagConstraints.gridy = 7;
0636: gridBagConstraints.gridwidth = 3;
0637: gridBagConstraints.anchor = GridBagConstraints.WEST;
0638: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0639: telaPrincipal.addComponent(jcbRealizarDebitoAutomatico,
0640: gridBagConstraints,
0641: PainelTelaBasica.DATA_COMPONENTS_AREA);
0642:
0643: ccDebitoAutomatico.setToolTipText(TelaCartaoCreditoMessages
0644: .getMessages().getString("DebitoAutomaticoToolTip"));
0645: ccDebitoAutomatico.setEnabled(false);
0646: gridBagConstraints = new GridBagConstraints();
0647: gridBagConstraints.gridx = 3;
0648: gridBagConstraints.gridy = 7;
0649: gridBagConstraints.gridwidth = 2;
0650: gridBagConstraints.anchor = GridBagConstraints.WEST;
0651: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0652: telaPrincipal.addComponent(ccDebitoAutomatico,
0653: gridBagConstraints,
0654: PainelTelaBasica.DATA_COMPONENTS_AREA);
0655:
0656: /* TODO Não estamos tratando plano de fidelidade
0657: jcheckTemPlanoFidelidade.setMinimumSize(new Dimension(100, 26));
0658: jcheckTemPlanoFidelidade.setText(TelaCartaoCreditoMessages.getMessages().getString("TemPlanoFidelidade"));
0659: jcheckTemPlanoFidelidade.setMnemonic(TelaCartaoCreditoMessages.getMessages().getString("TemPlanoFidelidadeMnemonic").charAt(0));
0660: jcheckTemPlanoFidelidade.setToolTipText(TelaCartaoCreditoMessages.getMessages().getString("TemPlanoFidelidadeToolTip"));
0661: jcheckTemPlanoFidelidade.addItemListener((ItemListener)GeneralEventHandler.makeProxy(this,"TemPlanoFidelidadeStateChanged",ItemListener.class, "itemStateChanged"));
0662: gridBagConstraints = new GridBagConstraints();
0663: gridBagConstraints.gridx = 0;
0664: gridBagConstraints.gridy = 7;
0665: gridBagConstraints.gridwidth = 3;
0666: gridBagConstraints.anchor = GridBagConstraints.WEST;
0667: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0668: telaPrincipal.addComponent(jcheckTemPlanoFidelidade, gridBagConstraints, PainelTelaBasica.DATA_COMPONENTS_AREA);
0669:
0670: jlQuantoValeCadaPonto.setText(TelaCartaoCreditoMessages.getMessages().getString("QuantoValeCadaPonto"));
0671: jlQuantoValeCadaPonto.setDisplayedMnemonic(TelaCartaoCreditoMessages.getMessages().getString("QuantoValeCadaPontoMnemonic").charAt(0));
0672: jlQuantoValeCadaPonto.setLabelFor(jcheckTemPlanoFidelidade);
0673: jlQuantoValeCadaPonto.setEnabled(false);
0674: gridBagConstraints = new GridBagConstraints();
0675: gridBagConstraints.gridx = 3;
0676: gridBagConstraints.gridy = 7;
0677: gridBagConstraints.weightx = 1;
0678: gridBagConstraints.gridwidth = 3;
0679: gridBagConstraints.weightx = 1;
0680: gridBagConstraints.fill = GridBagConstraints.BOTH;
0681: gridBagConstraints.anchor = GridBagConstraints.WEST;
0682: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0683: telaPrincipal.addComponent(jlQuantoValeCadaPonto, gridBagConstraints, PainelTelaBasica.DATA_COMPONENTS_AREA);
0684:
0685: jsQuantoValeCadaPonto.setMinimumSize(new Dimension(100, 26));
0686: jsQuantoValeCadaPonto.setModel(new SpinnerNumberModel(0d, 0d, 99d, 0.01d));
0687: jsQuantoValeCadaPonto.setToolTipText(TelaCartaoCreditoMessages.getMessages().getString("QuantoValeCadaPontoToolTip"));
0688: jsQuantoValeCadaPonto.setEnabled(false);
0689: gridBagConstraints = new GridBagConstraints();
0690: gridBagConstraints.gridx = 6;
0691: gridBagConstraints.gridy = 7;
0692: gridBagConstraints.anchor = GridBagConstraints.EAST;
0693: gridBagConstraints.insets = new Insets(5, 5, 5, 5);
0694: telaPrincipal.addComponent(jsQuantoValeCadaPonto, gridBagConstraints, PainelTelaBasica.DATA_COMPONENTS_AREA);
0695: */
0696:
0697: jbBesteDayToBuy.setText(TelaCartaoCreditoMessages.getMessages()
0698: .getString("BestDayToBuy"));
0699: jbBesteDayToBuy.setToolTipText(TelaCartaoCreditoMessages
0700: .getMessages().getString("BestDayToBuyTooltip"));
0701: jbBesteDayToBuy.setMnemonic(TelaCartaoCreditoMessages
0702: .getMessages().getString("BestDayToBuyMnemonic")
0703: .charAt(0));
0704: jbBesteDayToBuy.addActionListener(new ActionListener() {
0705: public void actionPerformed(ActionEvent e) {
0706: View bestDayToBuyView = new CreditCardBestDayView();//Criamos uma nova
0707: View rootWindow = (View) GFPController
0708: .getGFPController().getContexto().get(
0709: GFPController.ROOT_WINDOW);
0710: rootWindow.dock(bestDayToBuyView,
0711: DockingConstants.WEST_REGION, .3f);
0712: }
0713: });
0714: gridBagConstraints = new GridBagConstraints();
0715: gridBagConstraints.gridx = 1;
0716: gridBagConstraints.gridy = 0;
0717: gridBagConstraints.fill = GridBagConstraints.VERTICAL;
0718: gridBagConstraints.anchor = GridBagConstraints.WEST;
0719: telaPrincipal.addComponent(jbBesteDayToBuy, gridBagConstraints,
0720: PainelTelaBasica.TABLE_HEADER_AREA);
0721:
0722: telaPrincipal
0723: .getPainelBotoes()
0724: .addActionListener(
0725: "salvar", (ActionListener) GeneralEventHandler.makeProxy(this , "salvar", ActionListener.class, "actionPerformed")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
0726: telaPrincipal
0727: .getPainelBotoes()
0728: .addActionListener(
0729: "atualizar", (ActionListener) GeneralEventHandler.makeProxy(this , "atualizar", ActionListener.class, "actionPerformed")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
0730: telaPrincipal
0731: .getPainelBotoes()
0732: .addActionListener(
0733: "novo", (ActionListener) GeneralEventHandler.makeProxy(this , "novo", ActionListener.class, "actionPerformed")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
0734: telaPrincipal
0735: .getPainelBotoes()
0736: .addActionListener(
0737: "excluir", (ActionListener) GeneralEventHandler.makeProxy(this , "excluir", ActionListener.class, "actionPerformed")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
0738: telaPrincipal
0739: .getPainelBotoes()
0740: .addActionListener(
0741: "pesquisar", (ActionListener) GeneralEventHandler.makeProxy(this , "pesquisar", ActionListener.class, "actionPerformed")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
0742: telaPrincipal
0743: .getPainelBotoes()
0744: .addActionListener(
0745: "limpar", (ActionListener) GeneralEventHandler.makeProxy(this , "limpar", ActionListener.class, "actionPerformed")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
0746: telaPrincipal
0747: .getPainelBotoes()
0748: .addActionListener(
0749: "filtrar", (ActionListener) GeneralEventHandler.makeProxy(this , "filtrar", ActionListener.class, "actionPerformed")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
0750: getContentPane().add(telaPrincipal, BorderLayout.CENTER);
0751:
0752: pack();
0753: limpar(null);
0754: }
0755:
0756: private class PrintListener implements ActionListener {
0757: public void actionPerformed(final ActionEvent e) {
0758: ((JButton) e.getSource()).setEnabled(false);
0759: (new Thread() {
0760: {
0761: setPriority(Thread.MIN_PRIORITY);
0762: setDaemon(true);
0763: }
0764:
0765: @Override
0766: public void run() {
0767: try {
0768: Map<String, Object> map = new HashMap<String, Object>();
0769: map
0770: .put(
0771: "PagtoCartao",
0772: (new TransactionTypeDAO()
0773: .getBy(new TransactionType(
0774: TipoDeLancamentosMessages
0775: .getMessages()
0776: .getString(
0777: "CreditoPagamentoCartao"))))
0778: .getId());
0779: ReportFactory.makeReport("CartoesCredito", map);
0780: } catch (Exception e1) {
0781: ((SimpleLog) GFPController.getGFPController()
0782: .getContexto().get(GFPController.LOG))
0783: .log("Erro gerar relatorio de cartoes de credito!");
0784: ((SimpleLog) GFPController.getGFPController()
0785: .getContexto().get(GFPController.LOG))
0786: .log(e1.getLocalizedMessage());
0787: ((SimpleLog) GFPController.getGFPController()
0788: .getContexto().get(GFPController.LOG))
0789: .log(e1);
0790: } finally {
0791: ((JButton) e.getSource()).setEnabled(true);
0792: }
0793: }
0794: }).start();
0795: }
0796: }
0797:
0798: /**
0799: * @param evt
0800: */
0801: public void AutoDebitStateChanged(ItemEvent evt) {
0802: ccDebitoAutomatico.setEnabled(jcbRealizarDebitoAutomatico
0803: .isSelected());
0804: }
0805:
0806: /**
0807: * @param evt
0808: */
0809: public void BancoStateChanged(ItemEvent evt) {
0810: jcbBanco.setEnabled(jcheckBanco.isSelected());
0811: if (jcheckBanco.isSelected())
0812: try {
0813: jcbBanco.loadDados();
0814: } catch (DAOCreationException e) {
0815: ((SimpleLog) GFPController.getGFPController()
0816: .getContexto().get(GFPController.LOG))
0817: .log("Erro ao carregar dados em combo da tela de cartões!");
0818: ((SimpleLog) GFPController.getGFPController()
0819: .getContexto().get(GFPController.LOG)).log(e
0820: .getLocalizedMessage());
0821: ((SimpleLog) GFPController.getGFPController()
0822: .getContexto().get(GFPController.LOG)).log(e);
0823: } catch (SQLException e) {
0824: ((SimpleLog) GFPController.getGFPController()
0825: .getContexto().get(GFPController.LOG))
0826: .log("Erro ao carregar dados em combo da tela de cartões!");
0827: ((SimpleLog) GFPController.getGFPController()
0828: .getContexto().get(GFPController.LOG)).log(e
0829: .getLocalizedMessage());
0830: ((SimpleLog) GFPController.getGFPController()
0831: .getContexto().get(GFPController.LOG)).log(e);
0832: }
0833: }
0834:
0835: /**
0836: * @param evt
0837: */
0838: /* TODO Não tratamos plano de fidelidade
0839: public void TemPlanoFidelidadeStateChanged(ItemEvent evt)
0840: {
0841: jsQuantoValeCadaPonto.setEnabled(jcheckTemPlanoFidelidade.isSelected());
0842: jlQuantoValeCadaPonto.setEnabled(jcheckTemPlanoFidelidade.isSelected());
0843: }*/
0844:
0845: /**
0846: * @param e
0847: */
0848: public void atualizar(ActionEvent e) {
0849: refreshTabelaCartaoCredito();
0850: }
0851:
0852: /**
0853: * @param e
0854: */
0855: public void pesquisar(ActionEvent e) {
0856: if (creditCard == null)
0857: contaCorrenteInit();
0858:
0859: loadCartaoCredito();
0860: try {
0861: creditCard = controller.getBy(creditCard);
0862: } catch (SQLException sqle) {
0863: ((SimpleLog) GFPController.getGFPController().getContexto()
0864: .get(GFPController.LOG))
0865: .log("Erro ao pesquisar por cartao de credito: "
0866: + creditCard);
0867: ((SimpleLog) GFPController.getGFPController().getContexto()
0868: .get(GFPController.LOG)).log(sqle
0869: .getLocalizedMessage());
0870: ((SimpleLog) GFPController.getGFPController().getContexto()
0871: .get(GFPController.LOG)).log(sqle);
0872: creditCard = null;
0873: }
0874: editarCartaoDeCredito();
0875: }
0876:
0877: /**
0878: * @param e
0879: */
0880: public void excluir(ActionEvent e) {
0881: if (creditCard == null) {
0882: JOptionPane.showMessageDialog(this ,
0883: TelaCartaoCreditoMessages.getMessages().getString(
0884: "semDadosParaEcluir")); //$NON-NLS-1$
0885: return;
0886: }
0887:
0888: loadCartaoCredito();
0889:
0890: try {
0891: controller.deletar(creditCard);
0892: } catch (SQLException sqle) {
0893: ((SimpleLog) GFPController.getGFPController().getContexto()
0894: .get(GFPController.LOG))
0895: .log("Erro ao deletar cartao de credito: "
0896: + creditCard);
0897: ((SimpleLog) GFPController.getGFPController().getContexto()
0898: .get(GFPController.LOG)).log(sqle
0899: .getLocalizedMessage());
0900: ((SimpleLog) GFPController.getGFPController().getContexto()
0901: .get(GFPController.LOG)).log(sqle);
0902: }
0903: creditCard = null;
0904: refreshTabelaCartaoCredito();
0905: }
0906:
0907: /**
0908: * @param e
0909: */
0910: public void salvar(ActionEvent e) {
0911: if (creditCard == null) {//Todo Rever Mensagem
0912: JOptionPane.showMessageDialog(this ,
0913: TelaCartaoCreditoMessages.getMessages().getString(
0914: "semDadosParaSalvar")); //$NON-NLS-1$
0915: return;
0916: }
0917: loadCartaoCredito();
0918: if (controller.isAdicionandoNovo()) {
0919: try {
0920: controller.adicionarNovo(creditCard);
0921: } catch (SQLException sqle) {
0922: JOptionPane.showMessageDialog(this , sqle.getMessage(),
0923: ErrosDeDadosMessages.getMessages().getString(
0924: "MessageTitle"),
0925: JOptionPane.WARNING_MESSAGE);
0926: telaPrincipal.getPainelBotoes().setOcorreuErro(true);
0927: return;
0928: }
0929: close();
0930: } else {
0931: try {
0932: controller.atualizar(creditCard);
0933: } catch (SQLException sqle) {
0934: JOptionPane.showMessageDialog(this , sqle.getMessage(),
0935: ErrosDeDadosMessages.getMessages().getString(
0936: "MessageTitle"),
0937: JOptionPane.WARNING_MESSAGE);
0938: telaPrincipal.getPainelBotoes().setOcorreuErro(true);
0939: return;
0940: }
0941: }
0942: creditCard = null;
0943: refreshTabelaCartaoCredito();
0944: }
0945:
0946: /**
0947: * @param e
0948: */
0949: public void novo(ActionEvent e) {
0950: contaCorrenteInit();
0951: controller.setAdicionandoNovo(true);
0952: }
0953:
0954: /**
0955: * @param e
0956: */
0957: public void limpar(ActionEvent e) {
0958: telaPrincipal.showRequiredFields();
0959: creditCard = null;
0960: controller.setAdicionandoNovo(false);
0961: telaPrincipal.getPainelBotoes().dadosCarregados(false);
0962:
0963: telaPrincipal.getTextAreaDescricao().setText("");
0964:
0965: ictfAbertura.setDate(null);
0966: ictfFechamento.setDate(null);
0967: jsDiasParaPagar.setValue(0);
0968: jsPagamento.setValue(0);
0969: ictfValidade.setDate(null);
0970: jcheckBanco.setSelected(false);
0971: jcbBanco.setSelectedIndex(0);
0972: jftfNumero.setValue(null);
0973: mtfLimite.setValue(0.00);
0974: mtfLimiteExtra.setValue(0.00);
0975: jsJurosFinanciamento.setValue(0.0);
0976: jsJurosRotativo.setValue(0.0);
0977: jcbOperadora.setSelectedIndex(0);
0978: ccDebitoAutomatico.setSelectedIndex(0);
0979: jcbRealizarDebitoAutomatico.setSelected(false);
0980: //TODO Não tratamos plano de fidelidade
0981: //jcheckTemPlanoFidelidade.setSelected(false);
0982: //jsQuantoValeCadaPonto.setValue(Double.valueOf("0"));
0983: }
0984:
0985: /**
0986: * @param e
0987: */
0988: public void filtrar(ActionEvent e) {
0989: contaCorrenteInit();
0990: loadCartaoCredito();
0991:
0992: jtLancamentos.setDataType(creditCard);
0993: try {
0994: jtLancamentos.filter();
0995: } catch (Exception e1) {
0996: ((SimpleLog) GFPController.getGFPController().getContexto()
0997: .get(GFPController.LOG))
0998: .log("Erro ao filtrar tabela de Cartoes de Credito: "
0999: + creditCard);
1000: ((SimpleLog) GFPController.getGFPController().getContexto()
1001: .get(GFPController.LOG)).log(e1
1002: .getLocalizedMessage());
1003: ((SimpleLog) GFPController.getGFPController().getContexto()
1004: .get(GFPController.LOG)).log(e1);
1005: }
1006: }
1007:
1008: /**
1009: *
1010: */
1011: private void contaCorrenteInit() {
1012: creditCard = new CreditCard();
1013: }
1014:
1015: /**
1016: *
1017: */
1018: private void loadCartaoCredito() {
1019: if (jcheckBanco.isSelected()) {
1020: creditCard.setTemBanco(Boolean.TRUE);
1021: if (jcbBanco.getSelectedIndex() > 0)
1022: try {
1023: creditCard.setBanco(((Bank) jcbBanco
1024: .getPersistentObject(jcbBanco
1025: .getSelectedIndex())).getId());
1026: } catch (Exception e) {
1027: ((SimpleLog) GFPController.getGFPController()
1028: .getContexto().get(GFPController.LOG))
1029: .log("Erro ao setar banco para o cartao de credito!");
1030: ((SimpleLog) GFPController.getGFPController()
1031: .getContexto().get(GFPController.LOG))
1032: .log(e.getLocalizedMessage());
1033: ((SimpleLog) GFPController.getGFPController()
1034: .getContexto().get(GFPController.LOG))
1035: .log(e);
1036: }
1037: }
1038: creditCard.setDataAbertura(ictfAbertura.getDate());
1039: creditCard.setDataFechamento(ictfFechamento.getDate());
1040: creditCard.setDataValidade(ictfValidade.getDate());
1041: creditCard.setDiasParaPagamento((Integer) jsDiasParaPagar
1042: .getValue());
1043: creditCard.setDataPagamento((Integer) jsPagamento.getValue());
1044: creditCard.setJurosFinanciamento((Double) jsJurosFinanciamento
1045: .getValue());
1046: creditCard
1047: .setJurosRotativo((Double) jsJurosRotativo.getValue());
1048: if (mtfLimite.getValue() != null
1049: && !(mtfLimite.getValue() instanceof Float)
1050: && !((Double) mtfLimite.getValue()).equals(Double
1051: .valueOf("0.00")))
1052: creditCard.setLimite((Double) mtfLimite.getValue());
1053: if (mtfLimiteExtra.getValue() != null
1054: && !(mtfLimiteExtra.getValue() instanceof Float)
1055: && !((Double) mtfLimiteExtra.getValue()).equals(Double
1056: .valueOf("0.00")))
1057: creditCard.setLimiteExtra((Double) mtfLimiteExtra
1058: .getValue());
1059: creditCard.setNumeroCartao(jftfNumero.getValue().toString());
1060: if (jcbOperadora.getSelectedIndex() > 0) {
1061: try {
1062: creditCard.setOperadora(((Contact) jcbOperadora
1063: .getPersistentObject(jcbOperadora
1064: .getSelectedIndex())).getId());
1065: } catch (Exception e) {
1066: ((SimpleLog) GFPController.getGFPController()
1067: .getContexto().get(GFPController.LOG))
1068: .log("Erro setar operadora do cartao!");
1069: ((SimpleLog) GFPController.getGFPController()
1070: .getContexto().get(GFPController.LOG)).log(e
1071: .getLocalizedMessage());
1072: ((SimpleLog) GFPController.getGFPController()
1073: .getContexto().get(GFPController.LOG)).log(e);
1074: }
1075: }
1076:
1077: if (jcbRealizarDebitoAutomatico.isSelected()) {
1078: try {
1079: creditCard
1080: .setContaDebito(((CheckingAccount) ccDebitoAutomatico
1081: .getPersistentObject(ccDebitoAutomatico
1082: .getSelectedIndex())).getId());
1083: } catch (SQLException e) {
1084: ((SimpleLog) GFPController.getGFPController()
1085: .getContexto().get(GFPController.LOG))
1086: .log("Erro ao setar cnta de débito para cartao de credito!");
1087: ((SimpleLog) GFPController.getGFPController()
1088: .getContexto().get(GFPController.LOG)).log(e
1089: .getLocalizedMessage());
1090: ((SimpleLog) GFPController.getGFPController()
1091: .getContexto().get(GFPController.LOG)).log(e);
1092: }
1093: }
1094: /* TODO Não tratamos plano de fidelidade
1095: if (jcheckTemPlanoFidelidade.isSelected())
1096: {
1097: creditCard.setTemPlanoDeFidelidade(Boolean.TRUE);
1098: creditCard.setQuantoValeCadaPonto((Double)jsQuantoValeCadaPonto.getValue());
1099: }
1100: */
1101: creditCard.setDescricao(telaPrincipal.getTextAreaDescricao()
1102: .getText());
1103: }
1104:
1105: /**
1106: *
1107: */
1108: private void editarCartaoDeCredito() {
1109: if (creditCard == null)
1110: return;
1111:
1112: telaPrincipal.hideRequiredFields();
1113:
1114: if (creditCard.getTemBanco() != null
1115: && creditCard.getTemBanco().booleanValue()) {
1116: jcheckBanco.setSelected(true);
1117: try {
1118: jcbBanco.setSelectedItem(creditCard.getBanco(), "Id");
1119: } catch (SQLException e) {
1120: ((SimpleLog) GFPController.getGFPController()
1121: .getContexto().get(GFPController.LOG))
1122: .log("Erro ao carregar banco do cartao de credito: "
1123: + creditCard);
1124: ((SimpleLog) GFPController.getGFPController()
1125: .getContexto().get(GFPController.LOG)).log(e
1126: .getLocalizedMessage());
1127: ((SimpleLog) GFPController.getGFPController()
1128: .getContexto().get(GFPController.LOG)).log(e);
1129: }
1130: } else {
1131: jcheckBanco.setSelected(false);
1132: jcbBanco.setSelectedIndex(0);
1133: }
1134:
1135: jsDiasParaPagar.setValue(creditCard.getDiasParaPagamento());
1136: jsPagamento.setValue(creditCard.getDataPagamento());
1137: ictfValidade.setDate(creditCard.getDataValidade());
1138: ictfAbertura.setDate(creditCard.getDataAbertura());
1139: ictfFechamento.setDate(creditCard.getDataFechamento());
1140:
1141: if (creditCard.getJurosFinanciamento() != null)
1142: jsJurosFinanciamento.setValue(creditCard
1143: .getJurosFinanciamento());
1144:
1145: if (creditCard.getJurosRotativo() != null)
1146: jsJurosRotativo.setValue(creditCard.getJurosRotativo());
1147:
1148: if (creditCard.getLimite() != null)
1149: mtfLimite.setValue(creditCard.getLimite());
1150: if (creditCard.getLimiteExtra() != null)
1151: mtfLimiteExtra.setValue(creditCard.getLimiteExtra());
1152:
1153: jftfNumero.setValue(creditCard.getNumeroCartao());
1154:
1155: try {
1156: jcbOperadora.setSelectedItem(creditCard.getOperadora(),
1157: "Id");
1158: } catch (SQLException e) {
1159: ((SimpleLog) GFPController.getGFPController().getContexto()
1160: .get(GFPController.LOG))
1161: .log("Erro ao carregar operadora do cartao de credito: "
1162: + creditCard);
1163: ((SimpleLog) GFPController.getGFPController().getContexto()
1164: .get(GFPController.LOG)).log(e
1165: .getLocalizedMessage());
1166: ((SimpleLog) GFPController.getGFPController().getContexto()
1167: .get(GFPController.LOG)).log(e);
1168: }
1169: /* TODO Não tratamos plano de fidelidade
1170: if (creditCard.getTemPlanoDeFidelidade() != null && creditCard.getTemPlanoDeFidelidade().booleanValue())
1171: {
1172: jcheckTemPlanoFidelidade.setSelected(creditCard.getTemPlanoDeFidelidade().booleanValue());
1173: jsQuantoValeCadaPonto.setValue(creditCard.getQuantoValeCadaPonto());
1174: }
1175: */
1176:
1177: if (creditCard.getContaDebito() != null) {
1178: jcbRealizarDebitoAutomatico.setSelected(true);
1179: try {
1180: ccDebitoAutomatico.setSelectedItem(creditCard
1181: .getContaDebito(), "Id");
1182: } catch (SQLException e) {
1183: ((SimpleLog) GFPController.getGFPController()
1184: .getContexto().get(GFPController.LOG))
1185: .log("Erro ao carregar conta de debito automatico do cartao de credito: "
1186: + creditCard);
1187: ((SimpleLog) GFPController.getGFPController()
1188: .getContexto().get(GFPController.LOG)).log(e
1189: .getLocalizedMessage());
1190: ((SimpleLog) GFPController.getGFPController()
1191: .getContexto().get(GFPController.LOG)).log(e);
1192: }
1193: } else {
1194: ccDebitoAutomatico.setSelectedIndex(0);
1195: jcbRealizarDebitoAutomatico.setSelected(false);
1196: }
1197:
1198: telaPrincipal.getTextAreaDescricao().setText(
1199: creditCard.getDescricao());
1200:
1201: telaPrincipal.getPainelBotoes().dadosCarregados(true);
1202: }
1203:
1204: /**
1205: *
1206: */
1207: private void refreshTabelaCartaoCredito() {
1208: try {
1209: jtLancamentos.loadDados();
1210: } catch (Exception e) {
1211: ((SimpleLog) GFPController.getGFPController().getContexto()
1212: .get(GFPController.LOG))
1213: .log("Erro ao atualizar tabela de cartao de credito!");
1214: ((SimpleLog) GFPController.getGFPController().getContexto()
1215: .get(GFPController.LOG)).log(e
1216: .getLocalizedMessage());
1217: ((SimpleLog) GFPController.getGFPController().getContexto()
1218: .get(GFPController.LOG)).log(e);
1219: }
1220: }
1221:
1222: /**
1223: * @param e
1224: */
1225: public void loadFromTable(ListSelectionEvent e) {
1226: if (CreditCardWindow.this .isVisible()) {
1227: try {
1228: creditCard = (CreditCard) jtLancamentos
1229: .getPersistentObject(jtLancamentos
1230: .getSelectedRow());
1231: } catch (SQLException sqle) {
1232: ((SimpleLog) GFPController.getGFPController()
1233: .getContexto().get(GFPController.LOG))
1234: .log("Erro ao carregar cartao da tabela de cartoes de credito!");
1235: ((SimpleLog) GFPController.getGFPController()
1236: .getContexto().get(GFPController.LOG)).log(sqle
1237: .getLocalizedMessage());
1238: ((SimpleLog) GFPController.getGFPController()
1239: .getContexto().get(GFPController.LOG))
1240: .log(sqle);
1241: }
1242: editarCartaoDeCredito();
1243: }
1244: }
1245:
1246: @Override
1247: public void setVisible(boolean aFlag) {
1248: super .setVisible(aFlag);
1249: try {
1250: if (ccDebitoAutomatico != null)
1251: ccDebitoAutomatico.loadDados();
1252: if (jcbOperadora != null)
1253: jcbOperadora.loadDados();
1254: } catch (DAOCreationException e) {
1255: ((SimpleLog) GFPController.getGFPController().getContexto()
1256: .get(GFPController.LOG))
1257: .log("Erro ao carregar dados em combo da tela de cartões!");
1258: ((SimpleLog) GFPController.getGFPController().getContexto()
1259: .get(GFPController.LOG)).log(e
1260: .getLocalizedMessage());
1261: ((SimpleLog) GFPController.getGFPController().getContexto()
1262: .get(GFPController.LOG)).log(e);
1263: } catch (SQLException e) {
1264: ((SimpleLog) GFPController.getGFPController().getContexto()
1265: .get(GFPController.LOG))
1266: .log("Erro ao carregar dados em combo da tela de cartões!");
1267: ((SimpleLog) GFPController.getGFPController().getContexto()
1268: .get(GFPController.LOG)).log(e
1269: .getLocalizedMessage());
1270: ((SimpleLog) GFPController.getGFPController().getContexto()
1271: .get(GFPController.LOG)).log(e);
1272: }
1273: }
1274: }
|