Source Code Cross Referenced for ThrowableOutlineModel.java in  » Database-Client » iSQL-Viewer » org » isqlviewer » model » 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 » Database Client » iSQL Viewer » org.isqlviewer.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the Mozilla Public License
003:         * Version 1.1 (the "License"); you may not use this file except in
004:         * compliance with the License. You may obtain a copy of the License at
005:         * http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009:         * License for the specific language governing rights and limitations
010:         * under the License.
011:         * 
012:         * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013:         *
014:         * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015:         * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016:         *
017:         * Contributor(s): 
018:         *  Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019:         *  
020:         * If you didn't download this code from the following link, you should check
021:         * if you aren't using an obsolete version: http://www.isqlviewer.com
022:         */
023:        package org.isqlviewer.model;
024:
025:        import java.sql.SQLException;
026:        import java.util.Vector;
027:
028:        import javax.swing.tree.TreePath;
029:
030:        import org.isqlviewer.swing.outline.AbstractTreeTableModel;
031:        import org.isqlviewer.swing.outline.OutlineModel;
032:        import org.isqlviewer.util.LocalMessages;
033:
034:        /**
035:         * Outline model for showing exceptions in a tree-table fashion.
036:         * <p>
037:         * 
038:         * @author Mark A. Kobold &lt;mkobold at isqlviewer dot com&gt;
039:         * @version 1.0
040:         */
041:        public class ThrowableOutlineModel extends AbstractTreeTableModel {
042:
043:            private static final Class[] columnTypes = { OutlineModel.class,
044:                    String.class, String.class };
045:            private static final String RESOURCE_BUNDLE = "org.isqlviewer.model.ResourceBundle";
046:
047:            private Object root = new Object();
048:            private LocalMessages messages = new LocalMessages(RESOURCE_BUNDLE);
049:            private Vector<Throwable> errorChain = new Vector<Throwable>();
050:
051:            public ThrowableOutlineModel(Throwable error) {
052:
053:                errorChain.add(error);
054:                Throwable sourceError = error;
055:                Throwable nextError = getCause(sourceError);
056:                while (nextError != null && nextError != sourceError) {
057:                    errorChain.add(nextError);
058:                    sourceError = nextError;
059:                    nextError = getCause(sourceError);
060:                }
061:            }
062:
063:            public Class getColumnClass(int column) {
064:
065:                return columnTypes[column];
066:            }
067:
068:            public int getColumnCount() {
069:
070:                return columnTypes.length;
071:            }
072:
073:            public String getColumnName(int column) {
074:
075:                switch (column) {
076:                case 0:
077:                    return messages
078:                            .format("ThrowableOutlineModel.stacktrace_column.header");
079:                case 1:
080:                    return messages
081:                            .format("ThrowableOutlineModel.sqlstate_column.header");
082:                case 2:
083:                    return messages
084:                            .format("ThrowableOutlineModel.sqlerror_column.header");
085:                default:
086:                    return null;
087:                }
088:            }
089:
090:            public Object getValueAt(Object node, int column) {
091:
092:                if (node instanceof  SQLException) {
093:                    SQLException sqlError = (SQLException) node;
094:                    switch (column) {
095:                    case 1:
096:                        return sqlError.getSQLState();
097:                    case 2:
098:                        return Integer.toString(sqlError.getErrorCode());
099:                    }
100:                } else {
101:                    switch (column) {
102:                    case 1:
103:                        return "";
104:                    case 2:
105:                        return "";
106:                    }
107:                }
108:                return node;
109:            }
110:
111:            public Object getChild(Object parent, int index) {
112:
113:                if (parent == root) {
114:                    return errorChain.elementAt(index);
115:                } else if (parent instanceof  Throwable) {
116:                    return ((Throwable) parent).getStackTrace()[index];
117:                }
118:                return null;
119:            }
120:
121:            public int getChildCount(Object parent) {
122:
123:                if (parent == root) {
124:                    return errorChain.size();
125:                } else if (parent instanceof  Throwable) {
126:                    return ((Throwable) parent).getStackTrace().length;
127:                }
128:                return 0;
129:            }
130:
131:            public int getIndexOfChild(Object parent, Object child) {
132:
133:                if (parent == root) {
134:                    return errorChain.indexOf(child);
135:                } else if (parent instanceof  Throwable) {
136:                    StackTraceElement[] stackTrace = ((Throwable) parent)
137:                            .getStackTrace();
138:                    for (int i = 0; i < stackTrace.length; i++) {
139:                        String line = stackTrace[i].toString();
140:                        if (line.equals(child)) {
141:                            return i;
142:                        }
143:                    }
144:                }
145:                return -1;
146:            }
147:
148:            public Object getRoot() {
149:
150:                return root;
151:            }
152:
153:            public boolean isLeaf(Object node) {
154:
155:                return !(node instanceof  Throwable) && node != root;
156:            }
157:
158:            public void valueForPathChanged(TreePath path, Object newValue) {
159:
160:            }
161:
162:            private Throwable getCause(Throwable sourceError) {
163:
164:                if (sourceError instanceof  SQLException) {
165:                    Throwable cause = ((SQLException) sourceError)
166:                            .getNextException();
167:                    if (cause != null) {
168:                        return cause;
169:                    }
170:                }
171:                return sourceError.getCause();
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.