KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > swing > lib > SwingExplorer


1 /*====================================================================
2
3 Objectweb Explorer Framework
4 Copyright (C) 2000-2005 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): Jerome Moroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================
26 $Id: SwingExplorer.java,v 1.1 2005/07/05 09:16:30 moroy Exp $
27 ====================================================================*/

28 package org.objectweb.util.explorer.swing.lib;
29
30 import java.awt.BorderLayout JavaDoc;
31
32 import javax.swing.JFrame JavaDoc;
33 import javax.swing.JSplitPane JavaDoc;
34
35 import org.objectweb.fractal.adl.Factory;
36 import org.objectweb.fractal.adl.FactoryFactory;
37 import org.objectweb.fractal.api.Component;
38 import org.objectweb.fractal.util.Fractal;
39 import org.objectweb.util.explorer.api.Tree;
40 import org.objectweb.util.explorer.parser.api.ParserConfiguration;
41 import org.objectweb.util.explorer.swing.api.Explorer;
42 import org.objectweb.util.explorer.swing.api.StatusBar;
43 import org.objectweb.util.explorer.swing.api.ViewPanel;
44
45 /**
46  * This frame is composed of three elements which are the followings:
47  * <ul>
48  * <li>a tree view</li>
49  * <li>a status bar</li>
50  * <li>a view panel</li>
51  * </ul>
52  * It also wraps the corresponding Fractal component for simplicity concern.
53  *
54  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>,
55  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>.
56  *
57  * @version 0.1
58  */

59 public class SwingExplorer
60      extends JFrame JavaDoc
61   implements org.objectweb.util.explorer.swing.api.SwingExplorer
62 {
63
64     //===================================================================
65
//
66
// Internal States.
67
//
68
// ==================================================================
69

70     /**
71      * The SwingExplorer component.
72      */

73     private Component explorer_;
74
75     // ==================================================================
76
//
77
// Constructors.
78
//
79
// ==================================================================
80

81     /**
82      * Creates the Frame
83      */

84     protected void createFrame(){
85         getContentPane().setLayout(new BorderLayout JavaDoc());
86         getContentPane().add(new JSplitPane JavaDoc(
87                 JSplitPane.HORIZONTAL_SPLIT,
88                 true,
89                 new DefaultTreePanel(getExplorerItf().getTree()),
90                 getViewPanelItf().getViewPanel()), BorderLayout.CENTER);
91         getContentPane().add(getStatusBarItf().getStatusBar(), BorderLayout.SOUTH);
92         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
93         pack();
94     }
95     
96     /**
97      * Default constructor
98      * @param name The name of the frame
99      */

100     public SwingExplorer(String JavaDoc name){
101         super(name);
102         try {
103             // Creates a Fractal Explorer instance.
104
Factory f = FactoryFactory.getFactory(FactoryFactory.FRACTAL_BACKEND);
105             this.explorer_ = (Component)f.newComponent("org.objectweb.util.explorer.swing.SwingFractalExplorer",null);
106             Fractal.getLifeCycleController(this.explorer_).startFc();
107         } catch (Exception JavaDoc e) {
108             e.printStackTrace();
109         }
110         createFrame();
111     }
112     
113     // ==================================================================
114
//
115
// Internal methods.
116
//
117
// ==================================================================
118

119     /**
120      * Provides a fractal interface.
121      */

122     protected Object JavaDoc getFcInterface(String JavaDoc name){
123         try {
124             return explorer_.getFcInterface(name);
125         } catch (Exception JavaDoc e) {
126             // Should never happened!
127
return null;
128         }
129     }
130     
131     // ==================================================================
132
//
133
// Public methods.
134
//
135
// ==================================================================
136

137     /**
138      * @see org.objectweb.util.explorer.swing.api.SwingExplorer#getParserConfigurationItf()
139      */

140     public ParserConfiguration getParserConfigurationItf() {
141         return (ParserConfiguration)getFcInterface(ParserConfiguration.PARSER_CONFIGURATION);
142     }
143     
144     /**
145      * @see org.objectweb.util.explorer.swing.api.SwingExplorer#getTreeItf()
146      */

147     public Tree getTreeItf(){
148         return (Tree)getFcInterface(Tree.TREE);
149     }
150     
151     /**
152      * @see org.objectweb.util.explorer.swing.api.SwingExplorer#getExplorerItf()
153      */

154     public Explorer getExplorerItf(){
155         return (Explorer)getFcInterface(Explorer.EXPLORER);
156     }
157
158     /**
159      * @see org.objectweb.util.explorer.swing.api.SwingExplorer#getViewPanelItf()
160      */

161     public ViewPanel getViewPanelItf(){
162         return (ViewPanel)getFcInterface(ViewPanel.VIEW_PANEL);
163     }
164     
165     /**
166      * @see org.objectweb.util.explorer.swing.api.SwingExplorer#getStatusBarItf()
167      */

168     public StatusBar getStatusBarItf() {
169         return (StatusBar)getFcInterface(StatusBar.STATUS_BAR);
170     }
171 }
172
Popular Tags