ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/Conient.java
(Generate patch)

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/Conient.java (file contents):
Revision 1.18 by ajm, Wed Jan 24 03:37:31 2001 UTC vs.
Revision 1.34 by tdb, Tue May 21 16:47:10 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org.uk
4 + * Copyright (C) 2000-2002 i-scream
5 + *
6 + * This program is free software; you can redistribute it and/or
7 + * modify it under the terms of the GNU General Public License
8 + * as published by the Free Software Foundation; either version 2
9 + * of the License, or (at your option) any later version.
10 + *
11 + * This program is distributed in the hope that it will be useful,
12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 + * GNU General Public License for more details.
15 + *
16 + * You should have received a copy of the GNU General Public License
17 + * along with this program; if not, write to the Free Software
18 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 + */
20 +
21   //---PACKAGE DECLARATION---
22 < package uk.ac.ukc.iscream.conient;
22 > package uk.org.iscream.cms.conient;
23  
24   //---IMPORTS---
25   import javax.swing.*;
# Line 28 | Line 48 | public class Conient extends JFrame {
48      /**
49       * The initial width of the window
50       */        
51 <    private final int DEFAULT_WIDTH = 600;
51 >    private final int DEFAULT_WIDTH = 700;
52      
53      /**
54       * The initial height of the window
# Line 36 | Line 56 | public class Conient extends JFrame {
56      private final int DEFAULT_HEIGHT = 600;
57      
58      /**
59 <     * The i-scream server port
59 >     * The default configuration fle
60 >     * This can be specified on the command line
61       */
62 <    public static final int PORT = 4510;
62 >    public static final String DEFAULT_CONFIG_FILE = "./etc/default.conf";
63      
64 +    /**
65 +     * The time in seconds to display the splash
66 +     * screen for
67 +     */
68 +    public static final int DISPLAY_SPLASH_TIME_SECONDS = 3;
69 +    
70   //---STATIC METHODS---
71  
72      /**
# Line 51 | Line 78 | public class Conient extends JFrame {
78      public static void main(String[] args) {
79          // get the host from the command line if they gave it
80          String host = null;
81 +        String configFile = DEFAULT_CONFIG_FILE;
82          if (args.length == 1) {
83 <            host = args[0];
83 >            configFile = args[0];
84          }
85 +
86 +        // start the configuration system
87 +        Configuration.initialise(configFile);
88  
89          // the data display panel
90          DataPanel data = new DataPanel();
# Line 63 | Line 94 | public class Conient extends JFrame {
94          
95          // the main frame (passed the two panels)
96          Conient client = new Conient(data, control);
97 <        Conient.addMessage("Conient {an i-scream Client} © 2001 University of Kent & Project i-scream");
97 >        conientFrame = (Frame) client;
98 >        Conient.addMessage("Conient {an i-scream Client} (c) 2001 The i-scream Project (http://www.i-scream.org.uk)");
99 >
100          Conient.addMessage("Conient ready.");
101 +        
102      }
69
103      
104 +    /**
105 +     * A static accessor, allowing components of the system
106 +     * to get hold of the root frame of the system.
107 +     *
108 +     * see conientFrame attribute for details.
109 +     *
110 +     * @return the root Conient frame
111 +     */
112 +    public static Frame getFrame() {
113 +        return conientFrame;
114 +    }
115 +    
116   //---CONSTRUCTORS---
117  
118      /**
119       * Creates a new Swing Client Frame
120       */
121 <    private Conient(JPanel data, JPanel control) {
121 >    private Conient(JSplitPane data, ControlPanel control) {
122          // set up the Frame
123          super("Conient {an i-scream Client}");
124          setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
125 <
125 >        setJMenuBar(control.getMenuBar());
126 >        
127          // set what happens when the X in the corner is clicked        
128          addWindowListener(new WindowAdapter() {
129              public void windowClosing(WindowEvent e) {System.exit(0);}
# Line 85 | Line 131 | public class Conient extends JFrame {
131  
132          // add the control pane to the top border
133          getContentPane().add(control, "North");
134 <        
135 <        // create a scrollable pane for the data in the centre
90 <        JScrollPane scrollPane = new JScrollPane(data);
91 <        getContentPane().add(scrollPane, "Center");
134 >        // add the data pane to the centre        
135 >        getContentPane().add(data);
136  
137          // setup the status panel        
138          JPanel bottom = new JPanel();
# Line 100 | Line 144 | public class Conient extends JFrame {
144          bottom.add(messagesPane, "Center");
145          JPanel statusPanel = new JPanel();
146          JPanel linkPanel = new JPanel();
147 <        linkPanel.setLayout(new GridLayout(2,1));
147 >        linkPanel.setLayout(new GridLayout(1,2));
148          linkPanel.add(_controlStatus);
149          linkPanel.add(_dataStatus);
150 <        statusPanel.setLayout(new GridLayout(1,3));
150 >        statusPanel.setLayout(new GridLayout(2,1));
151          statusPanel.add(linkPanel);
152          statusPanel.add(_queueStatus);
153          bottom.add(statusPanel, "South");
# Line 111 | Line 155 | public class Conient extends JFrame {
155          // add the status panel to the bottom border
156          getContentPane().add(bottom, "South");
157          
158 <        // show the window
158 >        // a nice icon for the window
159 >        setIconImage((new ImageIcon("./resources/server.gif")).getImage());
160 >
161 >        // and just because we can, a silly splash screen
162 >        // of the dudes that did this funky jibble
163 >        Splash splash = new Splash();
164 >        splash.show();
165 >        // wait
166 >        try {
167 >            Thread.sleep(DISPLAY_SPLASH_TIME_SECONDS * 1000);
168 >        } catch (InterruptedException e) {
169 >            // don't do anything, we don't care
170 >        }
171 >        //loose the window
172 >        splash.dispose();
173 >        splash = null;        
174 >        // show the main window
175          show();
176      }
177  
# Line 195 | Line 255 | public class Conient extends JFrame {
255      static JTextArea _messages = new JTextArea();
256      {
257          _messages.setLineWrap(true);
258 +    }
259 +    
260 +    /**
261 +     * Holds a reference to the root frame for Conient
262 +     * This is only used by dialogs (specifically the configurationn
263 +     * dialog) so that it can be modal, please use the accessor.
264 +     */
265 +    private static Frame conientFrame;
266 +    
267 + //---INNER CLASSES----
268 +
269 +    /**
270 +     * An inner class to display a splash screen
271 +     */
272 +    private class Splash extends JWindow {
273 +        
274 +        /**
275 +         * Constructs a new splash screen
276 +         */
277 +        public Splash() {
278 +            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
279 +            JPanel splash = new JPanel();
280 +            splash.setBackground(Color.black);
281 +            JLabel image = new JLabel((new ImageIcon("./resources/i-scream-splash.gif")));
282 +            splash.add(image);
283 +            setContentPane(splash);
284 +            Dimension screen = getToolkit().getScreenSize();
285 +            pack();
286 +            setLocation((screen.width - getSize().width) / 2,
287 +                        (screen.height - getSize().height) / 2);
288 +            
289 +            
290 +        }
291      }
292   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines