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.11
Committed: Tue Feb 27 15:11:44 2001 UTC (23 years, 2 months ago) by ajm
Branch: MAIN
Changes since 1.10: +13 -11 lines
Log Message:
Made change to handle all resources (images etc).
Modified all scripts and classes which handles resources.
Moves to ./build/resources.
Also fixed bug in makefile which didn't copy ./build/etc on install.

File Contents

# Content
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.BorderLayout;
8 import java.net.URL;
9 import java.awt.event.ActionListener;
10 import java.awt.event.ActionEvent;
11
12 /**
13 * This panel holds the toolbar at the top.
14 * The tool bar dispatches events to the ConnectionHandler.
15 *
16 * It also creates and starts the ConnectionHandler which is the
17 * main thread for this application
18 *
19 * @author $Author: ajm4 $
20 * @version $Id: ControlPanel.java,v 1.10 2001/02/27 03:34:45 ajm4 Exp $
21 */
22 public class ControlPanel extends JPanel {
23
24 //---FINAL ATTRIBUTES---
25
26 /**
27 * The current CVS revision of this class
28 */
29 public final String REVISION = "$Revision: 1.10 $";
30
31 //---STATIC METHODS---
32
33 //---CONSTRUCTORS---
34
35 /**
36 * Constructs a new ControlPanel.
37 *
38 * @param data the data panel to be passed to the ConnectionHandler
39 */
40 public ControlPanel(DataPanel data) {
41 super();
42 setLayout(new BorderLayout());
43 _handler = new ConnectionHandler(data, _actionQueue);
44 add(_toolBar, "North");
45 _handler.start();
46 }
47
48 //---PUBLIC METHODS---
49
50 //---PRIVATE METHODS---
51
52 /**
53 * Sets up the tool bar, adding action listeners
54 * to dispatch events to the ConnectionHandler
55 */
56 private JToolBar setupToolBar() {
57
58 JButton connectButton = new JButton("Connect", new ImageIcon("./resources/control16.gif"));
59 connectButton.addActionListener(new ActionListener() {
60 public void actionPerformed(ActionEvent e) {
61 _actionQueue.add(new Integer(ConnectionHandler.CONNECT));
62 }
63 });
64 JButton disconnectButton = new JButton("Disconnect", new ImageIcon("./resources/stop16.gif"));
65 disconnectButton.addActionListener(new ActionListener() {
66 public void actionPerformed(ActionEvent e) {
67 _actionQueue.add(new Integer(ConnectionHandler.DISCONNECT));
68 }
69 });
70
71 JButton startDataButton = new JButton("Start Data", new ImageIcon("./resources/data16.gif"));
72 startDataButton.addActionListener(new ActionListener() {
73 public void actionPerformed(ActionEvent e) {
74 _actionQueue.add(new Integer(ConnectionHandler.STARTDATA));
75 }
76 });
77 JButton stopDataButton = new JButton("Stop Data", new ImageIcon("./resources/stop16.gif"));
78 stopDataButton.addActionListener(new ActionListener() {
79 public void actionPerformed(ActionEvent e) {
80 _actionQueue.add(new Integer(ConnectionHandler.STOPDATA));
81 }
82 });
83
84 JToolBar bar = new JToolBar(JToolBar.HORIZONTAL);
85 bar.add(connectButton);
86 bar.add(disconnectButton);
87 bar.addSeparator();
88 bar.add(startDataButton);
89 bar.add(stopDataButton);
90
91 bar.add(Box.createGlue());
92 JLabel image = new JLabel(new ImageIcon("./resources/i-scream.gif"));
93 bar.add(image);
94 return bar;
95 }
96
97 public JMenuBar setupMenuBar() {
98 JMenuBar bar = new JMenuBar();
99
100 JMenu conientMenu = new JMenu("Conient");
101 JMenuItem modifiyConfig = new JMenuItem("Modifiy Configuration");
102 modifiyConfig.addActionListener(new ActionListener() {
103 public void actionPerformed(ActionEvent e) {
104 Configuration.getInstance().GUIReconfiguration();
105 }
106 });
107 conientMenu.add(modifiyConfig);
108 conientMenu.addSeparator();
109 JMenuItem saveConfig = new JMenuItem("Save Configuration");
110 saveConfig.addActionListener(new ActionListener() {
111 public void actionPerformed(ActionEvent e) {
112 if (Configuration.getInstance().getUsingSpecificConfig()) {
113 Configuration.getInstance().saveConfiguration();
114 } else {
115 Configuration.getInstance().saveNewConfiguration();
116 }
117 }
118 });
119 conientMenu.add(saveConfig);
120
121 JMenuItem saveAsConfig = new JMenuItem("Save Configuration As...");
122 saveAsConfig.addActionListener(new ActionListener() {
123 public void actionPerformed(ActionEvent e) {
124 Configuration.getInstance().saveNewConfiguration();
125 }
126 });
127 conientMenu.add(saveAsConfig);
128
129 JMenuItem saveDefaultConfig = new JMenuItem("Save Configuration As Default");
130 saveDefaultConfig.addActionListener(new ActionListener() {
131 public void actionPerformed(ActionEvent e) {
132 Configuration.getInstance().saveDefaultConfiguration();
133 }
134 });
135 conientMenu.add(saveDefaultConfig);
136
137 JMenuItem loadConfig = new JMenuItem("Load Configuration...");
138 loadConfig.addActionListener(new ActionListener() {
139 public void actionPerformed(ActionEvent e) {
140 Configuration.getInstance().loadConfiguration();
141 }
142 });
143 conientMenu.add(loadConfig);
144 conientMenu.addSeparator();
145 JMenuItem quit = new JMenuItem("Quit");
146 quit.addActionListener(new ActionListener() {
147 public void actionPerformed(ActionEvent e) {
148 _actionQueue.add(new Integer(ConnectionHandler.QUIT));
149 }
150 });
151 conientMenu.add(quit);
152 bar.add(conientMenu);
153
154 JMenu connectionMenu = new JMenu("Connection");
155 JMenuItem controlConnect = new JMenuItem("Connect", new ImageIcon("./resources/control16.gif"));
156 controlConnect.addActionListener(new ActionListener() {
157 public void actionPerformed(ActionEvent e) {
158 _actionQueue.add(new Integer(ConnectionHandler.CONNECT));
159 }
160 });
161 connectionMenu.add(controlConnect);
162 JMenuItem controlDisconnect = new JMenuItem("Disconnect", new ImageIcon("./resources/stop16.gif"));
163 controlDisconnect.addActionListener(new ActionListener() {
164 public void actionPerformed(ActionEvent e) {
165 _actionQueue.add(new Integer(ConnectionHandler.DISCONNECT));
166 }
167 });
168 connectionMenu.add(controlDisconnect);
169 connectionMenu.addSeparator();
170 JMenuItem dataConnect = new JMenuItem("Start Data", new ImageIcon("./resources/data16.gif"));
171 dataConnect.addActionListener(new ActionListener() {
172 public void actionPerformed(ActionEvent e) {
173 _actionQueue.add(new Integer(ConnectionHandler.STARTDATA));
174 }
175 });
176 connectionMenu.add(dataConnect);
177 JMenuItem dataDisconnect = new JMenuItem("Stop Data", new ImageIcon("./resources/stop16.gif"));
178 dataDisconnect.addActionListener(new ActionListener() {
179 public void actionPerformed(ActionEvent e) {
180 _actionQueue.add(new Integer(ConnectionHandler.STOPDATA));
181 }
182 });
183 connectionMenu.add(dataDisconnect);
184 bar.add(connectionMenu);
185
186 JMenu helpMenu = new JMenu("Help");
187 JMenuItem help = new JMenuItem("Help");
188 helpMenu.add(help);
189 JMenuItem about = new JMenuItem("About");
190 helpMenu.add(about);
191 bar.add(helpMenu);
192
193 return bar;
194 }
195
196 //---ACCESSOR/MUTATOR METHODS---
197
198 public JMenuBar getMenuBar() {
199 return _menuBar;
200 }
201
202 //---ATTRIBUTES---
203
204 /**
205 * The tool bar for the control panel
206 */
207 JToolBar _toolBar = setupToolBar();
208
209 /**
210 * The menu bar for the Frame
211 */
212 JMenuBar _menuBar = setupMenuBar();
213
214 /**
215 * The queue that we will add actions to.
216 */
217 Queue _actionQueue = new Queue();
218
219 /**
220 * The connection handler in use by the system.
221 */
222 ConnectionHandler _handler;
223
224 //---STATIC ATTRIBUTES---
225
226 }