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

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/ControlPanel.java (file contents):
Revision 1.4 by ajm, Mon Jan 22 12:48:38 2001 UTC vs.
Revision 1.8 by ajm, Mon Feb 26 18:40:25 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 + package uk.ac.ukc.iscream.conient;
3  
4   //---IMPORTS---
5   import uk.ac.ukc.iscream.util.*;
6   import javax.swing.*;
7 < import java.awt.*;
8 < import java.awt.event.*;
7 > import java.awt.BorderLayout;
8 > import java.awt.event.ActionListener;
9 > import java.awt.event.ActionEvent;
10  
11   /**
12   * This panel holds the toolbar at the top.
13   * The tool bar dispatches events to the ConnectionHandler.
14   *
15 + * It also creates and starts the ConnectionHandler which is the
16 + * main thread for this application
17 + *
18   * @author  $Author$
19   * @version $Id$
20   */
# Line 26 | Line 31 | public class ControlPanel extends JPanel {
31      
32   //---CONSTRUCTORS---
33  
34 +    /**
35 +     * Constructs a new ControlPanel.
36 +     *
37 +     * @param data the data panel to be passed to the ConnectionHandler
38 +     */
39      public ControlPanel(DataPanel data) {
40          super();
41          setLayout(new BorderLayout());
42 <        _data = data;
33 <        _handler = new ConnectionHandler(_data, _actionQueue);
42 >        _handler = new ConnectionHandler(data, _actionQueue);
43          add(_toolBar, "North");
44          _handler.start();
45      }
# Line 39 | Line 48 | public class ControlPanel extends JPanel {
48    
49   //---PRIVATE METHODS---
50  
51 +    /**
52 +     * Sets up the tool bar, adding action listeners
53 +     * to dispatch events to the ConnectionHandler
54 +     */
55      private JToolBar setupToolBar() {
56 <        JButton connectButton = new JButton("Connect");
56 >        JButton connectButton = new JButton("Connect", new ImageIcon("./uk/ac/ukc/iscream/conient/control16.gif"));
57          connectButton.addActionListener(new ActionListener() {
58              public void actionPerformed(ActionEvent e) {
59                  _actionQueue.add(new Integer(ConnectionHandler.CONNECT));
60              }
61          });
62          
63 <        JButton startDataButton = new JButton("Start Data");
63 >        JButton startDataButton = new JButton("Start Data", new ImageIcon("./uk/ac/ukc/iscream/conient/data16.gif"));
64          startDataButton.addActionListener(new ActionListener() {
65              public void actionPerformed(ActionEvent e) {
66                  _actionQueue.add(new Integer(ConnectionHandler.STARTDATA));
67              }
68          });
69          
70 <        JButton stopDataButton = new JButton("Stop Data");
70 >        JButton stopDataButton = new JButton("Stop Data", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
71          stopDataButton.addActionListener(new ActionListener() {
72              public void actionPerformed(ActionEvent e) {
73                  _actionQueue.add(new Integer(ConnectionHandler.STOPDATA));
74              }
75          });
76          
77 <        JButton disconnectButton = new JButton("Disconnect");
77 >        JButton disconnectButton = new JButton("Disconnect", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
78          disconnectButton.addActionListener(new ActionListener() {
79              public void actionPerformed(ActionEvent e) {
80                  _actionQueue.add(new Integer(ConnectionHandler.DISCONNECT));
81              }
82          });
83          
84 <        JButton quitButton = new JButton("Quit");
84 >        JButton quitButton = new JButton("Quit", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
85          quitButton.addActionListener(new ActionListener() {
86              public void actionPerformed(ActionEvent e) {
87                  _actionQueue.add(new Integer(ConnectionHandler.QUIT));
88              }
89          });
90          
91 +        JButton configButton = new JButton("Config");
92 +        configButton.addActionListener(new ActionListener() {
93 +            public void actionPerformed(ActionEvent e) {
94 +                Configuration.getInstance().GUIReconfiguration();
95 +            }
96 +        });
97 +        
98          JToolBar bar = new JToolBar(JToolBar.HORIZONTAL);
99          bar.add(connectButton);
100          bar.add(startDataButton);
101          bar.add(stopDataButton);
102          bar.add(disconnectButton);
103          bar.add(quitButton);
104 +        bar.add(configButton);
105 +        bar.add(Box.createGlue());
106 +        JLabel image = new JLabel(new ImageIcon("./uk/ac/ukc/iscream/conient/i-scream.gif"));
107 +        bar.add(image);
108          return bar;
109      }
110  
# Line 88 | Line 112 | public class ControlPanel extends JPanel {
112  
113   //---ATTRIBUTES---
114  
115 <    DataPanel _data;
115 >    /**
116 >     * The tool bar for the control panel
117 >     */    
118      JToolBar _toolBar = setupToolBar();
119      
120 +    /**
121 +     * The queue that we will add actions to.
122 +     */
123      Queue _actionQueue = new Queue();
124 +    
125 +    /**
126 +     * The connection handler in use by the system.
127 +     */
128      ConnectionHandler _handler;
129  
130   //---STATIC ATTRIBUTES---

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines