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