Source Code Cross Referenced for ProfileDetailsPanel.java in  » Database-Client » SQL-Profiler » org » jahia » sqlprofiler » gui » 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 » SQL Profiler » org.jahia.sqlprofiler.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) Jahia Ltd. All rights reserved.
003:         *
004:         * This software is published under the terms of the Jahia Open Software
005:         * License version 1.1, a copy of which has been included with this
006:         * distribution in the LICENSE.txt file.
007:         */
008:        package org.jahia.sqlprofiler.gui;
009:
010:        import javax.swing.JPanel;
011:        import javax.swing.event.ListSelectionListener;
012:        import org.apache.log4j.Category;
013:        import java.text.MessageFormat;
014:        import javax.swing.JEditorPane;
015:        import javax.swing.JTable;
016:        import java.awt.BorderLayout;
017:        import javax.swing.BorderFactory;
018:        import javax.swing.JScrollPane;
019:        import javax.swing.ListSelectionModel;
020:        import javax.swing.event.ListSelectionEvent;
021:        import org.jahia.sqlprofiler.QueryEntry;
022:        import java.util.Date;
023:
024:        /**
025:         * <p>Title: A panel that displays more details about the currently selected
026:         * SQL Statement</p>
027:         * <p>Description: </p>
028:         * <p>Copyright: Copyright (c) 2003</p>
029:         * <p>Company: Jahia Ltd</p>
030:         * @author Serge Huber
031:         * @version 1.0
032:         */
033:
034:        class ProfileDetailsPanel extends JPanel implements 
035:                ListSelectionListener {
036:
037:            private static final Category LOG = Category
038:                    .getInstance(ProfileDetailsPanel.class);
039:
040:            /** used to format the logging event **/
041:            private static final MessageFormat FORMATTER = new MessageFormat(
042:                    "<b>Time:</b> <code>{0,time,medium}</code>"
043:                            + "&nbsp;&nbsp;<b>Elapsed time:</b> <code>{1,time,medium}</code>"
044:                            + "&nbsp;&nbsp;<b>Category:</b> <code>{2}</code>"
045:                            + "&nbsp;&nbsp;<b>Connection ID:</b> <code>{3}</code>"
046:                            + "<br><b>Prepared SQL:</b><br>" + "{4}<br>"
047:                            + "<b>SQL Statement:</b><br>" + "{5}");
048:
049:            /** the model for the data to render **/
050:            private final ProfileStatementTableModel mModel;
051:            /** pane for rendering detail **/
052:            private final JEditorPane mDetails;
053:
054:            /**
055:             * Creates a new <code>DetailPanel</code> instance.
056:             *
057:             * @param aTable the table to listen for selections on
058:             * @param aModel the model backing the table
059:             */
060:            ProfileDetailsPanel(JTable aTable,
061:                    final ProfileStatementTableModel aModel) {
062:                mModel = aModel;
063:                setLayout(new BorderLayout());
064:                setBorder(BorderFactory.createTitledBorder("Details: "));
065:
066:                mDetails = new JEditorPane();
067:                mDetails.setEditable(false);
068:                mDetails.setContentType("text/html");
069:                add(new JScrollPane(mDetails), BorderLayout.CENTER);
070:
071:                final ListSelectionModel rowSM = aTable.getSelectionModel();
072:                rowSM.addListSelectionListener(this );
073:            }
074:
075:            /** @see ListSelectionListener **/
076:            public void valueChanged(ListSelectionEvent aEvent) {
077:                //Ignore extra messages.
078:                if (aEvent.getValueIsAdjusting()) {
079:                    return;
080:                }
081:
082:                final ListSelectionModel lsm = (ListSelectionModel) aEvent
083:                        .getSource();
084:                if (lsm.isSelectionEmpty()) {
085:                    mDetails.setText("Nothing selected");
086:                } else {
087:                    final int selectedRow = lsm.getMinSelectionIndex();
088:                    final QueryEntry queryEntry = mModel
089:                            .getStatementDetails(selectedRow);
090:                    final Object[] args = { new Date(queryEntry.getTime()),
091:                            new Long(queryEntry.getElapsedTime()),
092:                            escape(queryEntry.getCategory()),
093:                            escape(queryEntry.getConnectionID()),
094:                            escape(queryEntry.getPreparedSQL()),
095:                            escape(queryEntry.getSqlStatement()) };
096:                    mDetails.setText(FORMATTER.format(args));
097:                    mDetails.setCaretPosition(0);
098:                }
099:            }
100:
101:            ////////////////////////////////////////////////////////////////////////////
102:            // Private methods
103:            ////////////////////////////////////////////////////////////////////////////
104:
105:            /**
106:             * Escape &lt;, &gt; &amp; and &quot; as their entities. It is very
107:             * dumb about &amp; handling.
108:             * @param aStr the String to escape.
109:             * @return the escaped String
110:             */
111:            private String escape(String aStr) {
112:                if (aStr == null) {
113:                    return null;
114:                }
115:
116:                final StringBuffer buf = new StringBuffer();
117:                for (int i = 0; i < aStr.length(); i++) {
118:                    char c = aStr.charAt(i);
119:                    switch (c) {
120:                    case '<':
121:                        buf.append("&lt;");
122:                        break;
123:                    case '>':
124:                        buf.append("&gt;");
125:                        break;
126:                    case '\"':
127:                        buf.append("&quot;");
128:                        break;
129:                    case '&':
130:                        buf.append("&amp;");
131:                        break;
132:                    default:
133:                        buf.append(c);
134:                        break;
135:                    }
136:                }
137:                return buf.toString();
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.