Source Code Cross Referenced for ShowExceptionMessageDialog.java in  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » common » 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 » Report » jmagallanes 1.0 » com.calipso.reportgenerator.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.calipso.reportgenerator.common;
002:
003:        import com.calipso.reportgenerator.common.CalipsoException;
004:
005:        import javax.swing.*;
006:        import java.awt.event.ActionListener;
007:        import java.awt.event.ActionEvent;
008:        import java.awt.event.WindowAdapter;
009:        import java.awt.event.WindowEvent;
010:        import java.awt.*;
011:        import java.util.ArrayList;
012:        import java.util.Iterator;
013:
014:        /**
015:         * Despliga un mensaje de error
016:         */
017:
018:        public class ShowExceptionMessageDialog extends JDialog {
019:            JPanel mainPanel;
020:            JPanel topPanel;
021:            JPanel centerPanel;
022:            JButton hideDetailsButton;
023:            JTextArea textField;
024:            JScrollPane scrollPane;
025:            private JLabel detalleLabel;
026:            private JButton cancelBtn;
027:            private JButton detalleBtn;
028:            private JButton stackBtn;
029:
030:            /**
031:             * Inicializa un objeto ShowExceptionMessageDialog
032:             * @param s
033:             * @param e
034:             */
035:            public ShowExceptionMessageDialog(String s, Exception e) {
036:                super (new JFrame(), true);
037:                showExceptionMessage(s, e);
038:            }
039:
040:            /**
041:             * Crea los componentes que componen el Dialog
042:             */
043:            private void initComponents(Exception e) {
044:                setTitle(com.calipso.reportgenerator.common.LanguageTraslator
045:                        .traslate("231"));
046:                getContentPane().add(getMainPanel(e));
047:                setResizable(false);
048:                addWindowListener(new WindowAdapter() {
049:                    public void windowOpened(WindowEvent e) {
050:                        setSize(getWidth(), getHeight()
051:                                - centerPanel.getHeight());
052:                        scrollPane.setVisible(false);
053:                    }
054:                });
055:                pack();
056:                java.awt.Dimension screenSize = java.awt.Toolkit
057:                        .getDefaultToolkit().getScreenSize();
058:                setSize(new java.awt.Dimension(400, 300));
059:                setLocation((screenSize.width - 400) / 2,
060:                        (screenSize.height - 300) / 4);
061:            }
062:
063:            /**
064:             * Retorna el panel  principal del Dialog
065:             * @return
066:             */
067:            private JPanel getMainPanel(Exception e) {
068:                JPanel xTopPanel = getTopPanel(e);
069:                JPanel xCenterPanel = getCenterPanel();
070:                mainPanel = new JPanel(new BorderLayout());
071:                mainPanel.add(xTopPanel, BorderLayout.NORTH);
072:                mainPanel.add(xCenterPanel, BorderLayout.CENTER);
073:                return mainPanel;
074:            }
075:
076:            /**
077:             * Retorna el Panel que contiene el JTextArea ubicado en la seccion central del panel principal
078:             * @return
079:             */
080:            private JPanel getCenterPanel() {
081:                centerPanel = new JPanel(new BorderLayout());
082:                textField = new JTextArea();
083:                scrollPane = new JScrollPane();
084:                textField.setEditable(false);
085:                scrollPane.getViewport().add(textField);
086:                centerPanel.add(scrollPane, BorderLayout.CENTER);
087:                return centerPanel;
088:            }
089:
090:            /**
091:             * Retorna el panel ubicado al norte del panel principal
092:             * @return
093:             */
094:            private JPanel getTopPanel(final Exception e) {
095:                detalleBtn = new JButton();
096:                cancelBtn = new JButton();
097:                stackBtn = new JButton();
098:                topPanel = new JPanel(null);
099:                topPanel.setPreferredSize(new Dimension(400, 200));
100:                detalleBtn.addActionListener(new ActionListener() {
101:                    public void actionPerformed(ActionEvent e) {
102:                        boolean value = scrollPane.isVisible();
103:                        if (value) {
104:                            setSize(getWidth(), getHeight()
105:                                    - centerPanel.getHeight());
106:                            stackBtn.setVisible(false);
107:                        } else {
108:                            setSize(getWidth(), getHeight()
109:                                    + centerPanel.getHeight());
110:                            stackBtn.setVisible(true);
111:                        }
112:                        scrollPane.setVisible(!value);
113:
114:                    }
115:                });
116:                cancelBtn.addActionListener(new ActionListener() {
117:                    public void actionPerformed(ActionEvent e) {
118:                        setVisible(false);
119:                        dispose();
120:                    }
121:                });
122:
123:                stackBtn.addActionListener(new ActionListener() {
124:                    public void actionPerformed(ActionEvent evt) {
125:                        ShowExceptionStackTrace.showStackTrace(e);
126:                    }
127:                });
128:
129:                detalleLabel = new JLabel();
130:                getContentPane().add(detalleLabel);
131:                detalleLabel.setText("222");
132:                detalleLabel.setBounds(8, 65, 382, 16);
133:
134:                cancelBtn
135:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
136:                                .traslate("112"));
137:                getContentPane().add(cancelBtn);
138:                cancelBtn.setBounds(306, 168, 85, 26);
139:
140:                detalleBtn
141:                        .setText(com.calipso.reportgenerator.common.LanguageTraslator
142:                                .traslate("230"));
143:                getContentPane().add(detalleBtn);
144:                detalleBtn.setBounds(216, 168, 81, 26);
145:
146:                stackBtn.setText("Stack");
147:                getContentPane().add(stackBtn);
148:                stackBtn.setBounds(126, 168, 81, 26);
149:                stackBtn.setVisible(false);
150:                return topPanel;
151:            }
152:
153:            /**
154:             * Crea y carga y visualiza el Componente
155:             * @param code
156:             * @param e
157:             */
158:            public static void initExceptionDialogMessage(String code,
159:                    Exception e) {
160:                new ShowExceptionMessageDialog(code, e);
161:
162:            }
163:
164:            /**
165:             * Agrega al JTextField todos los mensajes de la Exceptions que ocurrieron
166:             * @param code
167:             * @param e
168:             */
169:            private void showExceptionMessage(String code, Exception e) {
170:                ArrayList list = new ArrayList();
171:                fillCauses(e, list);
172:                initComponents(e);
173:                detalleLabel.setText(code);
174:                Iterator iterator = list.iterator();
175:                while (iterator.hasNext()) {
176:                    String s = (String) iterator.next();
177:                    if (s != null) {
178:                        textField.append(s + "\n");
179:                    }
180:                }
181:
182:                setVisible(true);
183:            }
184:
185:            /**
186:             * Carga las causas por las cuales ocurrieron las distintas Exceptions
187:             * @param e
188:             * @param list
189:             */
190:            private void fillCauses(Throwable e, ArrayList list) {
191:                list.add(e.getMessage());
192:                if (e instanceof  CalipsoException) {
193:                    Throwable subE = e.getCause();
194:                    if (subE != null && e != subE) {
195:                        fillCauses(subE, list);
196:                    }
197:                }
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.