Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ToolBar |
|
| 1.5555555555555556;1.556 | ||||
ToolBar$1 |
|
| 1.5555555555555556;1.556 | ||||
ToolBar$2 |
|
| 1.5555555555555556;1.556 | ||||
ToolBar$3 |
|
| 1.5555555555555556;1.556 | ||||
ToolBar$4 |
|
| 1.5555555555555556;1.556 | ||||
ToolBar$5 |
|
| 1.5555555555555556;1.556 | ||||
ToolBar$6 |
|
| 1.5555555555555556;1.556 |
1 | /****************************************************************************** | |
2 | * Toolbar.java - The BuckoFIBS main toolbar | |
3 | * $Id$ | |
4 | * | |
5 | * BuckoFIBS - Backgammon by BuckoSoft | |
6 | * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp. | |
7 | * | |
8 | * $Log$ | |
9 | * Revision 1.4 2011/05/23 03:37:09 dick | |
10 | * Purposefully broken to test the build script. | |
11 | * | |
12 | * Revision 1.3 2010/03/03 13:12:21 inim | |
13 | * Replaced (c) sign in comment mangled by CVS default encoding back to UTF-8 | |
14 | * | |
15 | * Revision 1.2 2010/03/03 12:19:49 inim | |
16 | * Moved source to UTF8 encoding from CP1252 encoding. To this end all source files' (c) message was updated to "Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.". This replaces the (c) sign to UTF8, and adds the new year 2010. | |
17 | * | |
18 | * Revision 1.1 2010/02/04 05:57:53 inim | |
19 | * Mavenized project folder layout | |
20 | * | |
21 | * Revision 1.14 2010/01/29 23:10:44 dick | |
22 | * Double-click the graph to bring up the config dialog. | |
23 | * | |
24 | * Revision 1.13 2010/01/27 02:10:39 dick | |
25 | * ratingGraphPanel.mouseClick. | |
26 | * | |
27 | * Revision 1.12 2009/03/04 19:05:03 dick | |
28 | * Javadoc. | |
29 | * | |
30 | * Revision 1.11 2009/02/21 17:59:05 dick | |
31 | * Add the RatingGraphPanel. | |
32 | * | |
33 | * Revision 1.10 2009/02/14 12:25:22 dick | |
34 | * Unused button becomes About button. | |
35 | * | |
36 | * Revision 1.9 2009/01/28 19:13:24 dick | |
37 | * Use the notes.png icon. | |
38 | * | |
39 | * Revision 1.8 2009/01/13 18:27:39 dick | |
40 | * Handle Ready To Play | |
41 | * | |
42 | * Revision 1.7 2009/01/09 07:16:51 dick | |
43 | * Add the Prefs4Messages button. | |
44 | * | |
45 | * Revision 1.6 2008/12/17 04:38:00 dick | |
46 | * Connect button work. | |
47 | * | |
48 | * Revision 1.5 2008/12/15 01:53:57 dick | |
49 | * Cleanup. | |
50 | * | |
51 | * Revision 1.4 2008/12/13 06:29:09 dick | |
52 | * Add ReadyToPlay and some funky icons. | |
53 | * | |
54 | * Revision 1.3 2008/12/11 08:49:26 dick | |
55 | * Add the tools (preferences) button. | |
56 | * | |
57 | * Revision 1.2 2008/03/30 05:44:12 dick | |
58 | * Execute a command when the connection button is clicked. | |
59 | * | |
60 | * Revision 1.1 2008/03/29 08:57:43 dick | |
61 | * BuckoFIBS skeleton checkin. | |
62 | * | |
63 | */ | |
64 | ||
65 | /* | |
66 | * This program is free software: you can redistribute it and/or modify | |
67 | * it under the terms of the GNU General Public License as published by | |
68 | * the Free Software Foundation, either version 3 of the License, or | |
69 | * (at your option) any later version. | |
70 | * | |
71 | * This program is distributed in the hope that it will be useful, | |
72 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
73 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
74 | * GNU General Public License for more details. | |
75 | * | |
76 | * You should have received a copy of the GNU General Public License | |
77 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
78 | * | |
79 | * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>. | |
80 | * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp. | |
81 | * | |
82 | */ | |
83 | package com.buckosoft.fibs.BuckoFIBS.gui; | |
84 | ||
85 | import java.awt.Color; | |
86 | import java.awt.Dimension; | |
87 | import java.awt.GridBagLayout; | |
88 | ||
89 | import javax.swing.ImageIcon; | |
90 | import javax.swing.JButton; | |
91 | import javax.swing.JCheckBox; | |
92 | import javax.swing.JToolBar; | |
93 | ||
94 | import com.buckosoft.fibs.BuckoFIBS.CommandDispatcher; | |
95 | ||
96 | /** The BuckoFIBS main toolbar. | |
97 | * @author Dick Balaska | |
98 | * @since 2008/03/29 | |
99 | * @version $Revision$ <br> $Date$ | |
100 | * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/com/buckosoft/fibs/BuckoFIBS/gui/ToolBar.java">cvs ToolBar.java</a> | |
101 | */ | |
102 | 0 | public class ToolBar extends JToolBar { |
103 | private static final long serialVersionUID = 1L; | |
104 | ||
105 | 0 | private JButton jButtonConnect = null; |
106 | ||
107 | private CommandDispatcher commandDispatcher; // @jve:decl-index=0: | |
108 | ||
109 | 0 | private JButton jButtonTools = null; |
110 | ||
111 | 0 | private JButton jButtonReadyToPlay = null; |
112 | ||
113 | 0 | private JCheckBox jCheckBox = null; |
114 | ||
115 | private ImageIcon connectedIcon; // @jve:decl-index=0: | |
116 | private ImageIcon notConnectedIcon; // @jve:decl-index=0: | |
117 | private ImageIcon readyIcon; | |
118 | private ImageIcon notReadyIcon; | |
119 | ||
120 | 0 | private JButton jButtonMessages = null; |
121 | ||
122 | 0 | private RatingGraphPanel ratingGraphPanel = null; |
123 | ||
124 | /** | |
125 | * Instantiate the ToolBar for BuckoFIBS | |
126 | * | |
127 | */ | |
128 | public ToolBar() { | |
129 | 0 | super(); |
130 | 0 | initialize(); |
131 | 0 | } |
132 | ||
133 | /** Set the reference to the command dispatcher | |
134 | * @param commandDispatcher Our system CommandDispatcher | |
135 | */ | |
136 | public void setCommandDispatcher(CommandDispatcher commandDispatcher) { | |
137 | 0 | this.commandDispatcher = commandDispatcher; |
138 | 0 | } |
139 | ||
140 | public void setConnected(boolean b) { | |
141 | 0 | this.getJButtonConnect().setIcon(b ? connectedIcon : notConnectedIcon); |
142 | 0 | this.getJButtonReadyToPlay().setEnabled(b); |
143 | 0 | } |
144 | ||
145 | private void handleConnectButton() { | |
146 | 0 | if (this.getJButtonConnect().getIcon() == connectedIcon) |
147 | 0 | commandDispatcher.dispatch(CommandDispatcher.Command.DISCONNECT_FROM_NETWORK); |
148 | else | |
149 | 0 | commandDispatcher.dispatch(CommandDispatcher.Command.SHOW_CONNECTION_DIALOG); |
150 | 0 | } |
151 | ||
152 | public void setReadyToPlay(boolean b) { | |
153 | 0 | this.getJButtonReadyToPlay().setIcon(b? readyIcon : notReadyIcon); |
154 | 0 | } |
155 | /** | |
156 | * This method initializes this | |
157 | * | |
158 | */ | |
159 | private void initialize() { | |
160 | 0 | notConnectedIcon = new ImageIcon(getClass().getResource("/g/connectTelnet.png")); |
161 | 0 | connectedIcon = new ImageIcon(getClass().getResource("/g/telnet.png")); |
162 | 0 | readyIcon = new ImageIcon(getClass().getResource("/g/accept32.png")); |
163 | 0 | notReadyIcon = new ImageIcon(getClass().getResource("/g/pause32.png")); |
164 | ||
165 | 0 | this.add(getJButtonConnect()); |
166 | 0 | this.add(getJButtonTools()); |
167 | 0 | this.add(getJButtonMessages()); |
168 | 0 | this.add(getJButtonReadyToPlay()); |
169 | 0 | this.add(new JToolBar.Separator()); |
170 | 0 | this.add(getJCheckBox()); |
171 | 0 | this.add(new JToolBar.Separator()); |
172 | 0 | this.add(new JToolBar.Separator()); |
173 | 0 | this.add(getRatingGraphPanel()); |
174 | 0 | } |
175 | ||
176 | /** | |
177 | * This method initializes jButtonUp | |
178 | * | |
179 | * @return javax.swing.JButton | |
180 | */ | |
181 | public JButton getJButtonConnect() { | |
182 | 0 | if (jButtonConnect == null) { |
183 | 0 | jButtonConnect = new JButton(); |
184 | 0 | jButtonConnect.setIcon(new ImageIcon(getClass().getResource("/g/connectTelnet.png"))); |
185 | 0 | jButtonConnect.setMnemonic(java.awt.event.KeyEvent.VK_U); |
186 | 0 | jButtonConnect.setPreferredSize(new Dimension(44, 44)); |
187 | 0 | jButtonConnect.setToolTipText("Connect to the Server"); |
188 | 0 | jButtonConnect.addActionListener(new java.awt.event.ActionListener() { |
189 | public void actionPerformed(java.awt.event.ActionEvent e) { | |
190 | 0 | handleConnectButton(); |
191 | 0 | } |
192 | }); | |
193 | } | |
194 | 0 | return jButtonConnect; |
195 | } | |
196 | ||
197 | /** | |
198 | * This method initializes jButtonTools | |
199 | * | |
200 | * @return javax.swing.JButton | |
201 | */ | |
202 | private JButton getJButtonTools() { | |
203 | 0 | if (jButtonTools == null) { |
204 | 0 | jButtonTools = new JButton(); |
205 | 0 | jButtonTools.setIcon(new ImageIcon(getClass().getResource("/g/tools.png"))); |
206 | 0 | jButtonTools.setToolTipText("Configure options"); |
207 | 0 | jButtonTools.addActionListener(new java.awt.event.ActionListener() { |
208 | public void actionPerformed(java.awt.event.ActionEvent e) { | |
209 | 0 | commandDispatcher.dispatch(CommandDispatcher.Command.SHOW_PREFERENCES_DIALOG); |
210 | 0 | } |
211 | }); | |
212 | } | |
213 | 0 | return jButtonTools; |
214 | } | |
215 | ||
216 | /** | |
217 | * This method initializes jButtonReadyToPlay | |
218 | * | |
219 | * @return javax.swing.JButton | |
220 | */ | |
221 | private JButton getJButtonReadyToPlay() { | |
222 | 0 | if (jButtonReadyToPlay == null) { |
223 | 0 | jButtonReadyToPlay = new JButton(); |
224 | 0 | jButtonReadyToPlay.setIcon(notReadyIcon); |
225 | 0 | jButtonReadyToPlay.setToolTipText("Toggle \"Ready to play\""); |
226 | 0 | jButtonReadyToPlay.addActionListener(new java.awt.event.ActionListener() { |
227 | public void actionPerformed(java.awt.event.ActionEvent e) { | |
228 | 0 | commandDispatcher.dispatch(CommandDispatcher.Command.TOGGLE_READY_TO_PLAY); |
229 | 0 | } |
230 | }); | |
231 | } | |
232 | 0 | return jButtonReadyToPlay; |
233 | } | |
234 | ||
235 | /** | |
236 | * This method initializes jCheckBox | |
237 | * | |
238 | * @return javax.swing.JCheckBox | |
239 | */ | |
240 | private JCheckBox getJCheckBox() { | |
241 | 0 | if (jCheckBox == null) { |
242 | 0 | jCheckBox = new JCheckBox(); |
243 | 0 | jCheckBox.setIcon(new ImageIcon(getClass().getResource("/g/choo.png"))); |
244 | 0 | jCheckBox.setToolTipText("Display the about box"); |
245 | 0 | jCheckBox.setPressedIcon(new ImageIcon(getClass().getResource("/g/choo1.png"))); |
246 | 0 | jCheckBox.addActionListener(new java.awt.event.ActionListener() { |
247 | public void actionPerformed(java.awt.event.ActionEvent e) { | |
248 | 0 | commandDispatcher.dispatch(CommandDispatcher.Command.SHOW_ABOUT_DIALOG); |
249 | 0 | } |
250 | }); | |
251 | } | |
252 | 0 | return jCheckBox; |
253 | } | |
254 | ||
255 | /** | |
256 | * This method initializes jButtonMessages | |
257 | * | |
258 | * @return javax.swing.JButton | |
259 | */ | |
260 | private JButton getJButtonMessages() { | |
261 | 0 | if (jButtonMessages == null) { |
262 | 0 | jButtonMessages = new JButton(); |
263 | 0 | jButtonMessages.setIcon(new ImageIcon(getClass().getResource("/g/notes.png"))); |
264 | 0 | jButtonMessages.setToolTipText("Configure message routing and display"); |
265 | 0 | jButtonMessages.addActionListener(new java.awt.event.ActionListener() { |
266 | public void actionPerformed(java.awt.event.ActionEvent e) { | |
267 | 0 | commandDispatcher.dispatch(CommandDispatcher.Command.SHOW_PREFS4MSGS_DIALOG); |
268 | 0 | } |
269 | }); | |
270 | } | |
271 | 0 | return jButtonMessages; |
272 | } | |
273 | ||
274 | /** | |
275 | * This method initializes jPanelRating | |
276 | * | |
277 | * @return javax.swing.JPanel | |
278 | */ | |
279 | public RatingGraphPanel getRatingGraphPanel() { | |
280 | 0 | if (ratingGraphPanel == null) { |
281 | 0 | ratingGraphPanel = new RatingGraphPanel(); |
282 | 0 | ratingGraphPanel.setLayout(new GridBagLayout()); |
283 | 0 | ratingGraphPanel.setPreferredSize(new Dimension(100, 40)); |
284 | 0 | ratingGraphPanel.setBackground(Color.black); |
285 | 0 | ratingGraphPanel.addMouseListener(new java.awt.event.MouseAdapter() { |
286 | public void mouseClicked(java.awt.event.MouseEvent e) { | |
287 | 0 | if (e.getClickCount() == 2) |
288 | 0 | commandDispatcher.dispatch(CommandDispatcher.Command.SHOW_RATINGS_GRAPH_DIALOG); |
289 | 0 | } |
290 | }); | |
291 | } | |
292 | 0 | return ratingGraphPanel; |
293 | } | |
294 | } |