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.13 by ajm, Mon Mar 19 01:38:16 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 + package uk.org.iscream.conient;
3  
4   //---IMPORTS---
5 < import uk.ac.ukc.iscream.util.*;
5 > import uk.org.iscream.util.*;
6   import javax.swing.*;
7 < import java.awt.*;
8 < import java.awt.event.*;
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$
20   * @version $Id$
21   */
# Line 26 | Line 32 | public class ControlPanel extends JPanel {
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 <        _data = data;
33 <        _handler = new ConnectionHandler(_data, _actionQueue);
43 >        _handler = new ConnectionHandler(data, _actionQueue);
44          add(_toolBar, "North");
45          _handler.start();
46      }
# Line 39 | Line 49 | public class ControlPanel extends JPanel {
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 <        JButton connectButton = new JButton("Connect");
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");
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 <        
57 <        JButton stopDataButton = new JButton("Stop Data");
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 <        JButton disconnectButton = new JButton("Disconnect");
85 <        disconnectButton.addActionListener(new ActionListener() {
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 <                _actionQueue.add(new Integer(ConnectionHandler.DISCONNECT));
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 <        JButton quitButton = new JButton("Quit");
122 <        quitButton.addActionListener(new ActionListener() {
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 <        JToolBar bar = new JToolBar(JToolBar.HORIZONTAL);
155 <        bar.add(connectButton);
156 <        bar.add(startDataButton);
157 <        bar.add(stopDataButton);
158 <        bar.add(disconnectButton);
159 <        bar.add(quitButton);
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          return bar;
187 <    }
187 >    }
188  
189   //---ACCESSOR/MUTATOR METHODS---
190  
191 +    public JMenuBar getMenuBar() {
192 +        return _menuBar;
193 +    }
194 +
195   //---ATTRIBUTES---
196  
197 <    DataPanel _data;
197 >    /**
198 >     * The tool bar for the control panel
199 >     */    
200      JToolBar _toolBar = setupToolBar();
201      
202 +    /**
203 +     * The menu bar for the Frame
204 +     */
205 +    JMenuBar _menuBar = setupMenuBar();
206 +    
207 +    /**
208 +     * The queue that we will add actions to.
209 +     */
210      Queue _actionQueue = new Queue();
211 +    
212 +    /**
213 +     * The connection handler in use by the system.
214 +     */
215      ConnectionHandler _handler;
216  
217   //---STATIC ATTRIBUTES---

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines