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.8 by ajm, Mon Feb 26 18:40:25 2001 UTC vs.
Revision 1.9 by ajm, Tue Feb 27 03:09:59 2001 UTC

# Line 54 | Line 54 | public class ControlPanel extends JPanel {
54       */
55      private JToolBar setupToolBar() {
56          JButton connectButton = new JButton("Connect", new ImageIcon("./uk/ac/ukc/iscream/conient/control16.gif"));
57 <        connectButton.addActionListener(new ActionListener() {
57 >        connectButton.addActionListener(connectListener);
58 >        JButton disconnectButton = new JButton("Disconnect", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
59 >        disconnectButton.addActionListener(disconnectListener);
60 >        
61 >        JButton startDataButton = new JButton("Start Data", new ImageIcon("./uk/ac/ukc/iscream/conient/data16.gif"));
62 >        startDataButton.addActionListener(startDataListener);
63 >        JButton stopDataButton = new JButton("Stop Data", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
64 >        stopDataButton.addActionListener(stopDataListener);
65 >        
66 >        JToolBar bar = new JToolBar(JToolBar.HORIZONTAL);
67 >        bar.add(connectButton);
68 >        bar.add(disconnectButton);
69 >        bar.addSeparator();
70 >        bar.add(startDataButton);
71 >        bar.add(stopDataButton);
72 >
73 >        bar.add(Box.createGlue());
74 >        JLabel image = new JLabel(new ImageIcon("./uk/ac/ukc/iscream/conient/i-scream.gif"));
75 >        bar.add(image);
76 >        return bar;
77 >    }
78 >    
79 >    public JMenuBar setupMenuBar() {
80 >        JMenuBar bar = new JMenuBar();
81 >        
82 >        JMenu conientMenu = new JMenu("Conient");
83 >        JMenuItem modifiyConfig = new JMenuItem("Modifiy Configuration");
84 >        modifiyConfig.addActionListener(new ActionListener() {
85              public void actionPerformed(ActionEvent e) {
86 <                _actionQueue.add(new Integer(ConnectionHandler.CONNECT));
86 >                Configuration.getInstance().GUIReconfiguration();
87              }
88          });
89 <        
90 <        JButton startDataButton = new JButton("Start Data", new ImageIcon("./uk/ac/ukc/iscream/conient/data16.gif"));
91 <        startDataButton.addActionListener(new ActionListener() {
89 >        conientMenu.add(modifiyConfig);
90 >        conientMenu.addSeparator();
91 >        JMenuItem saveConfig = new JMenuItem("Save Configuration");
92 >        saveConfig.addActionListener(new ActionListener() {
93              public void actionPerformed(ActionEvent e) {
94 <                _actionQueue.add(new Integer(ConnectionHandler.STARTDATA));
94 >                if (Configuration.getInstance().getUsingSpecificConfig()) {
95 >                    Configuration.getInstance().saveConfiguration();
96 >                } else {
97 >                    Configuration.getInstance().saveNewConfiguration();
98 >                }
99              }
100          });
101 +        conientMenu.add(saveConfig);
102          
103 <        JButton stopDataButton = new JButton("Stop Data", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
104 <        stopDataButton.addActionListener(new ActionListener() {
103 >        JMenuItem saveAsConfig = new JMenuItem("Save Configuration As...");
104 >        saveAsConfig.addActionListener(new ActionListener() {
105              public void actionPerformed(ActionEvent e) {
106 <                _actionQueue.add(new Integer(ConnectionHandler.STOPDATA));
106 >                Configuration.getInstance().saveNewConfiguration();
107              }
108          });
109 +        conientMenu.add(saveAsConfig);
110          
111 <        JButton disconnectButton = new JButton("Disconnect", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
112 <        disconnectButton.addActionListener(new ActionListener() {
111 >        JMenuItem saveDefaultConfig = new JMenuItem("Save Configuration As Default");
112 >        saveDefaultConfig.addActionListener(new ActionListener() {
113              public void actionPerformed(ActionEvent e) {
114 <                _actionQueue.add(new Integer(ConnectionHandler.DISCONNECT));
114 >                Configuration.getInstance().saveDefaultConfiguration();
115              }
116          });
117 +        conientMenu.add(saveDefaultConfig);
118          
119 <        JButton quitButton = new JButton("Quit", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
120 <        quitButton.addActionListener(new ActionListener() {
119 >        JMenuItem loadConfig = new JMenuItem("Load Configuration...");
120 >        loadConfig.addActionListener(new ActionListener() {
121              public void actionPerformed(ActionEvent e) {
122 <                _actionQueue.add(new Integer(ConnectionHandler.QUIT));
122 >                Configuration.getInstance().loadConfiguration();
123              }
124          });
125 <        
126 <        JButton configButton = new JButton("Config");
127 <        configButton.addActionListener(new ActionListener() {
125 >        conientMenu.add(loadConfig);
126 >        conientMenu.addSeparator();
127 >        JMenuItem quit = new JMenuItem("Quit");
128 >        quit.addActionListener(new ActionListener() {
129              public void actionPerformed(ActionEvent e) {
130 <                Configuration.getInstance().GUIReconfiguration();
130 >                _actionQueue.add(new Integer(ConnectionHandler.QUIT));
131              }
132          });
133 +        conientMenu.add(quit);
134 +        bar.add(conientMenu);
135          
136 <        JToolBar bar = new JToolBar(JToolBar.HORIZONTAL);
137 <        bar.add(connectButton);
138 <        bar.add(startDataButton);
139 <        bar.add(stopDataButton);
140 <        bar.add(disconnectButton);
141 <        bar.add(quitButton);
142 <        bar.add(configButton);
143 <        bar.add(Box.createGlue());
144 <        JLabel image = new JLabel(new ImageIcon("./uk/ac/ukc/iscream/conient/i-scream.gif"));
145 <        bar.add(image);
136 >        JMenu connectionMenu = new JMenu("Connection");
137 >        JMenuItem controlConnect = new JMenuItem("Connect", new ImageIcon("./uk/ac/ukc/iscream/conient/control16.gif"));      
138 >        controlConnect.addActionListener(connectListener);
139 >        connectionMenu.add(controlConnect);
140 >        JMenuItem controlDisconnect = new JMenuItem("Disconnect", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
141 >        controlDisconnect.addActionListener(disconnectListener);
142 >        connectionMenu.add(controlDisconnect);
143 >        connectionMenu.addSeparator();
144 >        JMenuItem dataConnect = new JMenuItem("Start Data", new ImageIcon("./uk/ac/ukc/iscream/conient/data16.gif"));      
145 >        dataConnect.addActionListener(startDataListener);
146 >        connectionMenu.add(dataConnect);
147 >        JMenuItem dataDisconnect = new JMenuItem("Stop Data", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
148 >        dataDisconnect.addActionListener(stopDataListener);
149 >        connectionMenu.add(dataDisconnect);
150 >        bar.add(connectionMenu);
151 >        
152 >        JMenu helpMenu = new JMenu("Help");
153 >        JMenuItem help = new JMenuItem("Help");
154 >        helpMenu.add(help);
155 >        JMenuItem about = new JMenuItem("About");
156 >        helpMenu.add(about);
157 >        bar.add(helpMenu);
158 >        
159          return bar;
160 <    }
160 >    }
161  
162   //---ACCESSOR/MUTATOR METHODS---
163  
164 +    public JMenuBar getMenuBar() {
165 +        return _menuBar;
166 +    }
167 +
168   //---ATTRIBUTES---
169  
170      /**
# Line 117 | Line 172 | public class ControlPanel extends JPanel {
172       */    
173      JToolBar _toolBar = setupToolBar();
174      
175 +    JMenuBar _menuBar = setupMenuBar();
176 +    
177      /**
178       * The queue that we will add actions to.
179       */
# Line 126 | Line 183 | public class ControlPanel extends JPanel {
183       * The connection handler in use by the system.
184       */
185      ConnectionHandler _handler;
186 +    
187 +    ActionListener connectListener = new ActionListener()
188 +    {
189 +        public void actionPerformed(ActionEvent e) {
190 +            _actionQueue.add(new Integer(ConnectionHandler.CONNECT));
191 +        }
192 +    };
193 +                                
194 +    
195 +    ActionListener startDataListener = new ActionListener()
196 +    {
197 +        public void actionPerformed(ActionEvent e) {
198 +            _actionQueue.add(new Integer(ConnectionHandler.STARTDATA));
199 +        }
200 +    };
201 +    ActionListener stopDataListener = new ActionListener()
202 +    {
203 +        public void actionPerformed(ActionEvent e) {
204 +            _actionQueue.add(new Integer(ConnectionHandler.STOPDATA));
205 +        }
206 +    };
207 +
208 +    ActionListener disconnectListener = new ActionListener()
209 +    {
210 +        public void actionPerformed(ActionEvent e) {
211 +            _actionQueue.add(new Integer(ConnectionHandler.DISCONNECT));
212 +        }
213 +    };                        
214  
215   //---STATIC ATTRIBUTES---
216  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines