KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > explorer > MainPDA


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
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: MainPDA.java,v 1.4 2005/07/01 15:55:17 moroy Exp $
27 ====================================================================*/

28 package org.objectweb.openccm.explorer;
29
30 import org.objectweb.fractal.adl.ADLException;
31 import org.objectweb.fractal.adl.Factory;
32 import org.objectweb.fractal.adl.FactoryFactory;
33 import org.objectweb.fractal.api.Component;
34 import org.objectweb.fractal.api.NoSuchInterfaceException;
35 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
36 import org.objectweb.fractal.util.Fractal;
37 import org.objectweb.openccm.explorer.CORBA.ConsoleFactory;
38 import org.objectweb.openccm.explorer.menu.Menu;
39 import org.objectweb.util.explorer.api.Tree;
40 import org.objectweb.util.explorer.context.api.ContextParser;
41 import org.objectweb.util.explorer.parser.api.ParserConfiguration;
42 import org.objectweb.util.explorer.swing.api.Explorer;
43 import org.objectweb.util.explorer.swing.api.StatusBar;
44 import org.objectweb.util.explorer.swing.api.ViewPanel;
45 import org.objectweb.util.explorer.swing.lib.DefaultTreePanel;
46
47 /** The java API's imports */
48 import java.awt.Dimension JavaDoc;
49 import java.awt.BorderLayout JavaDoc;
50 //import java.awt.HeadlessException;
51

52 import javax.swing.JTabbedPane JavaDoc;
53
54 /**
55  * This class defines the main frame of the OpenCCM Explorer designed for PDA
56  *
57  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
58  * @version 0.1
59  */

60 public class MainPDA
61      extends Main
62 {
63
64     /**
65      * Initializes the OpenCCM Browser frame
66      */

67     protected void init(String JavaDoc contextPropertyFile, String JavaDoc[] browserPropertyFile){
68
69         try {
70             // Creates a Fractal Explorer instance.
71
Factory f = FactoryFactory.getFactory(FactoryFactory.FRACTAL_BACKEND);
72             Component explorer = (Component)f.newComponent("org.objectweb.openccm.explorer.SwingCCMExplorer",null);
73             Fractal.getLifeCycleController(explorer).startFc();
74
75             // Loads the configuration file.
76
ParserConfiguration parser = (ParserConfiguration)explorer.getFcInterface(ParserConfiguration.PARSER_CONFIGURATION);
77             for (int i = 0; i < browserPropertyFile.length; i++) {
78                 parser.addPropertyFile(browserPropertyFile[i]);
79             }
80             parser.parse();
81
82             // Loads the context configuration file.
83
ContextParser cParser = (ContextParser)explorer.getFcInterface(ContextParser.CONTEXT_PARSER);
84             cParser.parse(contextPropertyFile);
85             
86             Explorer explorerItf = (Explorer)explorer.getFcInterface(Explorer.EXPLORER);
87             Tree treeItf = (Tree)explorer.getFcInterface(Tree.TREE);
88             
89             //setIconImage(createIcon("icons/tools.png").getImage());
90

91             // Creates the menu
92
Menu menu = new Menu(this, explorer);
93             
94             explorerItf.setMultipleRoles(true);
95             explorerItf.setCurrentRoles(new String JavaDoc[]{"user view","Deployment administrator","Components administrator","CORBA Administrator","CosNaming administrator"});
96             explorerItf.setMenuBar(menu.getMenuBar());
97             explorerItf.setToolBar(menu.getToolBar());
98             populateTree(treeItf);
99             
100             ViewPanel viewPanelItf = (ViewPanel)explorer.getFcInterface(ViewPanel.VIEW_PANEL);
101             StatusBar statusBarItf = (StatusBar)explorer.getFcInterface(StatusBar.STATUS_BAR);
102             
103             // Initializes the tree using in JDialog Boxes,
104
initializeTreeDialog(treeItf);
105
106             setJMenuBar(menu.getMenuBar());
107
108             getContentPane().setLayout(new BorderLayout JavaDoc());
109             getContentPane().add(menu.getToolBar(),BorderLayout.NORTH);
110             JTabbedPane JavaDoc tabbedPane = new JTabbedPane JavaDoc();
111             tabbedPane.addTab("Tree", new DefaultTreePanel(explorerItf.getTree()));
112             tabbedPane.addTab("View", viewPanelItf.getViewPanel());
113             getContentPane().add(tabbedPane, BorderLayout.CENTER);
114             getContentPane().add(statusBarItf.getStatusBar(),BorderLayout.SOUTH);
115
116             //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
117
addWindowListener(new OpenCCMWindowListener(treeItf));
118             pack();
119
120             // Centers the frame
121
Dimension JavaDoc screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
122             setLocation((screenSize.width - getWidth()) / 2, (screenSize.height - getHeight()) / 2);
123
124             setVisible(true);
125         } catch (ADLException e) {
126             ConsoleFactory.getDebugConsole().add(e.getMessage());
127         } catch (IllegalLifeCycleException e) {
128             ConsoleFactory.getDebugConsole().add(e.getMessage());
129         } catch (NoSuchInterfaceException e) {
130             ConsoleFactory.getDebugConsole().add(e.getMessage());
131         }
132         catch (Exception JavaDoc e) {
133             ConsoleFactory.getDebugConsole().add(e.getMessage());
134         }
135     }
136
137     /**
138      * Default constructor
139      */

140     public MainPDA(String JavaDoc contextPropertyFile, String JavaDoc[] browserPropertyFile) {
141         super(contextPropertyFile, browserPropertyFile);
142     }
143     
144 }
145
Popular Tags