Source Code Cross Referenced for TypeOfTransactionWindow.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:         * TelaCadastroContas.java Criado em 28 de Janeiro de 2004, 22:57
003:         */
004:
005:        package br.com.gfp.windows;
006:
007:        import java.awt.BorderLayout;
008:        import java.awt.Color;
009:        import java.awt.Dimension;
010:        import java.awt.GridBagConstraints;
011:        import java.awt.GridBagLayout;
012:        import java.awt.Insets;
013:        import java.awt.event.ActionEvent;
014:        import java.awt.event.ActionListener;
015:        import java.awt.event.FocusEvent;
016:        import java.awt.event.FocusListener;
017:        import java.awt.event.ItemEvent;
018:        import java.awt.event.ItemListener;
019:        import java.sql.SQLException;
020:        import java.text.NumberFormat;
021:        import java.util.HashMap;
022:
023:        import javax.swing.JButton;
024:        import javax.swing.JCheckBox;
025:        import javax.swing.JFrame;
026:        import javax.swing.JLabel;
027:        import javax.swing.JOptionPane;
028:        import javax.swing.JPanel;
029:        import javax.swing.WindowConstants;
030:        import javax.swing.event.ListSelectionEvent;
031:        import javax.swing.event.ListSelectionListener;
032:
033:        import br.com.gfp.dao.GFPController;
034:        import br.com.gfp.dao.TransactionTypeDAO;
035:        import br.com.gfp.data.TransactionType;
036:        import br.com.gfp.internationalization.ErrosDeDadosMessages;
037:        import br.com.gfp.internationalization.TelaTipoLancamentoMessages;
038:        import br.com.gfp.reports.ReportFactory;
039:        import br.com.gfp.util.SimpleLog;
040:        import br.com.gfp.windows.componentes.GFPHeaderRenderer;
041:        import br.com.gfp.windows.componentes.GFPTableCellRenderer;
042:        import br.com.gfpshare.beans.DBComboBox;
043:        import br.com.gfpshare.beans.GeneralEventHandler;
044:        import br.com.gfpshare.beans.ZLabel;
045:        import br.com.gfpshare.beans.ZMoneyTextField;
046:        import br.com.gfpshare.beans.ZTextField;
047:        import br.com.gfpshare.beans.aplicativos.IconeFactory;
048:        import br.com.gfpshare.beans.aplicativos.PainelTelaBasica;
049:        import br.com.gfpshare.beans.table.DBTreeTable;
050:        import br.com.gfpshare.db.DAOListener;
051:
052:        /**
053:         * @author Igor Regis da Silva Simoes
054:         */
055:        public class TypeOfTransactionWindow extends
056:                GFPInternalFrame<TransactionType> {
057:            private static final NumberFormat CURRENCY_INSTANCE_FORMATER = NumberFormat
058:                    .getCurrencyInstance();
059:
060:            private TransactionType transactionType = new TransactionType();
061:
062:            private PainelTelaBasica telaPrincipal;
063:
064:            private JCheckBox jcbSubGrupo;
065:
066:            private DBComboBox jcboxSubGrupo;
067:
068:            private ZLabel jlNome;
069:
070:            private JCheckBox jcbRealizarPrevisao;
071:
072:            private DBTreeTable jtLancamentos;
073:
074:            private ZTextField jtfNome;
075:
076:            private ZLabel jlMeta;
077:
078:            private ZMoneyTextField mtfMeta;
079:
080:            private JPanel metasPanel;
081:
082:            private JLabel metasDespesasSomaLabel;
083:
084:            private JLabel metasDespesasSoma;
085:
086:            /**
087:             * Cria um novo form TelaCadastroContas
088:             * 
089:             * @param owner
090:             */
091:            public TypeOfTransactionWindow(JFrame owner) {
092:                controller = new TransactionTypeDAO();
093:                initComponents();
094:                setSize(700, 450);
095:            }
096:
097:            /**
098:             * Cria uma tela com um listener que saberá quado um objeto foi inserido no DB
099:             * @param owner
100:             * @param listener
101:             */
102:            public TypeOfTransactionWindow(JFrame owner,
103:                    DAOListener<TransactionType> listener) {
104:                this (owner);
105:                setListener(listener);
106:            }
107:
108:            /**
109:             * 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
110:             * regenerated by the Form Editor.
111:             */
112:            private void initComponents() {
113:                setClosable(true);
114:                setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
115:                setIconifiable(true);
116:                setMaximizable(true);
117:                setResizable(true);
118:                setTitle(TelaTipoLancamentoMessages.getMessages().getString(
119:                        "tipoLancamento")); //$NON-NLS-1$
120:                setFrameIcon(IconeFactory.getIconeFactory().getImageIcon(
121:                        IconeFactory.TIPO_LANCAMENTO_PEQUENA));
122:
123:                GridBagConstraints gridBagConstraints;
124:
125:                jtLancamentos = new DBTreeTable(new TransactionType(),
126:                        "SuperTipo", new GFPHeaderRenderer());
127:                //		jtLancamentos = new DBTreeTable(new ExtendedDBTreeTableModel(new TransactionType(), "SuperTipo", new String[] {"Test"})); 
128:                jtLancamentos.hideColumn("Id"); //$NON-NLS-1$
129:                jtLancamentos.hideColumn("SuperTipo"); //$NON-NLS-1$
130:                jtLancamentos.hideColumn("EhDeSistema"); //$NON-NLS-1$
131:                jtLancamentos.getColumn("RealizarPrevisao").setMinWidth(120);
132:                jtLancamentos.getColumn("RealizarPrevisao").setMaxWidth(120);
133:                jtLancamentos.getColumn("RealizarPrevisao").setCellRenderer(
134:                        new GFPTableCellRenderer(GFPTableCellRenderer.BOOLEANO,
135:                                -1));
136:                jtLancamentos.getColumn("Meta").setCellRenderer(
137:                        new GFPTableCellRenderer(GFPTableCellRenderer.DINHEIRO,
138:                                -1));
139:                jtLancamentos
140:                        .getSelectionModel()
141:                        .addListSelectionListener(
142:                                (ListSelectionListener) GeneralEventHandler
143:                                        .makeProxy(
144:                                                this ,
145:                                                "loadFromTable", ListSelectionListener.class, "valueChanged")); //$NON-NLS-1$ //$NON-NLS-2$
146:
147:                telaPrincipal = new PainelTelaBasica();
148:                telaPrincipal.setJtDados(jtLancamentos);
149:                telaPrincipal.addPrintButtonListener(new PrintListener());
150:
151:                jtfNome = new ZTextField();
152:                jlNome = new ZLabel();
153:                jcbSubGrupo = new JCheckBox();
154:                jcboxSubGrupo = new DBComboBox(transactionType);
155:                jcbRealizarPrevisao = new JCheckBox();
156:                jlMeta = new ZLabel();
157:                mtfMeta = new ZMoneyTextField();
158:                metasPanel = new JPanel();
159:                metasDespesasSomaLabel = new JLabel();
160:                metasDespesasSoma = new JLabel();
161:
162:                jtfNome.setMinimumSize(new Dimension(100, 24));
163:                jtfNome.setPreferredSize(new Dimension(100, 26));
164:                gridBagConstraints = new GridBagConstraints();
165:                gridBagConstraints.gridx = 1;
166:                gridBagConstraints.gridy = 1;
167:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
168:                gridBagConstraints.anchor = GridBagConstraints.WEST;
169:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
170:                telaPrincipal.addComponent(jtfNome, gridBagConstraints,
171:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
172:
173:                jlNome.setText(TelaTipoLancamentoMessages.getMessages()
174:                        .getString("nome")); //$NON-NLS-1$
175:                jlNome.setDisplayedMnemonic(TelaTipoLancamentoMessages
176:                        .getMessages().getString("NomeMnemonic").charAt(0));
177:                jlNome.setRequiredField(jtfNome);
178:                jlNome.setValidationNotNull(true);
179:                gridBagConstraints = new GridBagConstraints();
180:                gridBagConstraints.gridx = 0;
181:                gridBagConstraints.gridy = 1;
182:                gridBagConstraints.anchor = GridBagConstraints.WEST;
183:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
184:                telaPrincipal.addComponent(jlNome, gridBagConstraints,
185:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
186:
187:                jcbSubGrupo.setText(TelaTipoLancamentoMessages.getMessages()
188:                        .getString("subGrupoDe")); //$NON-NLS-1$
189:                jcbSubGrupo.setMnemonic(TelaTipoLancamentoMessages
190:                        .getMessages().getString("SubGrupoDeMnemonic")
191:                        .charAt(0));
192:                jcbSubGrupo.setToolTipText(TelaTipoLancamentoMessages
193:                        .getMessages().getString("SubGrupoDeToolTip"));
194:                jcbSubGrupo
195:                        .addItemListener((ItemListener) GeneralEventHandler
196:                                .makeProxy(
197:                                        this ,
198:                                        "subGrupoItemStateChanged", ItemListener.class, "itemStateChanged")); //$NON-NLS-1$ //$NON-NLS-2$
199:
200:                gridBagConstraints = new GridBagConstraints();
201:                gridBagConstraints.gridx = 0;
202:                gridBagConstraints.gridy = 2;
203:                gridBagConstraints.anchor = GridBagConstraints.WEST;
204:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
205:                telaPrincipal.addComponent(jcbSubGrupo, gridBagConstraints,
206:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
207:
208:                jcboxSubGrupo.setMinimumSize(new Dimension(100, 25));
209:                jcboxSubGrupo.setPreferredSize(new Dimension(150, 25));
210:                jcboxSubGrupo.setEnabled(false);
211:                jcboxSubGrupo.setToolTipText(TelaTipoLancamentoMessages
212:                        .getMessages().getString("SubGrupoComboToolTip"));
213:                gridBagConstraints = new GridBagConstraints();
214:                gridBagConstraints.gridx = 1;
215:                gridBagConstraints.gridy = 2;
216:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
217:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
218:                telaPrincipal.addComponent(jcboxSubGrupo, gridBagConstraints,
219:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
220:
221:                jcbRealizarPrevisao.setText(TelaTipoLancamentoMessages
222:                        .getMessages().getString("realizarPrevisao"));
223:                jcbRealizarPrevisao.setMnemonic(TelaTipoLancamentoMessages
224:                        .getMessages().getString("RealizarPrevisaoMnemonic")
225:                        .charAt(0));
226:                jcbRealizarPrevisao.setToolTipText(TelaTipoLancamentoMessages
227:                        .getMessages().getString("RealizarPrevisaoToolTip"));
228:                gridBagConstraints = new GridBagConstraints();
229:                gridBagConstraints.gridx = 0;
230:                gridBagConstraints.gridy = 4;
231:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
232:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
233:                telaPrincipal.addComponent(jcbRealizarPrevisao,
234:                        gridBagConstraints,
235:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
236:
237:                mtfMeta.setMinimumSize(new Dimension(100, 24));
238:                mtfMeta.setPreferredSize(new Dimension(100, 26));
239:                mtfMeta.setToolTipText(TelaTipoLancamentoMessages.getMessages()
240:                        .getString("MetaToolTip"));
241:                mtfMeta.addFocusListener((FocusListener) GeneralEventHandler
242:                        .makeProxy(this , "formatMeta", FocusListener.class,
243:                                "focusLost"));
244:                gridBagConstraints = new GridBagConstraints();
245:                gridBagConstraints.gridx = 1;
246:                gridBagConstraints.gridy = 3;
247:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
248:                gridBagConstraints.anchor = GridBagConstraints.WEST;
249:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
250:                telaPrincipal.addComponent(mtfMeta, gridBagConstraints,
251:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
252:
253:                jlMeta.setText(TelaTipoLancamentoMessages.getMessages()
254:                        .getString("Meta"));
255:                jlMeta.setDisplayedMnemonic(TelaTipoLancamentoMessages
256:                        .getMessages().getString("MetaMnemonic").charAt(0));
257:                jlMeta.setLabelFor(jtfNome);
258:                gridBagConstraints = new GridBagConstraints();
259:                gridBagConstraints.gridx = 0;
260:                gridBagConstraints.gridy = 3;
261:                gridBagConstraints.anchor = GridBagConstraints.WEST;
262:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
263:                telaPrincipal.addComponent(jlMeta, gridBagConstraints,
264:                        PainelTelaBasica.DATA_COMPONENTS_AREA);
265:
266:                telaPrincipal.getPainelBotoes().addActionListener(
267:                        "salvar",
268:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
269:                                "salvar", ActionListener.class,
270:                                "actionPerformed"));
271:                telaPrincipal.getPainelBotoes().addActionListener(
272:                        "atualizar",
273:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
274:                                "atualizar", ActionListener.class,
275:                                "actionPerformed"));
276:                telaPrincipal.getPainelBotoes().addActionListener(
277:                        "novo",
278:                        (ActionListener) GeneralEventHandler
279:                                .makeProxy(this , "novo", ActionListener.class,
280:                                        "actionPerformed"));
281:                telaPrincipal.getPainelBotoes().addActionListener(
282:                        "excluir",
283:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
284:                                "excluir", ActionListener.class,
285:                                "actionPerformed"));
286:                telaPrincipal.getPainelBotoes().addActionListener(
287:                        "pesquisar",
288:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
289:                                "pesquisar", ActionListener.class,
290:                                "actionPerformed"));
291:                telaPrincipal.getPainelBotoes().addActionListener(
292:                        "limpar",
293:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
294:                                "limpar", ActionListener.class,
295:                                "actionPerformed"));
296:                telaPrincipal.getPainelBotoes().addActionListener(
297:                        "filtrar",
298:                        (ActionListener) GeneralEventHandler.makeProxy(this ,
299:                                "filtrar", ActionListener.class,
300:                                "actionPerformed"));
301:                getContentPane().add(telaPrincipal, BorderLayout.CENTER);
302:
303:                metasPanel.setLayout(new GridBagLayout());
304:                metasDespesasSomaLabel.setText(TelaTipoLancamentoMessages
305:                        .getMessages().getString("SomaMetasDespesas"));
306:                gridBagConstraints = new GridBagConstraints();
307:                gridBagConstraints.gridx = 0;
308:                gridBagConstraints.gridy = 0;
309:                gridBagConstraints.weightx = 1.0;
310:                gridBagConstraints.anchor = GridBagConstraints.EAST;
311:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
312:                metasPanel.add(metasDespesasSomaLabel, gridBagConstraints);
313:
314:                metasDespesasSoma.setForeground(Color.RED);
315:                gridBagConstraints = new GridBagConstraints();
316:                gridBagConstraints.gridx = 1;
317:                gridBagConstraints.gridy = 0;
318:                gridBagConstraints.anchor = GridBagConstraints.EAST;
319:                gridBagConstraints.insets = new Insets(5, 5, 5, 5);
320:                metasPanel.add(metasDespesasSoma, gridBagConstraints);
321:
322:                getContentPane().add(metasPanel, BorderLayout.SOUTH);
323:
324:                pack();
325:                limpar(null);
326:                jtfNome.requestFocus();
327:            }
328:
329:            private class PrintListener implements  ActionListener {
330:                public void actionPerformed(final ActionEvent e) {
331:                    ((JButton) e.getSource()).setEnabled(false);
332:                    (new Thread() {
333:                        {
334:                            setPriority(Thread.MIN_PRIORITY);
335:                            setDaemon(true);
336:                        }
337:
338:                        @Override
339:                        public void run() {
340:                            try {
341:                                ReportFactory.makeReport("TiposLancamentos",
342:                                        new HashMap());
343:                            } catch (Exception e1) {
344:                                ((SimpleLog) GFPController.getGFPController()
345:                                        .getContexto().get(GFPController.LOG))
346:                                        .log("Erro ao gerar relatorio de Tipos de lancamentos!");
347:                                ((SimpleLog) GFPController.getGFPController()
348:                                        .getContexto().get(GFPController.LOG))
349:                                        .log(e1.getLocalizedMessage());
350:                                ((SimpleLog) GFPController.getGFPController()
351:                                        .getContexto().get(GFPController.LOG))
352:                                        .log(e1);
353:                            } finally {
354:                                ((JButton) e.getSource()).setEnabled(true);
355:                            }
356:                        }
357:                    }).start();
358:                }
359:            }
360:
361:            public void formatMeta(FocusEvent ev) {
362:                if (mtfMeta.getValue() != null
363:                        && !(mtfMeta.getValue() instanceof  Float)) {
364:                    try {
365:                        if (((TransactionTypeDAO) controller)
366:                                .isDespesa(transactionType)) {
367:                            double campo = (Double) mtfMeta.getValue();
368:                            if (campo > 0)
369:                                campo *= -1;
370:                            mtfMeta.setValue(campo);
371:                        }
372:                    } catch (SQLException e) {
373:                        ((SimpleLog) GFPController.getGFPController()
374:                                .getContexto().get(GFPController.LOG))
375:                                .log("Erro ao definir tipo de lançamento para formatar campo de valor");
376:                        ((SimpleLog) GFPController.getGFPController()
377:                                .getContexto().get(GFPController.LOG)).log(e
378:                                .getLocalizedMessage());
379:                        ((SimpleLog) GFPController.getGFPController()
380:                                .getContexto().get(GFPController.LOG)).log(e);
381:                    }
382:                }
383:
384:            }
385:
386:            /**
387:             * @param e
388:             */
389:            public void atualizar(ActionEvent e) {
390:                refreshTabelaTiposLancamentos();
391:            }
392:
393:            /**
394:             * @param e
395:             */
396:            public void pesquisar(ActionEvent e) {
397:                if (transactionType == null)
398:                    transactionType = new TransactionType(jtfNome.getText());
399:                loadTipoLancamento();
400:                try {
401:                    transactionType = controller.getBy(transactionType);
402:                } catch (SQLException sqle) {
403:                    ((SimpleLog) GFPController.getGFPController().getContexto()
404:                            .get(GFPController.LOG))
405:                            .log("Erro ao pesquisar tipo de lancamento: "
406:                                    + transactionType);
407:                    ((SimpleLog) GFPController.getGFPController().getContexto()
408:                            .get(GFPController.LOG)).log(sqle
409:                            .getLocalizedMessage());
410:                    ((SimpleLog) GFPController.getGFPController().getContexto()
411:                            .get(GFPController.LOG)).log(sqle);
412:                    transactionType = null;
413:                }
414:                editarTipoLancamento();
415:            }
416:
417:            /**
418:             * @param e
419:             */
420:            public void excluir(ActionEvent e) {
421:                if (transactionType == null) {
422:                    JOptionPane.showMessageDialog(this ,
423:                            TelaTipoLancamentoMessages.getMessages().getString(
424:                                    "semDadosPraExcluir")); //$NON-NLS-1$
425:                    return;
426:                }
427:
428:                loadTipoLancamento();
429:
430:                try {
431:                    controller.deletar(transactionType);
432:                } catch (SQLException sqle) {
433:                    if (sqle.getErrorCode() == -9645)
434:                        JOptionPane.showMessageDialog(this , sqle.getMessage());
435:                    else {
436:                        ((SimpleLog) GFPController.getGFPController()
437:                                .getContexto().get(GFPController.LOG))
438:                                .log("Erro ao excluir tipo de lancamento: "
439:                                        + transactionType);
440:                        ((SimpleLog) GFPController.getGFPController()
441:                                .getContexto().get(GFPController.LOG)).log(sqle
442:                                .getLocalizedMessage());
443:                        ((SimpleLog) GFPController.getGFPController()
444:                                .getContexto().get(GFPController.LOG))
445:                                .log(sqle);
446:                    }
447:                }
448:                transactionType = null;
449:                refreshTabelaTiposLancamentos();
450:            }
451:
452:            /**
453:             * @param e
454:             */
455:            public void salvar(ActionEvent e) {
456:                if (transactionType == null) {//Todo Rever Mensagem
457:                    JOptionPane.showMessageDialog(this ,
458:                            TelaTipoLancamentoMessages.getMessages().getString(
459:                                    "semDadosPraSalvar")); //$NON-NLS-1$
460:                    return;
461:                }
462:                loadTipoLancamento();
463:                if (controller.isAdicionandoNovo()) {
464:                    try {
465:                        controller.adicionarNovo(transactionType);
466:                    } catch (SQLException sqle) {
467:                        JOptionPane.showMessageDialog(this , sqle.getMessage(),
468:                                ErrosDeDadosMessages.getMessages().getString(
469:                                        "MessageTitle"),
470:                                JOptionPane.WARNING_MESSAGE);
471:                        telaPrincipal.getPainelBotoes().setOcorreuErro(true);
472:                        return;
473:                    }
474:                    close();
475:                } else {
476:                    try {
477:                        controller.atualizar(transactionType);
478:                    } catch (SQLException sqle) {
479:                        if (sqle.getErrorCode() == -9645)
480:                            JOptionPane.showMessageDialog(this , sqle
481:                                    .getMessage());
482:                        else
483:                            JOptionPane.showMessageDialog(this , sqle
484:                                    .getMessage(), ErrosDeDadosMessages
485:                                    .getMessages().getString("MessageTitle"),
486:                                    JOptionPane.WARNING_MESSAGE);
487:                        telaPrincipal.getPainelBotoes().setOcorreuErro(true);
488:                        return;
489:                    }
490:                }
491:                transactionType = null;
492:                refreshTabelaTiposLancamentos();
493:            }
494:
495:            /**
496:             * @param e
497:             */
498:            public void novo(ActionEvent e) {
499:                transactionType = new TransactionType(jtfNome.getText());
500:                controller.setAdicionandoNovo(true);
501:            }
502:
503:            /**
504:             * @param evt
505:             */
506:            public void subGrupoItemStateChanged(ItemEvent evt) {
507:                jcboxSubGrupo.setEnabled(jcbSubGrupo.isSelected());
508:                jcboxSubGrupo.requestFocus();
509:            }
510:
511:            /**
512:             * @param e
513:             */
514:            public void limpar(ActionEvent e) {
515:                telaPrincipal.showRequiredFields();
516:                transactionType = null;
517:                jcbSubGrupo.setSelected(false);
518:                mtfMeta.setValue(null);
519:                jcboxSubGrupo.setSelectedIndex(0);
520:                jtfNome.setText(""); //$NON-NLS-1$
521:                telaPrincipal.getTextAreaDescricao().setText(""); //$NON-NLS-1$
522:                controller.setAdicionandoNovo(false);
523:                telaPrincipal.getPainelBotoes().dadosCarregados(false);
524:            }
525:
526:            /**
527:             * @param e
528:             */
529:            public void filtrar(ActionEvent e) {
530:                //aqui não fazemos nada
531:                //TODO colocar mensagem informando aoususario que nao da pra filtrar esta tabela
532:            }
533:
534:            /**
535:             *
536:             */
537:            private void loadTipoLancamento() {
538:                transactionType.setNome(jtfNome.getText());
539:                if (jcboxSubGrupo.getSelectedIndex() > 0)
540:                    try {
541:                        transactionType
542:                                .setSuperTipo(((TransactionType) jcboxSubGrupo
543:                                        .getPersistentObject(jcboxSubGrupo
544:                                                .getSelectedIndex())).getId());
545:                    } catch (Exception e) {
546:                        ((SimpleLog) GFPController.getGFPController()
547:                                .getContexto().get(GFPController.LOG))
548:                                .log("Erro ao setar super tipo do tipo de lancamento!");
549:                        ((SimpleLog) GFPController.getGFPController()
550:                                .getContexto().get(GFPController.LOG)).log(e
551:                                .getLocalizedMessage());
552:                        ((SimpleLog) GFPController.getGFPController()
553:                                .getContexto().get(GFPController.LOG)).log(e);
554:                    }
555:                transactionType.setRealizarPrevisao(Boolean
556:                        .valueOf(jcbRealizarPrevisao.isSelected()));
557:                if (mtfMeta.getValue() != null
558:                        && !(mtfMeta.getValue() instanceof  Float)
559:                        && !((Double) mtfMeta.getValue()).equals(Double
560:                                .valueOf("0.00")))
561:                    transactionType.setMeta((Double) mtfMeta.getValue());
562:                transactionType.setDescricao(telaPrincipal
563:                        .getTextAreaDescricao().getText());
564:            }
565:
566:            /**
567:             *
568:             */
569:            private void editarTipoLancamento() {
570:                telaPrincipal.hideRequiredFields();
571:                if (transactionType != null) {
572:                    jtfNome.setText(transactionType.getNome());
573:                    if (transactionType.getSuperTipo() != null) {
574:                        try {
575:                            jcboxSubGrupo.setSelectedItem(transactionType
576:                                    .getSuperTipo(), "Id"); //$NON-NLS-1$
577:                            jcbSubGrupo.setSelected(true);
578:                        } catch (SQLException e) {
579:                            ((SimpleLog) GFPController.getGFPController()
580:                                    .getContexto().get(GFPController.LOG))
581:                                    .log("Erro ao carregar super tipo do tipo de lancamento: "
582:                                            + transactionType);
583:                            ((SimpleLog) GFPController.getGFPController()
584:                                    .getContexto().get(GFPController.LOG))
585:                                    .log(e.getLocalizedMessage());
586:                            ((SimpleLog) GFPController.getGFPController()
587:                                    .getContexto().get(GFPController.LOG))
588:                                    .log(e);
589:                        }
590:                    } else {
591:                        jcbSubGrupo.setSelected(false);
592:                        jcboxSubGrupo.setSelectedIndex(0);
593:                    }
594:
595:                    if (transactionType.getRealizarPrevisao() != null)
596:                        jcbRealizarPrevisao.setSelected(transactionType
597:                                .getRealizarPrevisao().booleanValue());
598:                    else
599:                        jcbRealizarPrevisao.setSelected(false);
600:
601:                    mtfMeta.setValue(transactionType.getMeta());
602:
603:                    telaPrincipal.getTextAreaDescricao().setText(
604:                            transactionType.getDescricao());
605:                    telaPrincipal.getPainelBotoes().dadosCarregados(true);
606:                }
607:            }
608:
609:            /**
610:             *
611:             */
612:            private void refreshTabelaTiposLancamentos() {
613:                try {
614:                    jtLancamentos.loadDados();
615:                } catch (Exception e) {
616:                    ((SimpleLog) GFPController.getGFPController().getContexto()
617:                            .get(GFPController.LOG))
618:                            .log("Erro ao atualizar tabela de tipos de lancamentos!");
619:                    ((SimpleLog) GFPController.getGFPController().getContexto()
620:                            .get(GFPController.LOG)).log(e
621:                            .getLocalizedMessage());
622:                    ((SimpleLog) GFPController.getGFPController().getContexto()
623:                            .get(GFPController.LOG)).log(e);
624:                }
625:                calcularSomaDespesas();
626:            }
627:
628:            private void calcularSomaDespesas() {
629:                try {
630:                    metasDespesasSoma.setText(CURRENCY_INSTANCE_FORMATER
631:                            .format(((TransactionTypeDAO) controller)
632:                                    .somaMetasDespesas()));
633:                } catch (SQLException e) {
634:                    ((SimpleLog) GFPController.getGFPController().getContexto()
635:                            .get(GFPController.LOG))
636:                            .log("Erro ao calcular soma de metas para despesas!");
637:                    ((SimpleLog) GFPController.getGFPController().getContexto()
638:                            .get(GFPController.LOG)).log(e
639:                            .getLocalizedMessage());
640:                    ((SimpleLog) GFPController.getGFPController().getContexto()
641:                            .get(GFPController.LOG)).log(e);
642:                }
643:            }
644:
645:            /**
646:             * @param e
647:             */
648:            public void loadFromTable(ListSelectionEvent e) {
649:                if (TypeOfTransactionWindow.this .isVisible()) {
650:                    transactionType = (TransactionType) jtLancamentos
651:                            .getPersistentObject(jtLancamentos.getSelectedRow());
652:                    editarTipoLancamento();
653:                }
654:            }
655:
656:            @Override
657:            public void setVisible(boolean aFlag) {
658:                super.setVisible(aFlag);
659:                if (aFlag)
660:                    refreshTabelaTiposLancamentos();
661:            }
662:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.