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
Revision: 1.5
Committed: Wed Jan 24 03:09:46 2001 UTC (23 years, 4 months ago) by ajm
Branch: MAIN
Changes since 1.4: +25 -4 lines
Log Message:
all packaged up
all javadoc'd
still not handling stuff (sockets) right just yet....
but its all in a fit state to be PROPER and continue working and expanding on

File Contents

# User Rev Content
1 ajm 1.4 //---PACKAGE DECLARATION---
2 ajm 1.5 package uk.ac.ukc.iscream.conient;
3 ajm 1.4
4     //---IMPORTS---
5     import uk.ac.ukc.iscream.util.*;
6 ajm 1.1 import javax.swing.*;
7     import java.awt.*;
8     import java.awt.event.*;
9    
10 ajm 1.4 /**
11     * This panel holds the toolbar at the top.
12     * The tool bar dispatches events to the ConnectionHandler.
13     *
14 ajm 1.5 * It also creates and starts the ConnectionHandler which is the
15     * main thread for this application
16     *
17 ajm 1.4 * @author $Author: ajm4 $
18 ajm 1.5 * @version $Id: ControlPanel.java,v 1.4 2001/01/22 12:48:38 ajm4 Exp $
19 ajm 1.4 */
20 ajm 1.1 public class ControlPanel extends JPanel {
21 ajm 1.4
22     //---FINAL ATTRIBUTES---
23    
24     /**
25     * The current CVS revision of this class
26     */
27     public final String REVISION = "$Revision: 1.4 $";
28    
29     //---STATIC METHODS---
30    
31     //---CONSTRUCTORS---
32    
33 ajm 1.5 /**
34     * Constructs a new ControlPanel.
35     *
36     * @param data the data panel to be passed to the ConnectionHandler
37     */
38 ajm 1.1 public ControlPanel(DataPanel data) {
39     super();
40     setLayout(new BorderLayout());
41 ajm 1.5 _handler = new ConnectionHandler(data, _actionQueue);
42 ajm 1.1 add(_toolBar, "North");
43     _handler.start();
44     }
45 ajm 1.4
46     //---PUBLIC METHODS---
47    
48     //---PRIVATE METHODS---
49    
50 ajm 1.5 /**
51     * Sets up the tool bar, adding action listeners
52     * to dispatch events to the ConnectionHandler
53     */
54 ajm 1.1 private JToolBar setupToolBar() {
55     JButton connectButton = new JButton("Connect");
56     connectButton.addActionListener(new ActionListener() {
57     public void actionPerformed(ActionEvent e) {
58     _actionQueue.add(new Integer(ConnectionHandler.CONNECT));
59     }
60     });
61    
62 ajm 1.2 JButton startDataButton = new JButton("Start Data");
63     startDataButton.addActionListener(new ActionListener() {
64     public void actionPerformed(ActionEvent e) {
65     _actionQueue.add(new Integer(ConnectionHandler.STARTDATA));
66     }
67     });
68    
69     JButton stopDataButton = new JButton("Stop Data");
70     stopDataButton.addActionListener(new ActionListener() {
71     public void actionPerformed(ActionEvent e) {
72     _actionQueue.add(new Integer(ConnectionHandler.STOPDATA));
73     }
74     });
75    
76     JButton disconnectButton = new JButton("Disconnect");
77     disconnectButton.addActionListener(new ActionListener() {
78     public void actionPerformed(ActionEvent e) {
79     _actionQueue.add(new Integer(ConnectionHandler.DISCONNECT));
80     }
81     });
82    
83 ajm 1.3 JButton quitButton = new JButton("Quit");
84     quitButton.addActionListener(new ActionListener() {
85     public void actionPerformed(ActionEvent e) {
86     _actionQueue.add(new Integer(ConnectionHandler.QUIT));
87     }
88     });
89    
90 ajm 1.1 JToolBar bar = new JToolBar(JToolBar.HORIZONTAL);
91     bar.add(connectButton);
92 ajm 1.2 bar.add(startDataButton);
93     bar.add(stopDataButton);
94     bar.add(disconnectButton);
95 ajm 1.3 bar.add(quitButton);
96 ajm 1.1 return bar;
97     }
98    
99 ajm 1.4 //---ACCESSOR/MUTATOR METHODS---
100    
101     //---ATTRIBUTES---
102    
103 ajm 1.5 /**
104     * The tool bar for the control panel
105     */
106 ajm 1.1 JToolBar _toolBar = setupToolBar();
107    
108 ajm 1.5 /**
109     * The queue that we will add actions to.
110     */
111 ajm 1.1 Queue _actionQueue = new Queue();
112 ajm 1.5
113     /**
114     * The connection handler in use by the system.
115     */
116 ajm 1.1 ConnectionHandler _handler;
117 ajm 1.4
118     //---STATIC ATTRIBUTES---
119    
120     }