Source Code Cross Referenced for ClassesPanel.java in  » Net » Terracotta » com » tc » admin » dso » 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 » Net » Terracotta » com.tc.admin.dso 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003:         * notice. All rights reserved.
004:         */
005:        package com.tc.admin.dso;
006:
007:        import org.apache.xmlbeans.XmlOptions;
008:        import org.dijon.ContainerResource;
009:
010:        import com.tc.admin.AdminClient;
011:        import com.tc.admin.AdminClientContext;
012:        import com.tc.admin.ConnectionContext;
013:        import com.tc.admin.common.XAbstractAction;
014:        import com.tc.admin.common.XContainer;
015:        import com.tc.admin.common.XTextArea;
016:        import com.tc.admin.common.XTree;
017:        import com.tc.object.LiteralValues;
018:        import com.tc.stats.DSOClassInfo;
019:        import com.terracottatech.config.InstrumentedClasses;
020:        import com.terracottatech.config.TcConfigDocument;
021:        import com.terracottatech.config.TcConfigDocument.TcConfig;
022:
023:        import java.awt.event.ActionEvent;
024:        import java.awt.event.KeyEvent;
025:        import java.util.ArrayList;
026:        import java.util.HashMap;
027:        import java.util.Iterator;
028:
029:        import javax.swing.KeyStroke;
030:
031:        public class ClassesPanel extends XContainer {
032:            private ConnectionContext m_cc;
033:            private ClassesTable m_table;
034:            private XTree m_tree;
035:            private ClassesTreeMap m_treeMap;
036:            private XTextArea m_configText;
037:            private static XmlOptions m_xmlOpts;
038:
039:            private static final String REFRESH = "Refresh";
040:
041:            private static final String[] IGNORE_CLASS_LIST = { "com.tcclient",
042:                    "java." };
043:
044:            private static LiteralValues LITERALS = new LiteralValues();
045:
046:            static {
047:                m_xmlOpts = new XmlOptions();
048:                m_xmlOpts.setSavePrettyPrint();
049:                m_xmlOpts.setSavePrettyPrintIndent(2);
050:            }
051:
052:            public ClassesPanel(ConnectionContext cc) {
053:                super ();
054:
055:                AdminClientContext cntx = AdminClient.getContext();
056:
057:                load((ContainerResource) cntx.topRes
058:                        .getComponent("ClassesPanel"));
059:
060:                m_cc = cc;
061:
062:                DSOClassInfo[] classInfo = getClassInfos();
063:
064:                m_table = (ClassesTable) findComponent("ClassTable");
065:                m_table.setClassInfo(classInfo);
066:
067:                m_tree = (XTree) findComponent("ClassTree");
068:                m_tree.setShowsRootHandles(true);
069:                m_tree.setModel(new ClassTreeModel(classInfo));
070:
071:                m_treeMap = (ClassesTreeMap) findComponent("ClassesTreeMap");
072:                m_treeMap.setModel((ClassTreeModel) m_tree.getModel());
073:
074:                m_configText = (XTextArea) findComponent("ClassesConfigTextArea");
075:                updateConfigText();
076:
077:                KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0, true);
078:                getActionMap().put(REFRESH, new RefreshAction());
079:                getInputMap().put(ks, REFRESH);
080:            }
081:
082:            private DSOClassInfo[] getClassInfos() {
083:                DSOClassInfo[] classInfo = ClassesHelper.getHelper()
084:                        .getClassInfo(m_cc);
085:                ArrayList<DSOClassInfo> list = new ArrayList<DSOClassInfo>();
086:
087:                for (DSOClassInfo info : classInfo) {
088:                    String className = info.getClassName();
089:                    if (className.startsWith("com.tcclient"))
090:                        continue;
091:                    if (className.startsWith("[")) {
092:                        int i = 0;
093:                        while (className.charAt(i) == '[')
094:                            i++;
095:                        if (className.charAt(i) == 'L') {
096:                            className = className.substring(i + 1, className
097:                                    .length() - 1);
098:                        } else {
099:                            switch (className.charAt(i)) {
100:                            case 'Z':
101:                                className = "boolean";
102:                                break;
103:                            case 'I':
104:                                className = "int";
105:                                break;
106:                            case 'F':
107:                                className = "float";
108:                                break;
109:                            case 'C':
110:                                className = "char";
111:                                break;
112:                            case 'D':
113:                                className = "double";
114:                                break;
115:                            }
116:                        }
117:                        StringBuffer sb = new StringBuffer(className);
118:                        for (int j = 0; j < i; j++)
119:                            sb.append("[]");
120:                        className = sb.toString();
121:                    }
122:                    list.add(new DSOClassInfo(className, info
123:                            .getInstanceCount()));
124:                }
125:
126:                return list.toArray(new DSOClassInfo[0]);
127:            }
128:
129:            private void updateConfigText() {
130:                DSOClassInfo[] classInfo = ((ClassTreeModel) m_tree.getModel())
131:                        .getClassInfo();
132:                HashMap<String, String> map = new HashMap<String, String>();
133:                for (DSOClassInfo info : classInfo) {
134:                    String className = info.getClassName();
135:                    int brace = className.indexOf("[");
136:                    if (brace != -1) {
137:                        className = className.substring(0, brace);
138:                    }
139:                    map.put(className, className);
140:                }
141:                InstrumentedClasses instrumentedClasses = InstrumentedClasses.Factory
142:                        .newInstance();
143:                Iterator<String> iter = map.keySet().iterator();
144:                while (iter.hasNext()) {
145:                    String className = iter.next();
146:                    if (ignoreClass(className)) {
147:                        continue;
148:                    }
149:                    instrumentedClasses.addNewInclude().setClassExpression(
150:                            className);
151:                }
152:                TcConfigDocument configDoc = TcConfigDocument.Factory
153:                        .newInstance();
154:                TcConfig config = configDoc.addNewTcConfig();
155:                config.addNewApplication().addNewDso().setInstrumentedClasses(
156:                        instrumentedClasses);
157:                m_configText.setText(config.xmlText(m_xmlOpts));
158:            }
159:
160:            private boolean ignoreClass(String className) {
161:                if (LITERALS.isLiteral(className)) {
162:                    return true;
163:                }
164:                for (String pattern : IGNORE_CLASS_LIST) {
165:                    if (className.startsWith(pattern))
166:                        return true;
167:                }
168:                return false;
169:            }
170:
171:            public class RefreshAction extends XAbstractAction {
172:                public void actionPerformed(ActionEvent ae) {
173:                    refresh();
174:                }
175:            }
176:
177:            public void refresh() {
178:                AdminClientContext acc = AdminClient.getContext();
179:
180:                acc.controller.setStatus(acc
181:                        .getMessage("dso.classes.refreshing"));
182:                acc.controller.block();
183:
184:                DSOClassInfo[] classInfo = getClassInfos();
185:                m_table.setClassInfo(classInfo);
186:                ((ClassTreeModel) m_tree.getModel()).setClassInfo(classInfo);
187:                m_treeMap.setModel((ClassTreeModel) m_tree.getModel());
188:                updateConfigText();
189:
190:                acc.controller.clearStatus();
191:                acc.controller.unblock();
192:            }
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.