Source Code Cross Referenced for ContextView.java in  » Scripting » Pnuts » pnuts » tools » 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 » Scripting » Pnuts » pnuts.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)ContextView.java 1.2 04/12/06
003:         *
004:         * Copyright (c) 2003,2004 Sun Microsystems, Inc. All Rights Reserved.
005:         *
006:         * See the file "LICENSE.txt" for information on usage and redistribution
007:         * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
008:         */
009:        package pnuts.tools;
010:
011:        import java.awt.Component;
012:        import java.awt.Container;
013:        import java.awt.Font;
014:        import java.awt.GridBagConstraints;
015:        import java.awt.GridBagLayout;
016:        import java.awt.Insets;
017:        import java.util.HashSet;
018:        import java.util.Iterator;
019:        import java.util.Set;
020:        import java.util.StringTokenizer;
021:
022:        import javax.swing.JFrame;
023:        import javax.swing.JLabel;
024:        import javax.swing.JList;
025:        import javax.swing.JPanel;
026:        import javax.swing.JTable;
027:        import javax.swing.JTextArea;
028:        import javax.swing.JTextField;
029:
030:        import pnuts.ext.NonPublicMemberAccessor;
031:        import pnuts.lang.Configuration;
032:        import pnuts.lang.Context;
033:
034:        class ContextView {
035:            private final static Font monospaced = Font.getFont("monospaced");
036:            private final static Configuration debugConfig = new NonPublicMemberAccessor();
037:
038:            private JTextField currentPackage;
039:            private JTextField classLoader;
040:            private JList imports;
041:            private JList modules;
042:            private JTable locals;
043:            private JTable contextLocals;
044:            private JTextField inspect;
045:            private JTextArea result;
046:            private Context context;
047:            private GridBagLayout gb; // We have to use GBL because this class is loaded by bootclassloader.
048:            private VisualDebuggerView debuggerView;
049:
050:            public ContextView(VisualDebuggerView debuggerView) {
051:                this .debuggerView = debuggerView;
052:            }
053:
054:            public JFrame getFrame() {
055:                JFrame jfr = new JFrame();
056:                setupGUI(jfr.getContentPane());
057:                jfr.setSize(jfr.getPreferredSize());
058:                return jfr;
059:            }
060:
061:            public Container getContainer() {
062:                JPanel panel = new JPanel();
063:                setupGUI(panel);
064:                panel.setSize(panel.getPreferredSize());
065:                return panel;
066:            }
067:
068:            static void add(GridBagLayout gb, Container container,
069:                    Component component, int gridx, int gridy, int gridwidth,
070:                    int gridheight, int weightx, int weighty, int anchor,
071:                    int fill) {
072:                GridBagConstraints c = new GridBagConstraints();
073:                c.gridx = gridx;
074:                c.gridy = gridy;
075:                c.gridwidth = gridwidth;
076:                c.gridheight = gridheight;
077:                c.weightx = weightx;
078:                c.weighty = weighty;
079:                c.anchor = anchor;
080:                c.fill = fill;
081:                c.insets = new Insets(2, 2, 2, 2);
082:                gb.setConstraints(component, c);
083:                container.add(component);
084:            }
085:
086:            void addLabel(Container container, Component component, int gridx,
087:                    int gridy) {
088:                add(gb, container, component, gridx, gridy, 1, 1, 0, 0,
089:                        GridBagConstraints.NORTHEAST, GridBagConstraints.NONE);
090:            }
091:
092:            void add_h(Container container, Component component, int gridx,
093:                    int gridy) {
094:                add(gb, container, component, gridx, gridy, 1, 1, 1, 0,
095:                        GridBagConstraints.CENTER,
096:                        GridBagConstraints.HORIZONTAL);
097:            }
098:
099:            void add_b(Container container, Component component, int gridx,
100:                    int gridy) {
101:                add(gb, container, component, gridx, gridy, 1, 1, 1, 1,
102:                        GridBagConstraints.CENTER, GridBagConstraints.BOTH);
103:            }
104:
105:            void add_n(Container container, Component component, int gridx,
106:                    int gridy) {
107:                add(gb, container, component, gridx, gridy, 1, 1, 0, 0,
108:                        GridBagConstraints.CENTER, GridBagConstraints.NONE);
109:            }
110:
111:            JLabel createJLabel(String key) {
112:                return new JLabel(debuggerView.getResourceString(key
113:                        + VisualDebuggerView.labelSuffix));
114:            }
115:
116:            public void setupGUI(Container contentPane) {
117:                this .gb = new GridBagLayout();
118:                Font monospaced = Font.getFont("monospaced");
119:                contentPane.setLayout(gb);
120:
121:                String beansDef = debuggerView
122:                        .getResourceString("inspector.beans");
123:                StringTokenizer st = new StringTokenizer(beansDef, ",");
124:                int idx = 0;
125:                while (st.hasMoreTokens()) {
126:                    String token = st.nextToken();
127:                    String clsName = debuggerView
128:                            .getResourceString("inspector.bean." + token
129:                                    + ".class");
130:                    if (clsName != null) {
131:                        try {
132:                            Class cls = Class.forName(clsName);
133:                            Component bean = (Component) cls.newInstance();
134:                            if (bean instanceof  ContextListener) {
135:                                addContextlistener((ContextListener) bean);
136:                            }
137:                            addLabel(contentPane, createJLabel(token), 0, idx);
138:                            String layoutHint = debuggerView
139:                                    .getResourceString("inspector.bean."
140:                                            + token + ".layout");
141:                            if (layoutHint != null
142:                                    && layoutHint.toLowerCase().equals("both")) {
143:                                add_b(contentPane, bean, 1, idx);
144:                            } else if (layoutHint != null
145:                                    && layoutHint.toLowerCase().equals("none")) {
146:                                add_n(contentPane, bean, 1, idx);
147:                            } else { // "horizontal"
148:                                add_h(contentPane, bean, 1, idx);
149:                            }
150:                            idx++;
151:                        } catch (ClassNotFoundException cnf) {
152:                            // ignore
153:                        } catch (IllegalAccessException iae) {
154:                            // ignore
155:                        } catch (InstantiationException ie) {
156:                            // ignore
157:                        }
158:                    }
159:                }
160:            }
161:
162:            HashSet listeners = new HashSet();
163:
164:            public void addContextlistener(ContextListener listener) {
165:                listeners.add(listener);
166:            }
167:
168:            public void setContext(Context context) {
169:                this .context = context;
170:                Set listeners = (Set) this .listeners.clone();
171:                for (Iterator it = listeners.iterator(); it.hasNext();) {
172:                    ContextListener listener = (ContextListener) it.next();
173:                    listener.update(new ContextEvent(context));
174:                }
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.