Source Code Cross Referenced for SavingsWindow.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » gfp » windows » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Personal Finance Manager » br.com.gfp.windows 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SavingsWindow.java Criado em 23 de Fevereiro de 2004, 17:21
003:         */
004:
005:        package br.com.gfp.windows;
006:
007:        import java.awt.BorderLayout;
008:        import java.awt.Dimension;
009:        import java.awt.GridBagConstraints;
010:        import java.awt.Insets;
011:        import java.awt.event.ActionEvent;
012:        import java.awt.event.ActionListener;
013:        import java.sql.SQLException;
014:        import java.text.ParseException;
015:        import java.util.HashMap;
016:
017:        import javax.swing.DefaultComboBoxModel;
018:        import javax.swing.JButton;
019:        import javax.swing.JCheckBox;
020:        import javax.swing.JFrame;
021:        import javax.swing.JOptionPane;
022:        import javax.swing.WindowConstants;
023:        import javax.swing.event.InternalFrameEvent;
024:        import javax.swing.event.InternalFrameListener;
025:        import javax.swing.event.ListSelectionEvent;
026:        import javax.swing.event.ListSelectionListener;
027:        import javax.swing.text.DefaultFormatterFactory;
028:        import javax.swing.text.MaskFormatter;
029:
030:        import br.com.gfp.actions.AbrirTelaParaInsercaoAction;
031:        import br.com.gfp.dao.AccountSavingDAO;
032:        import br.com.gfp.dao.GFPController;
033:        import br.com.gfp.data.AccountSaving;
034:        import br.com.gfp.data.Bank;
035:        import br.com.gfp.internationalization.ErrosDeDadosMessages;
036:        import br.com.gfp.internationalization.TelaAplicacaoMessages;
037:        import br.com.gfp.reports.ReportFactory;
038:        import br.com.gfp.util.SimpleLog;
039:        import br.com.gfp.windows.componentes.GFPHeaderRenderer;
040:        import br.com.gfp.windows.componentes.GFPTableCellRenderer;
041:        import br.com.gfpshare.beans.DBComboBox;
042:        import br.com.gfpshare.beans.GeneralEventHandler;
043:        import br.com.gfpshare.beans.ZCalendarTextField;
044:        import br.com.gfpshare.beans.ZComboBox;
045:        import br.com.gfpshare.beans.ZFormattedTextField;
046:        import br.com.gfpshare.beans.ZLabel;
047:        import br.com.gfpshare.beans.ZMoneyTextField;
048:        import br.com.gfpshare.beans.aplicativos.IconeFactory;
049:        import br.com.gfpshare.beans.aplicativos.PainelTelaBasica;
050:        import br.com.gfpshare.beans.table.DBTable;
051:        import br.com.gfpshare.db.DAOCreationException;
052:        import br.com.gfpshare.db.DAOListener;
053:
054:        /**
055:         * @author Igor Regis da Silva Simoes
056:         */
057:        public class SavingsWindow extends GFPInternalFrame<AccountSaving> {
058:
059:            private JFrame owner = null;
060:
061:            private AccountSaving accountSaving = null;
062:
063:            private ZCalendarTextField ictfAbertura;
064:
065:            private ZCalendarTextField ictfFechamento;
066:
067:            private JButton jbConfigurar;
068:
069:            private DBComboBox jcbBanco;
070:
071:            private ZComboBox jcbRendimento;
072:
073:            private JCheckBox jcbResgateAutomatico;
074:
075:            private ZFormattedTextField jftfAgencia;
076:
077:            private ZFormattedTextField jftfNumero;
078:
079:            private ZLabel jlAbertura;
080:
081:            private ZLabel jlAgencia;
082:
083:            private ZLabel jlBanco;
084:
085:            private ZLabel jlFechamento;
086:
087:            private ZLabel jlNumero;
088:
089:            private ZLabel jlRendimento;
090:
091:            private ZLabel jlSaldoInicial;
092:
093:            private ZLabel jlValorMinimoResgateAutomatico;
094:
095:            private DBTable jtLancamentos;
096:
097:            private ZMoneyTextField mtfSaldoInicial;
098:
099:            private ZMoneyTextField mtfValorMinimoResgateAutomatico;
100:
101:            private PainelTelaBasica telaPrincipal;
102:
103:            /**
104:             * Cria um novo form TelaCadastroContas
105:             * 
106:             * @param owner
107:             */
108:            public SavingsWindow(JFrame owner) {
109:                controller = new AccountSavingDAO();
110:                this .owner = owner;
111:                initComponents();
112:                setSize(700, 450);
113:            }
114:
115:            public SavingsWindow(JFrame owner,
116:                    DAOListener<AccountSaving> listener) {
117:                this (owner);
118:                setListener(listener);
119:            }
120:
121:            /**
122:             * 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
123:             * regenerated by the Form Editor.
124:             */
125:            private void initComponents() {
126:                setClosable(true);
127:                setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
128:                setIconifiable(true);
129:                setMaximizable(true);
130:                setResizable(true);
131:                setTitle(TelaAplicacaoMessages.getMessages().getString(
132:                        "aplicacao")); //$NON-NLS-1$
133:                setFrameIcon(IconeFactory.getIconeFactory().getImageIcon(
134:                        IconeFactory.APLICACAO_PEQUENA));
135:
136:                addInternalFrameListener((InternalFrameListener) GeneralEventHandler
137:                        .makeProxy(
138:                                this ,
139:                                "telaAplicacaoFechada", InternalFrameListener.class, "internalFrameClosed")); //$NON-NLS-1$ //$NON-NLS-2$
140:
141:                GridBagConstraints gridBagConstraints;
142:
143:                jtLancamentos = new DBTable(new AccountSaving(),
144:                        new GFPHeaderRenderer());
145:                jtLancamentos.hideColumn("TipoConta"); //$NON-NLS-1$
146:                jtLancamentos.hideColumn("EhDeSistema"); //$NON-NLS-1$
147:                jtLancamentos.hideColumn("Id"); //$NON-NLS-1$
148:                //jtLancamentos.hideColumn("UsarCotas"); //$NON-NLS-1$
149:
150:                jtLancamentos.getColumn(jtLancamentos.getColumnName(2))
151:                        .setMaxWidth(90);
152:                jtLancamentos.getColumn(jtLancamentos.getColumnName(2))
153:                        .setMinWidth(90);
154:
155:                jtLancamentos.getColumn(jtLancamentos.getColumnName(3))
156:                        .setMaxWidth(50);
157:                jtLancamentos.getColumn(jtLancamentos.getColumnName(3))
158:                        .setMinWidth(50);
159:
160:                jtLancamentos.getColumn(jtLancamentos.getColumnName(4))
161:                        .setMaxWidth(75);
162:                jtLancamentos.getColumn(jtLancamentos.getColumnName(4))
163:                        .setMinWidth(75);
164:
165:                jtLancamentos.getColumn(jtLancamentos.getColumnName(5))
166:                        .setMaxWidth(75);
167:                jtLancamentos.getColumn(jtLancamentos.getColumnName(5))
168:                        .setMinWidth(75);
169:
170:                jtLancamentos
171:                        .getColumn(jtLancamentos.getColumnName(2))
172:                        .setCellRenderer(
173:                                new GFPTableCellRenderer(
174:                                        GFPTableCellRenderer.NUMERO_CONTA_CORRENTE,
175:                                        -1));
176:                jtLancamentos
177:                        .getColumn(jtLancamentos.getColumnName(3))
178:                        .setCellRenderer(
179:                                new GFPTableCellRenderer(
180:                                        GFPTableCellRenderer.NUMERO_AGENCIA, -1));
181:                jtLancamentos.getColumn(jtLancamentos.getColumnName(6))
182:                        .setCellRenderer(
183:                                new GFPTableCellRenderer(
184:                                        GFPTableCellRenderer.BANCO, -1));
185:                jtLancamentos
186:                        .getColumn(jtLancamentos.getColumnName(9))
187:                        .setCellRenderer(
188:                                new GFPTableCellRenderer(
189:                                        GFPTableCellRenderer.TIPO_DE_RENDIMENTO,
190:                                        -1));
191:
192:                jtLancamentos
193:                        .getSelectionModel()
194:                        .addListSelectionListener(
195:                                (ListSelectionListener) GeneralEventHandler
196:                                        .makeProxy(
197:                                                this ,
198:                                                "loadFromTable", ListSelectionListener.class, "valueChanged")); //$NON-NLS-1$ //$NON-NLS-2$
199:
200:                telaPrincipal = new PainelTelaBasica();
201:                telaPrincipal.setJtDados(jtLancamentos);
202:                telaPrincipal.setHorizontalDividerLocation(226);
203:                telaPrincipal.addPrintButtonListener(new PrintListener());
204:
205:                jlNumero = new ZLabel();
206:                jftfNumero = new ZFormattedTextField();
207:                jlAgencia = new ZLabel();
208:                jftfAgencia = new ZFormattedTextField();
209:                jlBanco = new ZLabel();
210:                jlAbertura = new ZLabel();
211:                jlFechamento = new ZLabel();
212:                jlSaldoInicial = new ZLabel();
213:                jlRendimento = new ZLabel();
214:                jcbRendimento = new ZComboBox();
215:                jcbRendimento.addItem(""); //$NON-NLS-1$
216:                mtfSaldoInicial = new ZMoneyTextField(owner);
217:                ictfAbertura = new ZCalendarTextField();
218:                ictfFechamento = new ZCalendarTextField();
219:                mtfValorMinimoResgateAutomatico = new ZMoneyTextField(owner);
220:                jlValorMinimoResgateAutomatico = new ZLabel();
221:                jcbResgateAutomatico = new JCheckBox();
222:                jcbBanco = new DBComboBox(new Bank());
223:                jbConfigurar = new JButton();
224:
225:                try {
226:                    MaskFormatter formato = new MaskFormatter(
227:                            TelaAplicacaoMessages.getMessages().getString(
228:                                    "mascaraConta")); //$NON-NLS-1$
229:                    formato.setValidCharacters(TelaAplicacaoMessages
230:                            .getMessages().getString("caracteresValidosConta")); //$NON-NLS-1$
231:                    formato.setPlaceholderCharacter('0');
232:                    formato.setValueContainsLiteralCharacters(false);
233:                    jftfNumero.setFormatterFactory(new DefaultFormatterFactory(
234:                            formato));
235:                } catch (ParseException e) {
236:                    ((SimpleLog) GFPController.getGFPController().getContexto()
237:                            .get(GFPController.LOG))
238:                            .log("Erro ao aplicar mascara para umero de conta corrente!");
239:                    ((SimpleLog) GFPController.getGFPController().getContexto()
240:                            .get(GFPController.LOG)).log(e
241:                            .getLocalizedMessage());
242:                    ((SimpleLog) GFPController.getGFPController().getContexto()
243:                            .get(GFPController.LOG)).log(e);
244:                }
245:                jftfNumero.setMinimumSize(new Dimension(100, 20));
246:                jftfNumero.setPreferredSize(new Dimension(100, 20));
247:                jftfNumero.setToolTipText(TelaAplicacaoMessages.getMessages()
248:                        .getString("CodigoToolTip"));
249:                gridBagConstraints = new GridBagConstraints();
250:                gridBagConstraints.gridx = 1;
251:                gridBagConstraints.gridy = 1;
252:                gridBagConstraints.gridwidth = 2;
253:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
254:                gridBagConstraints.anchor = GridBagConstraints.WEST;
255:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
256:                telaPrincipal.addComponent(jftfNumero, gridBagConstraints,
257:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
258:
259:                jlNumero.setText(TelaAplicacaoMessages.getMessages().getString(
260:                        "codigo")); //$NON-NLS-1$
261:                jlNumero.setDisplayedMnemonic(TelaAplicacaoMessages
262:                        .getMessages().getString("CodigoMnemonic").charAt(0));
263:                jlNumero.setRequiredField(jftfNumero);
264:                jlNumero.setValidationNotNull(true);
265:                gridBagConstraints = new GridBagConstraints();
266:                gridBagConstraints.gridx = 0;
267:                gridBagConstraints.gridy = 1;
268:                gridBagConstraints.anchor = GridBagConstraints.WEST;
269:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
270:                telaPrincipal.addComponent(jlNumero, gridBagConstraints,
271:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
272:
273:                try {
274:                    MaskFormatter formato = new MaskFormatter(
275:                            TelaAplicacaoMessages.getMessages().getString(
276:                                    "mascaraAgencia")); //$NON-NLS-1$
277:                    formato.setValidCharacters(TelaAplicacaoMessages
278:                            .getMessages()
279:                            .getString("caracteresValidosAgencia")); //$NON-NLS-1$
280:                    formato.setPlaceholderCharacter('0');
281:                    formato.setValueContainsLiteralCharacters(false);
282:                    jftfAgencia
283:                            .setFormatterFactory(new DefaultFormatterFactory(
284:                                    formato));
285:                } catch (ParseException e) {
286:                    ((SimpleLog) GFPController.getGFPController().getContexto()
287:                            .get(GFPController.LOG))
288:                            .log("Erro ao aplicar mascara para numero de agencia!");
289:                    ((SimpleLog) GFPController.getGFPController().getContexto()
290:                            .get(GFPController.LOG)).log(e
291:                            .getLocalizedMessage());
292:                    ((SimpleLog) GFPController.getGFPController().getContexto()
293:                            .get(GFPController.LOG)).log(e);
294:                }
295:                jftfAgencia.setMinimumSize(new Dimension(120, 20));
296:                jftfAgencia.setPreferredSize(new Dimension(70, 20));
297:                jftfAgencia.setToolTipText(TelaAplicacaoMessages.getMessages()
298:                        .getString("AgenciaToolTip"));
299:                gridBagConstraints = new GridBagConstraints();
300:                gridBagConstraints.gridx = 4;
301:                gridBagConstraints.gridy = 1;
302:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
303:                gridBagConstraints.anchor = GridBagConstraints.WEST;
304:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
305:                telaPrincipal.addComponent(jftfAgencia, gridBagConstraints,
306:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
307:
308:                jlAgencia.setText(TelaAplicacaoMessages.getMessages()
309:                        .getString("agencia")); //$NON-NLS-1$
310:                jlAgencia.setDisplayedMnemonic(TelaAplicacaoMessages
311:                        .getMessages().getString("AgenciaMnemonic").charAt(0));
312:                jlAgencia.setRequiredField(jftfAgencia);
313:                jlAgencia.setValidationNotNull(true);
314:                gridBagConstraints = new GridBagConstraints();
315:                gridBagConstraints.gridx = 3;
316:                gridBagConstraints.gridy = 1;
317:                gridBagConstraints.anchor = GridBagConstraints.WEST;
318:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
319:                telaPrincipal.addComponent(jlAgencia, gridBagConstraints,
320:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
321:
322:                jlBanco.setText(TelaAplicacaoMessages.getMessages().getString(
323:                        "banco")); //$NON-NLS-1$
324:                jlBanco.setDisplayedMnemonic(TelaAplicacaoMessages
325:                        .getMessages().getString("BancoMnemonic").charAt(0));
326:                jlBanco.setRequiredField(jcbBanco);
327:                jlBanco.setValidationNotNull(true);
328:                gridBagConstraints = new GridBagConstraints();
329:                gridBagConstraints.gridx = 0;
330:                gridBagConstraints.gridy = 0;
331:                gridBagConstraints.anchor = GridBagConstraints.WEST;
332:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
333:                telaPrincipal.addComponent(jlBanco, gridBagConstraints,
334:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
335:
336:                jlAbertura.setText(TelaAplicacaoMessages.getMessages()
337:                        .getString("abertura")); //$NON-NLS-1$
338:                jlAbertura.setDisplayedMnemonic(TelaAplicacaoMessages
339:                        .getMessages().getString("AberturaMnemonic").charAt(0));
340:                jlAbertura.setRequiredField(ictfAbertura);
341:                jlAbertura.setValidationNotNull(true);
342:                gridBagConstraints = new GridBagConstraints();
343:                gridBagConstraints.gridx = 0;
344:                gridBagConstraints.gridy = 2;
345:                gridBagConstraints.anchor = GridBagConstraints.WEST;
346:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
347:                telaPrincipal.addComponent(jlAbertura, gridBagConstraints,
348:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
349:
350:                jlFechamento.setText(TelaAplicacaoMessages.getMessages()
351:                        .getString("fechamento")); //$NON-NLS-1$
352:                jlFechamento.setDisplayedMnemonic(TelaAplicacaoMessages
353:                        .getMessages().getString("FechamentoMnemonic")
354:                        .charAt(0));
355:                jlFechamento.setLabelFor(ictfFechamento);
356:                gridBagConstraints = new GridBagConstraints();
357:                gridBagConstraints.gridx = 0;
358:                gridBagConstraints.gridy = 3;
359:                gridBagConstraints.anchor = GridBagConstraints.WEST;
360:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
361:                telaPrincipal.addComponent(jlFechamento, gridBagConstraints,
362:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
363:
364:                jlSaldoInicial.setText(TelaAplicacaoMessages.getMessages()
365:                        .getString("saldoInicial")); //$NON-NLS-1$
366:                jlSaldoInicial.setDisplayedMnemonic(TelaAplicacaoMessages
367:                        .getMessages().getString("SaldoInicialMnemonic")
368:                        .charAt(0));
369:                jlSaldoInicial.setLabelFor(mtfSaldoInicial);
370:                gridBagConstraints = new GridBagConstraints();
371:                gridBagConstraints.gridx = 3;
372:                gridBagConstraints.gridy = 2;
373:                gridBagConstraints.anchor = GridBagConstraints.WEST;
374:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
375:                telaPrincipal.addComponent(jlSaldoInicial, gridBagConstraints,
376:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
377:
378:                jlRendimento.setText(TelaAplicacaoMessages.getMessages()
379:                        .getString("rendimento")); //$NON-NLS-1$
380:                jlRendimento.setDisplayedMnemonic(TelaAplicacaoMessages
381:                        .getMessages().getString("RendimentoMnemonic")
382:                        .charAt(0));
383:                jlRendimento.setRequiredField(jcbRendimento);
384:                jlRendimento.setValidationNotNull(true);
385:                gridBagConstraints = new GridBagConstraints();
386:                gridBagConstraints.gridx = 3;
387:                gridBagConstraints.gridy = 3;
388:                gridBagConstraints.anchor = GridBagConstraints.WEST;
389:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
390:                telaPrincipal.addComponent(jlRendimento, gridBagConstraints,
391:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
392:
393:                jcbRendimento
394:                        .setModel(new DefaultComboBoxModel(
395:                                new String[] {
396:                                        "", TelaAplicacaoMessages.getMessages().getString("diario"), TelaAplicacaoMessages.getMessages().getString("mensal"), TelaAplicacaoMessages.getMessages().getString("anual") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
397:                jcbRendimento.setToolTipText(TelaAplicacaoMessages
398:                        .getMessages().getString("RendimentoToolTip"));
399:                gridBagConstraints = new GridBagConstraints();
400:                gridBagConstraints.gridx = 4;
401:                gridBagConstraints.gridy = 3;
402:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
403:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
404:                telaPrincipal.addComponent(jcbRendimento, gridBagConstraints,
405:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
406:
407:                mtfSaldoInicial.setMinimumSize(new Dimension(100, 20));
408:                mtfSaldoInicial.setPreferredSize(new Dimension(100, 20));
409:                mtfSaldoInicial.setToolTipText(TelaAplicacaoMessages
410:                        .getMessages().getString("SaldoInicialToolTip"));
411:                gridBagConstraints = new GridBagConstraints();
412:                gridBagConstraints.gridx = 4;
413:                gridBagConstraints.gridy = 2;
414:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
415:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
416:                telaPrincipal.addComponent(mtfSaldoInicial, gridBagConstraints,
417:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
418:
419:                ictfAbertura.setMinimumSize(new Dimension(100, 26));
420:                ictfAbertura.setToolTipText(TelaAplicacaoMessages.getMessages()
421:                        .getString("AberturaToolTip"));
422:                gridBagConstraints = new GridBagConstraints();
423:                gridBagConstraints.gridx = 1;
424:                gridBagConstraints.gridy = 2;
425:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
426:                telaPrincipal.addComponent(ictfAbertura, gridBagConstraints,
427:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
428:
429:                ictfFechamento.setMinimumSize(new Dimension(100, 26));
430:                ictfFechamento.setToolTipText(TelaAplicacaoMessages
431:                        .getMessages().getString("FechamentoToolTip"));
432:                gridBagConstraints = new GridBagConstraints();
433:                gridBagConstraints.gridx = 1;
434:                gridBagConstraints.gridy = 3;
435:                telaPrincipal.addComponent(ictfFechamento, gridBagConstraints,
436:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
437:
438:                mtfValorMinimoResgateAutomatico.setMinimumSize(new Dimension(
439:                        100, 20));
440:                mtfValorMinimoResgateAutomatico.setPreferredSize(new Dimension(
441:                        100, 20));
442:                mtfValorMinimoResgateAutomatico
443:                        .setToolTipText(TelaAplicacaoMessages.getMessages()
444:                                .getString("VrResgateMinimoToolTip"));
445:                gridBagConstraints = new GridBagConstraints();
446:                gridBagConstraints.gridx = 4;
447:                gridBagConstraints.gridy = 4;
448:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
449:                gridBagConstraints.anchor = GridBagConstraints.WEST;
450:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
451:                telaPrincipal.addComponent(mtfValorMinimoResgateAutomatico,
452:                        gridBagConstraints,
453:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
454:
455:                jlValorMinimoResgateAutomatico.setText(TelaAplicacaoMessages
456:                        .getMessages().getString("vrMinimoMovimento")); //$NON-NLS-1$
457:                jlValorMinimoResgateAutomatico
458:                        .setDisplayedMnemonic(TelaAplicacaoMessages
459:                                .getMessages().getString(
460:                                        "vrMinimoMovimentoMnemonic").charAt(0));
461:                jlValorMinimoResgateAutomatico
462:                        .setLabelFor(mtfValorMinimoResgateAutomatico);
463:                jlValorMinimoResgateAutomatico.setPreferredSize(new Dimension(
464:                        150, 24));
465:                gridBagConstraints = new GridBagConstraints();
466:                gridBagConstraints.gridx = 3;
467:                gridBagConstraints.gridy = 4;
468:                gridBagConstraints.anchor = GridBagConstraints.WEST;
469:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
470:                telaPrincipal.addComponent(jlValorMinimoResgateAutomatico,
471:                        gridBagConstraints,
472:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
473:
474:                jcbResgateAutomatico.setText(TelaAplicacaoMessages
475:                        .getMessages().getString("resgateAutomatico")); //$NON-NLS-1$
476:                jcbResgateAutomatico.setMnemonic(TelaAplicacaoMessages
477:                        .getMessages().getString("ResgateAutomaticoMnemonic")
478:                        .charAt(0));
479:                gridBagConstraints = new GridBagConstraints();
480:                gridBagConstraints.gridx = 0;
481:                gridBagConstraints.gridy = 4;
482:                gridBagConstraints.gridwidth = 2;
483:                gridBagConstraints.anchor = GridBagConstraints.WEST;
484:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
485:                telaPrincipal.addComponent(jcbResgateAutomatico,
486:                        gridBagConstraints,
487:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
488:
489:                jcbBanco.setToolTipText(TelaAplicacaoMessages.getMessages()
490:                        .getString("BancoToolTip"));
491:                jcbBanco.setInsertNewListener(AbrirTelaParaInsercaoAction
492:                        .getAction(), BankWindow.class.getName());
493:                gridBagConstraints = new GridBagConstraints();
494:                gridBagConstraints.gridx = 1;
495:                gridBagConstraints.gridy = 0;
496:                gridBagConstraints.gridwidth = 4;
497:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
498:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
499:                telaPrincipal.addComponent(jcbBanco, gridBagConstraints,
500:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
501:
502:                jbConfigurar
503:                        .setIcon(IconeFactory.getIconeFactory().getImageIcon(
504:                                IconeFactory.CONFIGURA_APLICACAO_PEQUENA));
505:                jbConfigurar.setMnemonic(TelaAplicacaoMessages.getMessages()
506:                        .getString("ConfigurarMnemonic").charAt(0));
507:                jbConfigurar.setToolTipText(TelaAplicacaoMessages.getMessages()
508:                        .getString("ConfigurarToolTip"));
509:                jbConfigurar.setText(TelaAplicacaoMessages.getMessages()
510:                        .getString("configurar"));
511:                jbConfigurar.setActionCommand("configurar");
512:
513:                gridBagConstraints = new GridBagConstraints();
514:                gridBagConstraints.gridx = 0;
515:                gridBagConstraints.gridy = 7;
516:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
517:                gridBagConstraints.anchor = GridBagConstraints.NORTH;
518:                gridBagConstraints.weighty = 1.0;
519:                telaPrincipal.getPainelBotoes().add(jbConfigurar);
520:
521:                telaPrincipal.setDescricaoRequired(true, null);
522:                telaPrincipal.getPainelBotoes().addActionListener(
523:                        "salvar",
524:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
525:                                "salvar", ActionListener.class,
526:                                "actionPerformed"));
527:                telaPrincipal.getPainelBotoes().addActionListener(
528:                        "atualizar",
529:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
530:                                "atualizar", ActionListener.class,
531:                                "actionPerformed"));
532:                telaPrincipal.getPainelBotoes().addActionListener(
533:                        "novo",
534:                        (ActionListener) GeneralEventHandler
535:                                .makeProxy(this , "novo", ActionListener.class,
536:                                        "actionPerformed"));
537:                telaPrincipal.getPainelBotoes().addActionListener(
538:                        "excluir",
539:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
540:                                "excluir", ActionListener.class,
541:                                "actionPerformed"));
542:                telaPrincipal.getPainelBotoes().addActionListener(
543:                        "pesquisar",
544:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
545:                                "pesquisar", ActionListener.class,
546:                                "actionPerformed"));
547:                telaPrincipal.getPainelBotoes().addActionListener(
548:                        "limpar",
549:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
550:                                "limpar", ActionListener.class,
551:                                "actionPerformed"));
552:                telaPrincipal.getPainelBotoes().addActionListener(
553:                        "configurar",
554:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
555:                                "configurar", ActionListener.class,
556:                                "actionPerformed"));
557:                telaPrincipal.getPainelBotoes().addActionListener(
558:                        "filtrar",
559:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
560:                                "filtrar", ActionListener.class,
561:                                "actionPerformed"));
562:
563:                getContentPane().add(telaPrincipal, BorderLayout.CENTER);
564:
565:                pack();
566:                limpar(null);
567:            }
568:
569:            private class PrintListener implements  ActionListener {
570:                public void actionPerformed(final ActionEvent e) {
571:                    ((JButton) e.getSource()).setEnabled(false);
572:                    (new Thread() {
573:                        {
574:                            setPriority(Thread.MIN_PRIORITY);
575:                            setDaemon(true);
576:                        }
577:
578:                        @Override
579:                        public void run() {
580:                            try {
581:                                ReportFactory.makeReport("Aplicacoes",
582:                                        new HashMap());
583:                            } catch (Exception e) {
584:                                ((SimpleLog) GFPController.getGFPController()
585:                                        .getContexto().get(GFPController.LOG))
586:                                        .log("Erro ao gerar relatório de accoutSaving!");
587:                                ((SimpleLog) GFPController.getGFPController()
588:                                        .getContexto().get(GFPController.LOG))
589:                                        .log(e.getLocalizedMessage());
590:                                ((SimpleLog) GFPController.getGFPController()
591:                                        .getContexto().get(GFPController.LOG))
592:                                        .log(e);
593:                            } finally {
594:                                ((JButton) e.getSource()).setEnabled(true);
595:                            }
596:                        }
597:                    }).start();
598:                }
599:            }
600:
601:            /**
602:             * @param e
603:             */
604:            public void atualizar(ActionEvent e) {
605:                refreshTabelaAplicacoes();
606:            }
607:
608:            /**
609:             * @param e
610:             */
611:            public void pesquisar(ActionEvent e) {
612:                if (accountSaving == null)
613:                    accountSaving = new AccountSaving((Double) mtfSaldoInicial
614:                            .getValue());
615:                loadAplicacao();
616:                try {
617:                    accountSaving = controller.getBy(accountSaving);
618:                } catch (SQLException sqle) {
619:                    accountSaving = null;
620:                    ((SimpleLog) GFPController.getGFPController().getContexto()
621:                            .get(GFPController.LOG))
622:                            .log("Erro ao realizar pesquisa por accoutSaving!");
623:                    ((SimpleLog) GFPController.getGFPController().getContexto()
624:                            .get(GFPController.LOG)).log(sqle
625:                            .getLocalizedMessage());
626:                    ((SimpleLog) GFPController.getGFPController().getContexto()
627:                            .get(GFPController.LOG)).log(sqle);
628:                }
629:                editarAplicacao();
630:            }
631:
632:            /**
633:             * @param e
634:             */
635:            public void excluir(ActionEvent e) {
636:                if (accountSaving == null) {
637:                    JOptionPane.showMessageDialog(this , TelaAplicacaoMessages
638:                            .getMessages().getString(
639:                                    "semDadosSelecionadosParaExcluir")); //$NON-NLS-1$
640:                    return;
641:                }
642:
643:                loadAplicacao();
644:
645:                try {
646:                    controller.deletar(accountSaving);
647:                } catch (SQLException sqle) {
648:                    ((SimpleLog) GFPController.getGFPController().getContexto()
649:                            .get(GFPController.LOG))
650:                            .log("Erro ao excluir accoutSaving!");
651:                    ((SimpleLog) GFPController.getGFPController().getContexto()
652:                            .get(GFPController.LOG)).log(sqle
653:                            .getLocalizedMessage());
654:                    ((SimpleLog) GFPController.getGFPController().getContexto()
655:                            .get(GFPController.LOG)).log(sqle);
656:                }
657:                accountSaving = null;
658:                refreshTabelaAplicacoes();
659:            }
660:
661:            /**
662:             * @param e
663:             */
664:            public void salvar(ActionEvent e) {
665:                if (accountSaving == null) {//Todo Rever Mensagem
666:                    JOptionPane.showMessageDialog(this , TelaAplicacaoMessages
667:                            .getMessages().getString("semDadosParaSalvar")); //$NON-NLS-1$
668:                    return;
669:                }
670:                loadAplicacao();
671:                if (controller.isAdicionandoNovo()) {
672:                    try {
673:                        controller.adicionarNovo(accountSaving);
674:                    } catch (SQLException sqle) {
675:                        JOptionPane.showMessageDialog(this , sqle.getMessage(),
676:                                ErrosDeDadosMessages.getMessages().getString(
677:                                        "MessageTitle"),
678:                                JOptionPane.WARNING_MESSAGE);
679:                        telaPrincipal.getPainelBotoes().setOcorreuErro(true);
680:                        return;
681:                    }
682:                    close();
683:                    controller.setAdicionandoNovo(false);
684:                } else {
685:                    try {
686:                        controller.atualizar(accountSaving);
687:                    } catch (SQLException sqle) {
688:                        JOptionPane.showMessageDialog(this , sqle.getMessage(),
689:                                ErrosDeDadosMessages.getMessages().getString(
690:                                        "MessageTitle"),
691:                                JOptionPane.WARNING_MESSAGE);
692:                        telaPrincipal.getPainelBotoes().setOcorreuErro(true);
693:                        return;
694:                    }
695:                }
696:                accountSaving = null;
697:                refreshTabelaAplicacoes();
698:            }
699:
700:            /**
701:             * @param e
702:             */
703:            public void novo(ActionEvent e) {
704:                accountSaving = new AccountSaving((Double) mtfSaldoInicial
705:                        .getValue());
706:                controller.setAdicionandoNovo(true);
707:            }
708:
709:            /**
710:             * @param evt
711:             */
712:            public void configurar(ActionEvent evt) {
713:                if (accountSaving != null)
714:                    GFPController.getGFPController().create(
715:                            ConfigureSavingsWindow.class,
716:                            new Object[] { accountSaving.getId(),
717:                                    accountSaving.getTipoConta(),
718:                                    accountSaving.getTipoRendimento() });
719:                else {
720:                    JOptionPane.showMessageDialog(this , TelaAplicacaoMessages
721:                            .getMessages().getString("selecionaUmaAplicacao")); //$NON-NLS-1$
722:                }
723:            }
724:
725:            /**
726:             * @param e
727:             */
728:            public void telaAplicacaoFechada(InternalFrameEvent e) {
729:                GFPController.getGFPController().removeTela(this );
730:            }
731:
732:            /**
733:             * @param e
734:             */
735:            public void limpar(ActionEvent e) {
736:                telaPrincipal.showRequiredFields();
737:                accountSaving = null;
738:                ictfAbertura.setDate(null);
739:                ictfFechamento.setDate(null);
740:                jcbBanco.setSelectedIndex(0);
741:                jcbRendimento.setSelectedIndex(0);
742:                jftfAgencia.setValue(null);
743:                jftfNumero.setValue(null);
744:                telaPrincipal.getTextAreaDescricao().setText(""); //$NON-NLS-1$
745:                mtfSaldoInicial.setValue(new Double(0.00));
746:                mtfValorMinimoResgateAutomatico.setValue(new Double(0.00));
747:                jcbResgateAutomatico.setSelected(false);
748:                telaPrincipal.getPainelBotoes().dadosCarregados(false);
749:            }
750:
751:            /**
752:             * @param e
753:             */
754:            public void filtrar(ActionEvent e) {
755:                accountSaving = new AccountSaving();
756:                loadAplicacao();
757:
758:                jtLancamentos.setDataType(accountSaving);
759:                try {
760:                    jtLancamentos.filter();
761:                } catch (Exception e1) {
762:                    ((SimpleLog) GFPController.getGFPController().getContexto()
763:                            .get(GFPController.LOG))
764:                            .log("Erro ao filtrar dados da tabela de aplicacoes!");
765:                    ((SimpleLog) GFPController.getGFPController().getContexto()
766:                            .get(GFPController.LOG)).log(e1
767:                            .getLocalizedMessage());
768:                    ((SimpleLog) GFPController.getGFPController().getContexto()
769:                            .get(GFPController.LOG)).log(e1);
770:                }
771:            }
772:
773:            /**
774:             *
775:             */
776:            private void loadAplicacao() {
777:                accountSaving
778:                        .setNumeroConta(jftfNumero.getValue() != null ? jftfNumero
779:                                .getValue().toString()
780:                                : null);
781:                accountSaving
782:                        .setNumeroAgencia(jftfAgencia.getValue() != null ? jftfAgencia
783:                                .getValue().toString()
784:                                : null);
785:                accountSaving.setDataAbertura(ictfAbertura.getDate());
786:                accountSaving.setDataFechamento(ictfFechamento.getDate());
787:
788:                if (jcbBanco.getSelectedIndex() > 0)
789:                    try {
790:                        accountSaving.setBanco((Integer) jcbBanco.getDataAt(
791:                                jcbBanco.getSelectedIndex()).get("Id")); //$NON-NLS-1$
792:                    } catch (Exception e) {
793:                        ((SimpleLog) GFPController.getGFPController()
794:                                .getContexto().get(GFPController.LOG))
795:                                .log("Erro ao setar banco para accoutSaving!");
796:                        ((SimpleLog) GFPController.getGFPController()
797:                                .getContexto().get(GFPController.LOG)).log(e
798:                                .getLocalizedMessage());
799:                        ((SimpleLog) GFPController.getGFPController()
800:                                .getContexto().get(GFPController.LOG)).log(e);
801:                    }
802:                if (!((Double) mtfSaldoInicial.getValue()).equals(Double
803:                        .valueOf("0.00")))
804:                    accountSaving.setSaldoInicial((Double) mtfSaldoInicial
805:                            .getValue());
806:                accountSaving.setDescricao(telaPrincipal.getTextAreaDescricao()
807:                        .getText());
808:
809:                if (jcbRendimento.getSelectedIndex() > 0)
810:                    try {
811:                        accountSaving.setTipoRendimento(new Integer(
812:                                jcbRendimento.getSelectedIndex()));
813:                    } catch (Exception e) {
814:                        ((SimpleLog) GFPController.getGFPController()
815:                                .getContexto().get(GFPController.LOG))
816:                                .log("Erro ao setar tipo de rendimento para accoutSaving!");
817:                        ((SimpleLog) GFPController.getGFPController()
818:                                .getContexto().get(GFPController.LOG)).log(e
819:                                .getLocalizedMessage());
820:                        ((SimpleLog) GFPController.getGFPController()
821:                                .getContexto().get(GFPController.LOG)).log(e);
822:                    }
823:                accountSaving.setResgateAutomatico(new Boolean(
824:                        jcbResgateAutomatico.isSelected()));
825:                if (mtfValorMinimoResgateAutomatico.getValue() != null
826:                        && !((Double) mtfValorMinimoResgateAutomatico
827:                                .getValue()).equals(Double.valueOf("0.00")))
828:                    accountSaving
829:                            .setValorMinimoMovimentacao((Double) mtfValorMinimoResgateAutomatico
830:                                    .getValue());
831:            }
832:
833:            /**
834:             *
835:             */
836:            private void editarAplicacao() {
837:                telaPrincipal.hideRequiredFields();
838:                if (accountSaving != null && jftfNumero != null) {
839:                    jftfNumero.setValue(accountSaving.getNumeroConta());
840:                    jftfAgencia.setValue(accountSaving.getNumeroAgencia());
841:                    ictfAbertura.setDate(accountSaving.getDataAbertura());
842:                    ictfFechamento.setDate(accountSaving.getDataFechamento());
843:
844:                    try {
845:                        jcbBanco
846:                                .setSelectedItem(accountSaving.getBanco(), "Id"); //$NON-NLS-1$
847:                    } catch (SQLException e) {
848:                        ((SimpleLog) GFPController.getGFPController()
849:                                .getContexto().get(GFPController.LOG))
850:                                .log("Erro ao recuperar banco da accoutSaving!");
851:                        ((SimpleLog) GFPController.getGFPController()
852:                                .getContexto().get(GFPController.LOG)).log(e
853:                                .getLocalizedMessage());
854:                        ((SimpleLog) GFPController.getGFPController()
855:                                .getContexto().get(GFPController.LOG)).log(e);
856:                    }
857:
858:                    mtfSaldoInicial.setValue(accountSaving.getSaldoInicial());
859:                    telaPrincipal.getTextAreaDescricao().setText(
860:                            accountSaving.getDescricao());
861:
862:                    jcbRendimento.setSelectedIndex(accountSaving
863:                            .getTipoRendimento().intValue());
864:                    if (accountSaving.getResgateAutomatico() != null)
865:                        jcbResgateAutomatico.setSelected(accountSaving
866:                                .getResgateAutomatico().booleanValue());
867:                    mtfValorMinimoResgateAutomatico.setValue(accountSaving
868:                            .getValorMinimoMovimentacao());
869:
870:                    telaPrincipal.getPainelBotoes().dadosCarregados(true);
871:                }
872:            }
873:
874:            /**
875:             *
876:             */
877:            private void refreshTabelaAplicacoes() {
878:                if (SavingsWindow.this .isVisible()) {
879:                    try {
880:                        jtLancamentos.loadDados();
881:                    } catch (Exception e) {
882:                        ((SimpleLog) GFPController.getGFPController()
883:                                .getContexto().get(GFPController.LOG))
884:                                .log("Erro ao recarregar dados da table de aplicacoes!");
885:                        ((SimpleLog) GFPController.getGFPController()
886:                                .getContexto().get(GFPController.LOG)).log(e
887:                                .getLocalizedMessage());
888:                        ((SimpleLog) GFPController.getGFPController()
889:                                .getContexto().get(GFPController.LOG)).log(e);
890:                    }
891:                }
892:            }
893:
894:            /**
895:             * @param e
896:             */
897:            public void loadFromTable(ListSelectionEvent e) {
898:                try {
899:                    accountSaving = (AccountSaving) jtLancamentos
900:                            .getPersistentObject(jtLancamentos.getSelectedRow());
901:                } catch (SQLException sqle) {
902:                    ((SimpleLog) GFPController.getGFPController().getContexto()
903:                            .get(GFPController.LOG))
904:                            .log("Erro ao carregar accoutSaving da tabela de aplicacoes!");
905:                    ((SimpleLog) GFPController.getGFPController().getContexto()
906:                            .get(GFPController.LOG)).log(sqle
907:                            .getLocalizedMessage());
908:                    ((SimpleLog) GFPController.getGFPController().getContexto()
909:                            .get(GFPController.LOG)).log(sqle);
910:                }
911:                editarAplicacao();
912:            }
913:
914:            @Override
915:            public void setVisible(boolean aFlag) {
916:                super .setVisible(aFlag);
917:                try {
918:                    if (jcbBanco != null)
919:                        jcbBanco.loadDados();
920:                } catch (DAOCreationException e) {
921:                    ((SimpleLog) GFPController.getGFPController().getContexto()
922:                            .get(GFPController.LOG))
923:                            .log("Erro ao carregar dados em combo da tela accoutSaving!");
924:                    ((SimpleLog) GFPController.getGFPController().getContexto()
925:                            .get(GFPController.LOG)).log(e
926:                            .getLocalizedMessage());
927:                    ((SimpleLog) GFPController.getGFPController().getContexto()
928:                            .get(GFPController.LOG)).log(e);
929:                } catch (SQLException e) {
930:                    ((SimpleLog) GFPController.getGFPController().getContexto()
931:                            .get(GFPController.LOG))
932:                            .log("Erro ao carregar dados em combo da tela de accoutSaving!");
933:                    ((SimpleLog) GFPController.getGFPController().getContexto()
934:                            .get(GFPController.LOG)).log(e
935:                            .getLocalizedMessage());
936:                    ((SimpleLog) GFPController.getGFPController().getContexto()
937:                            .get(GFPController.LOG)).log(e);
938:                }
939:            }
940:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.