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.15
Committed: Sat May 18 18:15:56 2002 UTC (22 years ago) by tdb
Branch: MAIN
Changes since 1.14: +22 -3 lines
Log Message:
i-scream is now licensed under the GPL. I've added the GPL headers to every
source file, and put a full copy of the license in the appropriate places.
I think I've covered everything. This is going to be a mad commit ;)

File Contents

# Content
1 /*
2 * i-scream central monitoring system
3 * Copyright (C) 2000-2002 i-scream
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 //---PACKAGE DECLARATION---
21 package uk.org.iscream.cms.conient;
22
23 //---IMPORTS---
24 import uk.org.iscream.cms.server.util.*;
25 import javax.swing.*;
26 import java.awt.BorderLayout;
27 import java.net.URL;
28 import java.awt.event.ActionListener;
29 import java.awt.event.ActionEvent;
30
31 /**
32 * This panel holds the toolbar at the top.
33 * The tool bar dispatches events to the ConnectionHandler.
34 *
35 * It also creates and starts the ConnectionHandler which is the
36 * main thread for this application
37 *
38 * @author $Author: tdb $
39 * @version $Id: ControlPanel.java,v 1.14 2001/05/29 17:41:32 tdb Exp $
40 */
41 public class ControlPanel extends JPanel {
42
43 //---FINAL ATTRIBUTES---
44
45 /**
46 * The current CVS revision of this class
47 */
48 public final String REVISION = "$Revision: 1.14 $";
49
50 //---STATIC METHODS---
51
52 //---CONSTRUCTORS---
53
54 /**
55 * Constructs a new ControlPanel.
56 *
57 * @param data the data panel to be passed to the ConnectionHandler
58 */
59 public ControlPanel(DataPanel data) {
60 super();
61 setLayout(new BorderLayout());
62 _handler = new ConnectionHandler(data, _actionQueue);
63 add(_toolBar, "North");
64 _handler.start();
65 }
66
67 //---PUBLIC METHODS---
68
69 //---PRIVATE METHODS---
70
71 /**
72 * Sets up the tool bar, adding action listeners
73 * to dispatch events to the ConnectionHandler
74 */
75 private JToolBar setupToolBar() {
76
77 JButton connectButton = new JButton("Connect", new ImageIcon("./resources/control16.gif"));
78 connectButton.addActionListener(new ActionListener() {
79 public void actionPerformed(ActionEvent e) {
80 _actionQueue.add(new Integer(ConnectionHandler.CONNECT));
81 }
82 });
83 JButton disconnectButton = new JButton("Disconnect", new ImageIcon("./resources/stop16.gif"));
84 disconnectButton.addActionListener(new ActionListener() {
85 public void actionPerformed(ActionEvent e) {
86 _actionQueue.add(new Integer(ConnectionHandler.DISCONNECT));
87 }
88 });
89
90 JButton startDataButton = new JButton("Start Data", new ImageIcon("./resources/data16.gif"));
91 startDataButton.addActionListener(new ActionListener() {
92 public void actionPerformed(ActionEvent e) {
93 _actionQueue.add(new Integer(ConnectionHandler.STARTDATA));
94 }
95 });
96 JButton stopDataButton = new JButton("Stop Data", new ImageIcon("./resources/stop16.gif"));
97 stopDataButton.addActionListener(new ActionListener() {
98 public void actionPerformed(ActionEvent e) {
99 _actionQueue.add(new Integer(ConnectionHandler.STOPDATA));
100 }
101 });
102
103 JToolBar bar = new JToolBar(JToolBar.HORIZONTAL);
104 bar.add(connectButton);
105 bar.add(disconnectButton);
106 bar.addSeparator();
107 bar.add(startDataButton);
108 bar.add(stopDataButton);
109
110 bar.add(Box.createGlue());
111 JLabel image = new JLabel(new ImageIcon("./resources/i-scream.gif"));
112 bar.add(image);
113 return bar;
114 }
115
116 public JMenuBar setupMenuBar() {
117 JMenuBar bar = new JMenuBar();
118
119 JMenu conientMenu = new JMenu("Conient");
120 JMenuItem modifiyConfig = new JMenuItem("Modifiy Configuration");
121 modifiyConfig.addActionListener(new ActionListener() {
122 public void actionPerformed(ActionEvent e) {
123 Configuration.getInstance().GUIReconfiguration();
124 }
125 });
126 conientMenu.add(modifiyConfig);
127 conientMenu.addSeparator();
128 JMenuItem saveConfig = new JMenuItem("Save Configuration");
129 saveConfig.addActionListener(new ActionListener() {
130 public void actionPerformed(ActionEvent e) {
131 if (Configuration.getInstance().getUsingSpecificConfig()) {
132 Configuration.getInstance().saveConfiguration();
133 } else {
134 Configuration.getInstance().saveNewConfiguration();
135 }
136 }
137 });
138 conientMenu.add(saveConfig);
139
140 JMenuItem saveAsConfig = new JMenuItem("Save Configuration As...");
141 saveAsConfig.addActionListener(new ActionListener() {
142 public void actionPerformed(ActionEvent e) {
143 Configuration.getInstance().saveNewConfiguration();
144 }
145 });
146 conientMenu.add(saveAsConfig);
147
148 JMenuItem saveDefaultConfig = new JMenuItem("Save Configuration As Default");
149 saveDefaultConfig.addActionListener(new ActionListener() {
150 public void actionPerformed(ActionEvent e) {
151 Configuration.getInstance().saveDefaultConfiguration();
152 }
153 });
154 conientMenu.add(saveDefaultConfig);
155
156 JMenuItem loadConfig = new JMenuItem("Load Configuration...");
157 loadConfig.addActionListener(new ActionListener() {
158 public void actionPerformed(ActionEvent e) {
159 Configuration.getInstance().loadConfiguration();
160 }
161 });
162 conientMenu.add(loadConfig);
163 conientMenu.addSeparator();
164 JMenuItem quit = new JMenuItem("Quit");
165 quit.addActionListener(new ActionListener() {
166 public void actionPerformed(ActionEvent e) {
167 _actionQueue.add(new Integer(ConnectionHandler.QUIT));
168 }
169 });
170 conientMenu.add(quit);
171 bar.add(conientMenu);
172
173 JMenu connectionMenu = new JMenu("Connection");
174 JMenuItem controlConnect = new JMenuItem("Connect", new ImageIcon("./resources/control16.gif"));
175 controlConnect.addActionListener(new ActionListener() {
176 public void actionPerformed(ActionEvent e) {
177 _actionQueue.add(new Integer(ConnectionHandler.CONNECT));
178 }
179 });
180 connectionMenu.add(controlConnect);
181 JMenuItem controlDisconnect = new JMenuItem("Disconnect", new ImageIcon("./resources/stop16.gif"));
182 controlDisconnect.addActionListener(new ActionListener() {
183 public void actionPerformed(ActionEvent e) {
184 _actionQueue.add(new Integer(ConnectionHandler.DISCONNECT));
185 }
186 });
187 connectionMenu.add(controlDisconnect);
188 connectionMenu.addSeparator();
189 JMenuItem dataConnect = new JMenuItem("Start Data", new ImageIcon("./resources/data16.gif"));
190 dataConnect.addActionListener(new ActionListener() {
191 public void actionPerformed(ActionEvent e) {
192 _actionQueue.add(new Integer(ConnectionHandler.STARTDATA));
193 }
194 });
195 connectionMenu.add(dataConnect);
196 JMenuItem dataDisconnect = new JMenuItem("Stop Data", new ImageIcon("./resources/stop16.gif"));
197 dataDisconnect.addActionListener(new ActionListener() {
198 public void actionPerformed(ActionEvent e) {
199 _actionQueue.add(new Integer(ConnectionHandler.STOPDATA));
200 }
201 });
202 connectionMenu.add(dataDisconnect);
203 bar.add(connectionMenu);
204
205 return bar;
206 }
207
208 //---ACCESSOR/MUTATOR METHODS---
209
210 public JMenuBar getMenuBar() {
211 return _menuBar;
212 }
213
214 //---ATTRIBUTES---
215
216 /**
217 * The tool bar for the control panel
218 */
219 JToolBar _toolBar = setupToolBar();
220
221 /**
222 * The menu bar for the Frame
223 */
224 JMenuBar _menuBar = setupMenuBar();
225
226 /**
227 * The queue that we will add actions to.
228 */
229 Queue _actionQueue = new Queue();
230
231 /**
232 * The connection handler in use by the system.
233 */
234 ConnectionHandler _handler;
235
236 //---STATIC ATTRIBUTES---
237
238 }