Source Code Cross Referenced for Browser.java in  » J2EE » hgcommons » biz » hammurapi » swing » 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 » J2EE » hgcommons » biz.hammurapi.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * hgcommons 7
003:         * Hammurapi Group Common Library 
004:         * Copyright (C) 2003  Hammurapi Group
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2 of the License, or (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         * URL: http://www.hammurapi.biz/hammurapi-biz/ef/xmenu/hammurapi-group/products/products/hgcommons/index.html
021:         * e-Mail: support@hammurapi.biz
022:         */
023:        package biz.hammurapi.swing;
024:
025:        import java.awt.GridBagConstraints;
026:        import java.awt.GridBagLayout;
027:        import java.awt.event.WindowEvent;
028:
029:        import javax.swing.JFrame;
030:        import javax.swing.JScrollPane;
031:        import javax.swing.JSplitPane;
032:        import javax.swing.JTable;
033:        import javax.swing.JTree;
034:        import javax.swing.WindowConstants;
035:        import javax.swing.table.TableModel;
036:        import javax.swing.tree.DefaultMutableTreeNode;
037:        import javax.swing.tree.DefaultTreeModel;
038:        import javax.swing.tree.MutableTreeNode;
039:        import javax.swing.tree.TreeNode;
040:        import javax.swing.tree.TreePath;
041:
042:        /**
043:         * @author Pavel Vlasov
044:         * 
045:         * @version $Revision: 1.2 $
046:         */
047:        public class Browser extends JFrame {
048:
049:            private javax.swing.JPanel jContentPane = null;
050:
051:            private JSplitPane jSplitPane = null;
052:
053:            private JScrollPane jScrollPane = null;
054:
055:            private JScrollPane jDetailsPane = null;
056:
057:            private JTree jTree = null;
058:
059:            private JTable jTable = null;
060:
061:            /**
062:             * This method initializes jSplitPane
063:             * 
064:             * @return javax.swing.JSplitPane
065:             */
066:            private JSplitPane getJSplitPane() {
067:                if (jSplitPane == null) {
068:                    jSplitPane = new JSplitPane();
069:                    jSplitPane.setLeftComponent(getJScrollPane());
070:                    jSplitPane.setRightComponent(getJScrollPane1());
071:                    jSplitPane.setDividerLocation(400);
072:                }
073:                return jSplitPane;
074:            }
075:
076:            /**
077:             * This method initializes jScrollPane
078:             * 
079:             * @return javax.swing.JScrollPane
080:             */
081:            private JScrollPane getJScrollPane() {
082:                if (jScrollPane == null) {
083:                    jScrollPane = new JScrollPane();
084:                    jScrollPane.setViewportView(getJTree());
085:                }
086:                return jScrollPane;
087:            }
088:
089:            /**
090:             * This method initializes jScrollPane1
091:             * 
092:             * @return javax.swing.JScrollPane
093:             */
094:            private JScrollPane getJScrollPane1() {
095:                if (jDetailsPane == null) {
096:                    jDetailsPane = new JScrollPane();
097:                    jDetailsPane.setViewportView(getJTable());
098:                }
099:                return jDetailsPane;
100:            }
101:
102:            /**
103:             * This method initializes jTree
104:             * 
105:             * @return javax.swing.JTree
106:             */
107:            private JTree getJTree() {
108:                if (jTree == null) {
109:                    jTree = new JTree();
110:                    jTree
111:                            .addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
112:                                public void valueChanged(
113:                                        javax.swing.event.TreeSelectionEvent e) {
114:                                    TreePath newLeadSelectionPath = e
115:                                            .getNewLeadSelectionPath();
116:                                    if (newLeadSelectionPath == null) {
117:                                        jTable.setVisible(false);
118:                                    } else {
119:                                        DefaultMutableTreeNode lastPathComponent = (DefaultMutableTreeNode) newLeadSelectionPath
120:                                                .getLastPathComponent();
121:                                        Visualizable v = CompositeVisualizer
122:                                                .getThreadInstance()
123:                                                .toVisualizable(
124:                                                        lastPathComponent
125:                                                                .getUserObject());
126:                                        TableModel toTable = v.toTable();
127:                                        if (toTable != null) {
128:                                            jTable.setModel(toTable);
129:                                        }
130:                                        jTable.setVisible(toTable != null);
131:                                        //jTable.getColumnModel().getColumn(0).setMaxWidth(150);
132:                                    }
133:                                }
134:                            });
135:                }
136:                return jTree;
137:            }
138:
139:            /**
140:             * This method initializes jTable	
141:             * 	
142:             * @return javax.swing.JTable	
143:             */
144:            private JTable getJTable() {
145:                if (jTable == null) {
146:                    jTable = new JTable();
147:                }
148:                return jTable;
149:            }
150:
151:            /**
152:             * @param root
153:             */
154:            public Browser(String title, TreeNode root) {
155:                super ();
156:                initialize();
157:                setTitle(title);
158:                getJTree().setModel(new DefaultTreeModel(root));
159:            }
160:
161:            /**
162:             * This method initializes this
163:             * 
164:             * @return void
165:             */
166:            private void initialize() {
167:                this .setSize(921, 616);
168:                this .setContentPane(getJContentPane());
169:                this .setTitle("JFrame");
170:            }
171:
172:            /**
173:             * This method initializes jContentPane
174:             * 
175:             * @return javax.swing.JPanel
176:             */
177:            private javax.swing.JPanel getJContentPane() {
178:                if (jContentPane == null) {
179:                    GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
180:                    jContentPane = new javax.swing.JPanel();
181:                    jContentPane.setLayout(new GridBagLayout());
182:                    gridBagConstraints1.gridx = 0;
183:                    gridBagConstraints1.gridy = 0;
184:                    gridBagConstraints1.weightx = 1.0;
185:                    gridBagConstraints1.weighty = 1.0;
186:                    gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
187:                    jContentPane.add(getJSplitPane(), gridBagConstraints1);
188:                }
189:                return jContentPane;
190:            }
191:
192:            /**
193:             * Shows objects in Browser. Blocks current thread until browser closes.
194:             * @param o
195:             * @param title
196:             */
197:            public static void show(Object o, String title) {
198:                MutableTreeNode node = CompositeVisualizer.getThreadInstance()
199:                        .toVisualizable(o).toTree(title);
200:                final Object monitor = new Object();
201:                Browser browser = new Browser(title, node) {
202:                    protected void processWindowEvent(WindowEvent e) {
203:                        super .processWindowEvent(e);
204:                        if (e.getID() == WindowEvent.WINDOW_CLOSED) {
205:                            synchronized (monitor) {
206:                                monitor.notifyAll();
207:                            }
208:                        }
209:                    }
210:                };
211:
212:                browser
213:                        .setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
214:                browser.setVisible(true);
215:
216:                synchronized (monitor) {
217:                    try {
218:                        monitor.wait();
219:                    } catch (InterruptedException ex) {
220:                        // Ignore
221:                    }
222:                }
223:            }
224:
225:            /**
226:             * Shows object in browser with default close operation <code>WindowConstants.EXIT_ON_CLOSE</code>
227:             * @param o
228:             * @param title
229:             */
230:            public static void showAndExitOnClose(Object o, String title) {
231:                MutableTreeNode node = CompositeVisualizer.getThreadInstance()
232:                        .toVisualizable(o).toTree(title);
233:                Browser browser = new Browser(title, node);
234:                browser.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
235:                browser.setVisible(true);
236:            }
237:
238:        } //  @jve:decl-index=0:visual-constraint="10,10"
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.