Source Code Cross Referenced for JMapViewer.java in  » IDE » tIDE » tide » profiler » 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 » IDE » tIDE » tide.profiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package tide.profiler;
002:
003:        import javax.swing.border.LineBorder;
004:        import tide.editor.MainEditorFrame;
005:        import snow.utils.gui.Icons;
006:        import tide.execute.ProcessItem;
007:        import java.io.File;
008:        import snow.sortabletable.*;
009:        import javax.swing.*;
010:        import javax.swing.event.*;
011:        import java.awt.*;
012:        import java.awt.event.*;
013:
014:        /** A panel as output tab, to see the histogram of the used objects in memory.
015:         */
016:        public final class JMapViewer extends JPanel {
017:            final JTable table;
018:            SortableTableModel sortableTableModel;
019:            JMapReader reader;
020:            final ProcessItem pi;
021:
022:            public JMapViewer(final JMapReader reader, final ProcessItem pi,
023:                    final File jmap) {
024:                super (new BorderLayout());
025:
026:                this .pi = pi;
027:                this .reader = reader;
028:                this .sortableTableModel = new SortableTableModel(reader);
029:                table = new JTable(this .sortableTableModel);
030:
031:                add(new JScrollPane(table), BorderLayout.CENTER);
032:                sortableTableModel.installGUI(table);
033:                table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
034:
035:                MultiSearchPanel asp2 = new MultiSearchPanel("Filter: ", null,
036:                        sortableTableModel);
037:                JPanel northPan = new JPanel();
038:                northPan.setLayout(new BoxLayout(northPan, BoxLayout.X_AXIS));
039:                northPan.add(asp2);
040:                add(northPan, BorderLayout.NORTH);
041:
042:                JButton delta = new JButton("look again for diffs");
043:                delta
044:                        .setToolTipText("Repopulates the actual object histogram and shows the differences");
045:                delta.setMargin(new Insets(0, 4, 0, 4));
046:                northPan.add(Box.createHorizontalStrut(5));
047:                northPan.add(delta);
048:                delta.addActionListener(new ActionListener() {
049:                    public void actionPerformed(ActionEvent ae) {
050:                        try {
051:                            if (pi.isTerminated())
052:                                throw new Exception("Process " + pi.pid
053:                                        + " is no more running");
054:                            Process np = Runtime.getRuntime().exec(
055:                                    new String[] { jmap.getAbsolutePath(),
056:                                            "-histo", pi.pid });
057:                            JMapReader newReader = new JMapReader(np);
058:                            np.waitFor();
059:                            reader.addDiffAnalysis(newReader);
060:                            newReader.terminate();
061:                            EventQueue.invokeLater(new Runnable() {
062:                                public void run() {
063:                                    sortableTableModel.setAllColumnsVisible();
064:                                    sortableTableModel.sort(reader
065:                                            .getColumnCount(), false);
066:                                    sortableTableModel
067:                                            .setPreferredColumnSizesFromModel();
068:                                }
069:                            });
070:
071:                        } catch (Exception e) {
072:                            JOptionPane.showMessageDialog(JMapViewer.this , ""
073:                                    + e.getMessage(), "Cannot observe process",
074:                                    JOptionPane.ERROR_MESSAGE);
075:                            e.printStackTrace();
076:                        }
077:                    }
078:                });
079:
080:                // TODO: same functions as in the ProcessesManager
081:                JButton deep = new JButton("deep view with jhat");
082:                deep
083:                        .setToolTipText("<html><body>Creates a dump to a file with jmap and lauch jhat to browse it.<br>"
084:                                + "Subsequent calls shows differences.");
085:                deep.setMargin(new Insets(0, 4, 0, 4));
086:                northPan.add(Box.createHorizontalStrut(5));
087:                northPan.add(deep);
088:                deep.addActionListener(new ActionListener() {
089:                    public void actionPerformed(ActionEvent ae) {
090:                        File previous = pi.getLastValidDump();
091:                        try {
092:                            if (pi.isTerminated())
093:                                throw new Exception("Process " + pi.pid
094:                                        + " is no more running");
095:                            File newDump = ProfilerUtils.dumpToFileWithJMap(pi,
096:                                    previous);
097:                            if (newDump == null)
098:                                return;
099:                            if (pi.isTerminated())
100:                                throw new Exception("Process " + pi.pid
101:                                        + " is no more running");
102:                            ProfilerUtils.analyseProfilerResultWithJHatTool(
103:                                    newDump, previous);
104:                        } catch (Exception e) {
105:                            JOptionPane.showMessageDialog(JMapViewer.this , ""
106:                                    + e.getMessage(), "Cannot analyse process",
107:                                    JOptionPane.ERROR_MESSAGE);
108:                            e.printStackTrace();
109:                        }
110:                    }
111:                });
112:
113:                JButton close = new JButton(Icons.sharedCross); //"close view");
114:                close.setMargin(new Insets(0, 0, 0, 0));
115:                northPan.add(Box.createHorizontalStrut(5));
116:                northPan.add(close);
117:                close.addActionListener(new ActionListener() {
118:                    public void actionPerformed(ActionEvent ae) {
119:                        if (getParent() instanceof  JTabbedPane) {
120:                            JTabbedPane tp = (JTabbedPane) getParent();
121:                            tp.remove(JMapViewer.this );
122:                        }
123:
124:                        sortableTableModel.removeOldListeners();
125:                        reader.terminate();
126:                    }
127:                });
128:            }
129:
130:            public void installAsTab() {
131:                final JTabbedPane tp = MainEditorFrame.instance.outputPanels;
132:                String title = "JMap of " + pi.pid;
133:                tp.addTab(title, this );
134:
135:                JPanel rp = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
136:                rp.setOpaque(false);
137:                rp.add(new JLabel(title));
138:                JButton cb = new JButton(new Icons.CrossIcon(8, 8, true));
139:                rp.add(cb);
140:                cb.setFocusPainted(false);
141:                cb.setMargin(new Insets(0, 0, 0, 0));
142:                cb.setBorder(new LineBorder(Color.lightGray, 1, true)); //null);
143:                cb.addActionListener(new ActionListener() {
144:                    public void actionPerformed(ActionEvent ae) {
145:                        tp.remove(JMapViewer.this );
146:                    }
147:                });
148:                tp.setTabComponentAt(tp.getTabCount() - 1, rp);
149:            }
150:
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.