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
Revision: 1.31
Committed: Tue May 29 17:41:32 2001 UTC (22 years, 11 months ago) by tdb
Branch: MAIN
Changes since 1.30: +3 -3 lines
Log Message:
The last of the central monitoring system packages to be changed to the newer
structure. It has changed from;

uk.org.iscream.conient.*

to;

uk.org.iscream.cms.conient.*

This is in keeping with the new style of packaging.

File Contents

# User Rev Content
1 ajm 1.1 //---PACKAGE DECLARATION---
2 tdb 1.31 package uk.org.iscream.cms.conient;
3 ajm 1.1
4     //---IMPORTS---
5     import javax.swing.*;
6     import javax.swing.border.*;
7     import java.awt.*;
8     import java.awt.event.*;
9    
10     /**
11 ajm 1.15 * This is the main class of the Conient client.
12 ajm 1.1 *
13 ajm 1.15 * This sets up the control panel, the data panel
14     * and its own display.
15     *
16 ajm 1.16 * @author $Author: ajm4 $
17 tdb 1.31 * @version $Id: Conient.java,v 1.30 2001/03/22 00:39:52 ajm4 Exp $
18 ajm 1.1 */
19 ajm 1.16 public class Conient extends JFrame {
20 ajm 1.1
21     //---FINAL ATTRIBUTES---
22    
23     /**
24     * The current CVS revision of this class
25     */
26 tdb 1.31 public final String REVISION = "$Revision: 1.30 $";
27 ajm 1.15
28     /**
29     * The initial width of the window
30     */
31 ajm 1.27 private final int DEFAULT_WIDTH = 700;
32 ajm 1.15
33     /**
34     * The initial height of the window
35     */
36     private final int DEFAULT_HEIGHT = 600;
37 ajm 1.9
38 ajm 1.15 /**
39 ajm 1.19 * The default configuration fle
40     * This can be specified on the command line
41 ajm 1.15 */
42 ajm 1.19 public static final String DEFAULT_CONFIG_FILE = "./etc/default.conf";
43 ajm 1.1
44 ajm 1.22 /**
45     * The time in seconds to display the splash
46     * screen for
47     */
48     public static final int DISPLAY_SPLASH_TIME_SECONDS = 3;
49    
50 ajm 1.1 //---STATIC METHODS---
51    
52 ajm 1.15 /**
53     * The first method that is called.
54     * Sets up the various panels
55     *
56     * @param args the command line arguments
57     */
58 ajm 1.1 public static void main(String[] args) {
59 ajm 1.9 // get the host from the command line if they gave it
60     String host = null;
61 ajm 1.19 String configFile = DEFAULT_CONFIG_FILE;
62 ajm 1.9 if (args.length == 1) {
63 ajm 1.19 configFile = args[0];
64 ajm 1.9 }
65 ajm 1.19
66     // start the configuration system
67     Configuration.initialise(configFile);
68 ajm 1.8
69 ajm 1.9 // the data display panel
70     DataPanel data = new DataPanel();
71    
72     // the control panel
73     ControlPanel control = new ControlPanel(data);
74 ajm 1.1
75 ajm 1.9 // the main frame (passed the two panels)
76 ajm 1.16 Conient client = new Conient(data, control);
77 ajm 1.23 conientFrame = (Frame) client;
78 ajm 1.30 Conient.addMessage("Conient {an i-scream Client} (c) 2001 The i-scream Project (http://www.i-scream.org.uk)");
79 ajm 1.19
80 ajm 1.16 Conient.addMessage("Conient ready.");
81 ajm 1.22
82 ajm 1.1 }
83 ajm 1.23
84     /**
85     * A static accessor, allowing components of the system
86     * to get hold of the root frame of the system.
87     *
88     * see conientFrame attribute for details.
89     *
90     * @return the root Conient frame
91     */
92     public static Frame getFrame() {
93     return conientFrame;
94     }
95 ajm 1.1
96     //---CONSTRUCTORS---
97    
98     /**
99 ajm 1.9 * Creates a new Swing Client Frame
100 ajm 1.1 */
101 ajm 1.28 private Conient(JSplitPane data, ControlPanel control) {
102 ajm 1.9 // set up the Frame
103 ajm 1.17 super("Conient {an i-scream Client}");
104 ajm 1.15 setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
105 ajm 1.24 setJMenuBar(control.getMenuBar());
106    
107 ajm 1.15 // set what happens when the X in the corner is clicked
108 ajm 1.9 addWindowListener(new WindowAdapter() {
109     public void windowClosing(WindowEvent e) {System.exit(0);}
110     });
111 ajm 1.8
112 ajm 1.15 // add the control pane to the top border
113 tdb 1.14 getContentPane().add(control, "North");
114 ajm 1.28 // add the data pane to the centre
115     getContentPane().add(data);
116 ajm 1.15
117     // setup the status panel
118 ajm 1.9 JPanel bottom = new JPanel();
119     bottom.setLayout(new BorderLayout());
120     _messages.setEditable(false);
121     _messages.setRows(3);
122     JScrollPane messagesPane = new JScrollPane(_messages);
123     messagesPane.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 102)), " Messages "));
124     bottom.add(messagesPane, "Center");
125 ajm 1.11 JPanel statusPanel = new JPanel();
126 ajm 1.12 JPanel linkPanel = new JPanel();
127 ajm 1.20 linkPanel.setLayout(new GridLayout(1,2));
128 ajm 1.12 linkPanel.add(_controlStatus);
129     linkPanel.add(_dataStatus);
130 ajm 1.20 statusPanel.setLayout(new GridLayout(2,1));
131 ajm 1.12 statusPanel.add(linkPanel);
132 ajm 1.11 statusPanel.add(_queueStatus);
133     bottom.add(statusPanel, "South");
134 ajm 1.15
135     // add the status panel to the bottom border
136 ajm 1.9 getContentPane().add(bottom, "South");
137 ajm 1.8
138 ajm 1.21 // a nice icon for the window
139 ajm 1.25 setIconImage((new ImageIcon("./resources/server.gif")).getImage());
140 ajm 1.22
141     // and just because we can, a silly splash screen
142     // of the dudes that did this funky gibble
143     Splash splash = new Splash();
144     splash.show();
145     // wait
146     try {
147     Thread.sleep(DISPLAY_SPLASH_TIME_SECONDS * 1000);
148     } catch (InterruptedException e) {
149     // don't do anything, we don't care
150     }
151     //loose the window
152     splash.dispose();
153     splash = null;
154     // show the main window
155 ajm 1.1 show();
156     }
157    
158     //---PUBLIC METHODS---
159    
160     //---PRIVATE METHODS---
161    
162 ajm 1.9 //---ACCESSOR/MUTATOR METHODS---
163 ajm 1.1
164 ajm 1.15 /**
165     * Sets the control link status.
166     *
167     * @param status the message
168     */
169 ajm 1.12 public static void setControlStatus(String status) {
170     _controlStatus.setText("Control Link: " + status);
171     _controlStatus.repaint();
172     }
173    
174 ajm 1.15 /**
175     * Sets the data link status.
176     *
177     * @param status the message
178     */
179 ajm 1.12 public static void setDataStatus(String status) {
180     _dataStatus.setText("Data Link: " + status);
181     _dataStatus.repaint();
182 ajm 1.9 }
183 ajm 1.1
184 ajm 1.15 /**
185     * Updates the queue status.
186     *
187     * @param currentQueue
188     * @param numElements
189     */
190 ajm 1.11 public static void setQueueStatus(int currentQueue, int numElements) {
191     _queueStatus.setText("Data Queue : " + currentQueue + " Packets Recieved : " + numElements);
192     _queueStatus.repaint();
193     }
194    
195 ajm 1.15 /**
196     * Adds a system message to the messages list
197     *
198     * @param message the new message
199     */
200 ajm 1.9 public static void addMessage(String message) {
201     _messages.insert(message + "\n", 0);
202     }
203 ajm 1.13
204 ajm 1.1 //---ATTRIBUTES---
205 ajm 1.13
206     //---STATIC ATTRIBUTES---
207    
208 ajm 1.15 /**
209     * Displays information about the data link
210     */
211 ajm 1.12 static JLabel _controlStatus = new JLabel("Control Link: Disconnected", JLabel.LEFT);
212 ajm 1.9 {
213 ajm 1.12 _controlStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
214 ajm 1.11 }
215    
216 ajm 1.15 /**
217     * Displays information about the data link
218     */
219 ajm 1.12 static JLabel _dataStatus = new JLabel("Data Link: Disconnected", JLabel.LEFT);
220 ajm 1.11 {
221 ajm 1.12 _dataStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
222 ajm 1.11 }
223    
224 ajm 1.15 /**
225     * Displays information about the inbound data queue.
226     */
227 ajm 1.13 static JLabel _queueStatus = new JLabel(" ", JLabel.LEFT);
228 ajm 1.11 {
229     _queueStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
230     }
231 ajm 1.15
232     /**
233     * The place where system messages are written.
234     */
235 ajm 1.9 static JTextArea _messages = new JTextArea();
236 ajm 1.18 {
237     _messages.setLineWrap(true);
238 ajm 1.22 }
239 ajm 1.23
240     /**
241     * Holds a reference to the root frame for Conient
242     * This is only used by dialogs (specifically the configurationn
243     * dialog) so that it can be modal, please use the accessor.
244     */
245     private static Frame conientFrame;
246 ajm 1.22
247     //---INNER CLASSES----
248    
249     /**
250     * An inner class to display a splash screen
251     */
252     private class Splash extends JWindow {
253    
254     /**
255     * Constructs a new splash screen
256     */
257     public Splash() {
258     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
259     JPanel splash = new JPanel();
260     splash.setBackground(Color.black);
261 ajm 1.25 JLabel image = new JLabel((new ImageIcon("./resources/i-scream-splash.gif")));
262 ajm 1.22 splash.add(image);
263     setContentPane(splash);
264     Dimension screen = getToolkit().getScreenSize();
265     pack();
266     setLocation((screen.width - getSize().width) / 2,
267     (screen.height - getSize().height) / 2);
268    
269    
270     }
271 ajm 1.18 }
272 ajm 1.8 }