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.10 by ajm, Mon Jan 22 03:03:39 2001 UTC vs.
Revision 1.21 by ajm, Mon Feb 5 01:26:04 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 + package uk.ac.ukc.iscream.conient;
3  
4   //---IMPORTS---
5   import javax.swing.*;
6   import javax.swing.border.*;
6 import java.awt.Color;
7 import uk.ac.ukc.iscream.util.*;
8
7   import java.awt.*;
8   import java.awt.event.*;
11 import java.net.*;
12 import java.io.*;
13 import java.util.Date;
14 import java.text.DateFormat;
15 import java.util.Locale;
16 import java.util.HashMap;
17 import javax.swing.border.*;
9  
10   /**
11 < * NASTY AND BASIC, PLEASE DON'T COMPLAIN
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 30 | 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 53 | 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");
72 <        SwingClient.setStatus("Disconnected");
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 64 | 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 <        
77 <        // build the frame
92 >        // add the control pane to the top border
93          getContentPane().add(control, "North");
79        getContentPane().add(data, "Center");
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 +        // 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 "));
87
106          bottom.add(messagesPane, "Center");
107 <        bottom.add(_status, "South");
107 >        JPanel statusPanel = new JPanel();
108 >        JPanel linkPanel = new JPanel();
109 >        linkPanel.setLayout(new GridLayout(1,2));
110 >        linkPanel.add(_controlStatus);
111 >        linkPanel.add(_dataStatus);
112 >        statusPanel.setLayout(new GridLayout(2,1));
113 >        statusPanel.add(linkPanel);
114 >        statusPanel.add(_queueStatus);
115 >        bottom.add(statusPanel, "South");
116 >
117 >        // add the status panel to the bottom border
118          getContentPane().add(bottom, "South");
119          
120 +        // a nice icon for the window
121 +        setIconImage((new ImageIcon("./uk/ac/ukc/iscream/conient/server.gif")).getImage());
122          // show the window
123          show();
124      }
# Line 99 | Line 129 | public class SwingClient extends JFrame {
129  
130   //---ACCESSOR/MUTATOR METHODS---
131  
132 <    public static void setStatus(String status) {
133 <        _status.setText(status);
134 <        _status.repaint();
132 >    /**
133 >     * Sets the control link status.
134 >     *
135 >     * @param status the message
136 >     */
137 >    public static void setControlStatus(String status) {
138 >        _controlStatus.setText("Control Link: " + status);
139 >        _controlStatus.repaint();
140      }
141 +    
142 +    /**
143 +     * Sets the data link status.
144 +     *
145 +     * @param status the message
146 +     */
147 +    public static void setDataStatus(String status) {
148 +        _dataStatus.setText("Data Link: " + status);
149 +        _dataStatus.repaint();
150 +    }
151  
152 +    /**
153 +     * Updates the queue status.
154 +     *
155 +     * @param currentQueue
156 +     * @param numElements
157 +     */
158 +    public static void setQueueStatus(int currentQueue, int numElements) {
159 +        _queueStatus.setText("Data Queue : " + currentQueue + " Packets Recieved : " + numElements);
160 +        _queueStatus.repaint();
161 +    }
162 +
163 +    /**
164 +     * Adds a system message to the messages list
165 +     *
166 +     * @param message the new message
167 +     */
168      public static void addMessage(String message) {
169          _messages.insert(message + "\n", 0);
170      }
110 //---ATTRIBUTES---
171  
172 <    static JLabel _status = new JLabel("Initialising", JLabel.LEFT);
172 > //---ATTRIBUTES---
173 >    
174 > //---STATIC ATTRIBUTES---
175 >    
176 >    /**
177 >     * Displays information about the data link
178 >     */
179 >    static JLabel _controlStatus = new JLabel("Control Link: Disconnected", JLabel.LEFT);
180      {
181 <        _status.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
182 <    }      
181 >        _controlStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
182 >    }
183      
184 <    ImageIcon _serverIcon = new ImageIcon("server.gif");
185 <    JLabel _serverCountLabel;
186 <    int _serverCount = 0;
187 <    static JTextArea _messages = new JTextArea();
184 >    /**
185 >     * Displays information about the data link
186 >     */
187 >    static JLabel _dataStatus = new JLabel("Data Link: Disconnected", JLabel.LEFT);
188 >    {
189 >        _dataStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
190 >    }
191      
192 < //---STATIC ATTRIBUTES---
192 >    /**
193 >     * Displays information about the inbound data queue.
194 >     */
195 >    static JLabel _queueStatus = new JLabel(" ", JLabel.LEFT);
196 >    {
197 >        _queueStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
198 >    }
199      
200 +    /**
201 +     * The place where system messages are written.
202 +     */
203 +    static JTextArea _messages = new JTextArea();
204 +    {
205 +        _messages.setLineWrap(true);
206 +    }
207   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines