KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ReflectorConsole


1 /*====================================================================
2
3 Objectweb Browser Framework
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle, Jerome Moroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 import java.awt.BorderLayout JavaDoc;
28 import java.io.File JavaDoc;
29 import java.io.IOException JavaDoc;
30 import java.net.MalformedURLException JavaDoc;
31 import java.util.jar.JarFile JavaDoc;
32
33 import javax.swing.JFrame JavaDoc;
34 import javax.swing.JSplitPane JavaDoc;
35
36 import org.objectweb.util.browser.core.api.StatusBar;
37 import org.objectweb.util.browser.core.api.ViewPanel;
38 import org.objectweb.util.browser.core.common.DefaultStatusBar;
39 import org.objectweb.util.browser.core.common.DefaultTreePanel;
40 import org.objectweb.util.browser.core.common.DefaultViewPanel;
41 import org.objectweb.util.browser.core.common.DynamicTree;
42 import org.objectweb.util.browser.plugin.java.reflect.JarFileStructure;
43
44 /**
45  * This class builds a example console built on top of the Browser Framework.
46  * This console allows us to browse a standalone Java archive.
47  *
48  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>,
49  * <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>
50  *
51  * @version 0.1
52  */

53 public class ReflectorConsole {
54
55     public ReflectorConsole(String JavaDoc configFile){
56         // Creates the main frame
57
JFrame JavaDoc frame = new JFrame JavaDoc("Browser GUI");
58         
59         // Creates the view panel
60
ViewPanel viewPanel = new DefaultViewPanel();
61         
62         // Creates the status bar
63
StatusBar statusBar = new DefaultStatusBar();
64         
65         // Creates the tree
66
DynamicTree tree = new DynamicTree();
67                    
68         // Configures the tree
69
tree.setNewBrowserProperty(new String JavaDoc[]{configFile});
70         tree.setTargetPanel(viewPanel);
71         tree.setStatusBar(statusBar);
72
73         // Populates the tree
74
try {
75             File JavaDoc f = new File JavaDoc("build/lib/reflect-plugin.jar");
76             tree.addEntry(f.getName(), new JarFileStructure(new JarFile JavaDoc(f),f.toURL()),8);
77         } catch (MalformedURLException JavaDoc e) {
78             e.printStackTrace();
79         } catch (IOException JavaDoc e) {
80             e.printStackTrace();
81         }
82         
83         // Configures the main frame
84
frame.getContentPane().setLayout(new BorderLayout JavaDoc());
85         frame.getContentPane().add(
86             new JSplitPane JavaDoc(
87                 JSplitPane.HORIZONTAL_SPLIT,
88                 true,
89                 new DefaultTreePanel((DynamicTree)tree),
90                 ((DefaultViewPanel)viewPanel)),
91             BorderLayout.CENTER);
92         frame.getContentPane().add((DefaultStatusBar)statusBar, BorderLayout.SOUTH);
93         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
94         frame.pack();
95         frame.setVisible(true);
96     }
97
98     public static void main(String JavaDoc[] args){
99         if(args.length != 0)
100             new ReflectorConsole(args[0]);
101         else
102             System.err.println("Java Archive expected!");
103     }
104
105 }
106
Popular Tags