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.14 by tdb, Mon Jan 22 19:35:36 2001 UTC vs.
Revision 1.20 by ajm, Sun Feb 4 00:04:01 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 + package uk.ac.ukc.iscream.conient;
3  
4   //---IMPORTS---
5   import javax.swing.*;
# Line 7 | Line 8 | import java.awt.*;
8   import java.awt.event.*;
9  
10   /**
11 < * Root for the SwingClient...starts the whole show off...
11 > * This is the main class of the Conient client.
12   *
13 + * This sets up the control panel, the data panel
14 + * and its own display.
15 + *
16   * @author  $Author$
17   * @version $Id$
18   */
19 < public class SwingClient extends JFrame {
19 > public class Conient extends JFrame {
20  
21   //---FINAL ATTRIBUTES---
22  
# Line 20 | Line 24 | public class SwingClient extends JFrame {
24       * The current CVS revision of this class
25       */
26      public final String REVISION = "$Revision$";
27 <        
28 <    private final int width = 600;
29 <    private final int height = 600;
27 >
28 >    /**
29 >     * The initial width of the window
30 >     */        
31 >    private final int DEFAULT_WIDTH = 600;
32      
33 <    // the well known port
34 <    public static final int PORT = 4510;
33 >    /**
34 >     * The initial height of the window
35 >     */
36 >    private final int DEFAULT_HEIGHT = 600;
37      
38 +    /**
39 +     * The default configuration fle
40 +     * This can be specified on the command line
41 +     */
42 +    public static final String DEFAULT_CONFIG_FILE = "./etc/default.conf";
43 +    
44   //---STATIC METHODS---
45  
46 +    /**
47 +     * The first method that is called.
48 +     * Sets up the various panels
49 +     *
50 +     * @param args the command line arguments
51 +     */
52      public static void main(String[] args) {
53          // get the host from the command line if they gave it
54          String host = null;
55 +        String configFile = DEFAULT_CONFIG_FILE;
56          if (args.length == 1) {
57 <            host = args[0];
57 >            configFile = args[0];
58          }
59 +
60 +        // start the configuration system
61 +        Configuration.initialise(configFile);
62  
63          // the data display panel
64          DataPanel data = new DataPanel();
# Line 43 | Line 67 | public class SwingClient extends JFrame {
67          ControlPanel control = new ControlPanel(data);
68          
69          // the main frame (passed the two panels)
70 <        SwingClient client = new SwingClient(data, control);
71 <        SwingClient.addMessage("Client started");
70 >        Conient client = new Conient(data, control);
71 >        Conient.addMessage("Conient {an i-scream Client} © 2001 University of Kent & Project i-scream");
72 >
73 >        Conient.addMessage("Conient ready.");
74      }
75  
76      
# Line 53 | Line 79 | public class SwingClient extends JFrame {
79      /**
80       * Creates a new Swing Client Frame
81       */
82 <    private SwingClient(JPanel data, JPanel control) {
82 >    private Conient(JPanel data, JPanel control) {
83          // set up the Frame
84 <        super("I-Scream Client");
85 <        
86 <        setSize(width, height);
84 >        super("Conient {an i-scream Client}");
85 >        setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
86 >
87 >        // set what happens when the X in the corner is clicked        
88          addWindowListener(new WindowAdapter() {
89              public void windowClosing(WindowEvent e) {System.exit(0);}
90          });
91  
92 +        // add the control pane to the top border
93          getContentPane().add(control, "North");
94          
95 +        // create a scrollable pane for the data in the centre
96          JScrollPane scrollPane = new JScrollPane(data);
97          getContentPane().add(scrollPane, "Center");
98 <        
99 <        
98 >
99 >        // setup the status panel        
100          JPanel bottom = new JPanel();
101          bottom.setLayout(new BorderLayout());
102          _messages.setEditable(false);
103          _messages.setRows(3);
104          JScrollPane messagesPane = new JScrollPane(_messages);
105          messagesPane.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 102)), " Messages "));
77
106          bottom.add(messagesPane, "Center");
107          JPanel statusPanel = new JPanel();
108          JPanel linkPanel = new JPanel();
109 <        linkPanel.setLayout(new GridLayout(2,1));
109 >        linkPanel.setLayout(new GridLayout(1,2));
110          linkPanel.add(_controlStatus);
111          linkPanel.add(_dataStatus);
112 <        statusPanel.setLayout(new GridLayout(1,3));
112 >        statusPanel.setLayout(new GridLayout(2,1));
113          statusPanel.add(linkPanel);
114          statusPanel.add(_queueStatus);
87        
115          bottom.add(statusPanel, "South");
116 +
117 +        // add the status panel to the bottom border
118          getContentPane().add(bottom, "South");
119          
120          // show the window
# Line 98 | Line 127 | public class SwingClient extends JFrame {
127  
128   //---ACCESSOR/MUTATOR METHODS---
129  
130 +    /**
131 +     * Sets the control link status.
132 +     *
133 +     * @param status the message
134 +     */
135      public static void setControlStatus(String status) {
136          _controlStatus.setText("Control Link: " + status);
137          _controlStatus.repaint();
138      }
139      
140 +    /**
141 +     * Sets the data link status.
142 +     *
143 +     * @param status the message
144 +     */
145      public static void setDataStatus(String status) {
146          _dataStatus.setText("Data Link: " + status);
147          _dataStatus.repaint();
148      }
149  
150 +    /**
151 +     * Updates the queue status.
152 +     *
153 +     * @param currentQueue
154 +     * @param numElements
155 +     */
156      public static void setQueueStatus(int currentQueue, int numElements) {
157          _queueStatus.setText("Data Queue : " + currentQueue + " Packets Recieved : " + numElements);
158          _queueStatus.repaint();
159      }
160  
161 +    /**
162 +     * Adds a system message to the messages list
163 +     *
164 +     * @param message the new message
165 +     */
166      public static void addMessage(String message) {
167          _messages.insert(message + "\n", 0);
168      }
169  
170   //---ATTRIBUTES---
171      
122    ImageIcon _serverIcon = new ImageIcon("server.gif");
123    JLabel _serverCountLabel;
124    int _serverCount = 0;
125    
172   //---STATIC ATTRIBUTES---
173      
174 +    /**
175 +     * Displays information about the data link
176 +     */
177      static JLabel _controlStatus = new JLabel("Control Link: Disconnected", JLabel.LEFT);
178      {
179          _controlStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
180      }
181      
182 +    /**
183 +     * Displays information about the data link
184 +     */
185      static JLabel _dataStatus = new JLabel("Data Link: Disconnected", JLabel.LEFT);
186      {
187          _dataStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
188      }
189      
190 +    /**
191 +     * Displays information about the inbound data queue.
192 +     */
193      static JLabel _queueStatus = new JLabel(" ", JLabel.LEFT);
194      {
195          _queueStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
196      }
197 +    
198 +    /**
199 +     * The place where system messages are written.
200 +     */
201      static JTextArea _messages = new JTextArea();
202 +    {
203 +        _messages.setLineWrap(true);
204 +    }
205   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines