Line | Hits | Source |
---|---|---|
1 | /******************************************************************************* | |
2 | *InternetCafe is a software solution that helps the management of Cybercafes | |
3 | * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005. | |
4 | * Copyright (C) 2006 Guido Angelo Ingenito | |
5 | ||
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version 2 | |
9 | * of the License, or (at your option) any later version. | |
10 | ||
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | *******************************************************************************/ | |
20 | ||
21 | package base.jdbs.ui.panel; | |
22 | ||
23 | import java.awt.BorderLayout; | |
24 | import java.awt.GridLayout; | |
25 | import java.awt.event.ActionEvent; | |
26 | import java.awt.event.ActionListener; | |
27 | import java.beans.PropertyChangeEvent; | |
28 | import java.beans.PropertyChangeListener; | |
29 | ||
30 | import javax.swing.JComboBox; | |
31 | import javax.swing.JPanel; | |
32 | import javax.swing.JScrollPane; | |
33 | import javax.swing.JTextArea; | |
34 | import javax.swing.JTextField; | |
35 | import javax.swing.border.TitledBorder; | |
36 | ||
37 | import org.apache.log4j.Logger; | |
38 | ||
39 | import base.jdbs.Backup; | |
40 | import base.jdbs.ConfigurationManager; | |
41 | import base.jdbs.SecurityLevel; | |
42 | ||
43 | import com.toedter.calendar.JDateChooser; | |
44 | ||
45 | /** | |
46 | * @author skunk | |
47 | * | |
48 | */ | |
49 | 0 | @SuppressWarnings("serial") |
50 | 0 | public class BackupPanel extends JPanel { |
51 | 0 | |
52 | 0 | private static final transient Logger logger = Logger |
53 | .getLogger(BackupPanel.class.getName()); | |
54 | ||
55 | private JPanel guIdPanel; | |
56 | ||
57 | private JPanel namePanel; | |
58 | ||
59 | private JPanel descriptionPanel; | |
60 | ||
61 | private JPanel creationDatePanel; | |
62 | 0 | |
63 | private JPanel expirationDatePanel; | |
64 | 0 | |
65 | 0 | private JPanel securityLevelPanel; |
66 | 0 | |
67 | 0 | private JPanel filePanel; |
68 | ||
69 | 0 | private JTextField guIdTextField; |
70 | ||
71 | private JTextField nameTextField; | |
72 | 0 | |
73 | 0 | private JScrollPane descriptionScrollPane; |
74 | 0 | |
75 | 0 | private JTextArea descriptionTextArea; |
76 | ||
77 | private JDateChooser creationDateChooser; | |
78 | 0 | |
79 | 0 | private JDateChooser expirationDateChooser; |
80 | 0 | |
81 | private JComboBox securityLevelComboBox; | |
82 | 0 | |
83 | 0 | private final Backup backup; |
84 | 0 | |
85 | 0 | public BackupPanel(Backup backup) { |
86 | 0 | this.backup = backup; |
87 | 0 | initialize(); |
88 | 0 | } |
89 | 0 | |
90 | 0 | protected void initialize() { |
91 | 0 | this.setLayout(new GridLayout(2, 1)); |
92 | 0 | JPanel topPanel = new JPanel(); |
93 | 0 | topPanel.setLayout(new GridLayout(3, 2)); |
94 | 0 | |
95 | 0 | topPanel.add(this.getGuIdPanel()); |
96 | 0 | topPanel.add(this.getNamePanel()); |
97 | 0 | topPanel.add(this.getDescriptionPanel()); |
98 | 0 | topPanel.add(this.getSecurityLevelPanel()); |
99 | 0 | topPanel.add(this.getCreationDatePanel()); |
100 | 0 | topPanel.add(this.getExpirationDatePanel()); |
101 | ||
102 | 0 | JPanel bottomPanel = new JPanel(); |
103 | 0 | bottomPanel.setLayout(new BorderLayout()); |
104 | 0 | bottomPanel.add(this.getFilePanel()); |
105 | 0 | |
106 | 0 | this.add(topPanel); |
107 | 0 | this.add(bottomPanel); |
108 | 0 | |
109 | 0 | } |
110 | ||
111 | /** | |
112 | * @return Returns the creationDatePanel. | |
113 | */ | |
114 | protected JPanel getCreationDatePanel() { | |
115 | 0 | if (this.creationDatePanel == null) { |
116 | 0 | this.creationDatePanel = new JPanel(); |
117 | 0 | this.creationDatePanel.setBorder(new TitledBorder("Creation Date")); |
118 | 0 | this.creationDatePanel.setLayout(new BorderLayout()); |
119 | 0 | this.creationDatePanel.add(this.getCreationDateChooser(), |
120 | BorderLayout.CENTER); | |
121 | 0 | } |
122 | 0 | return creationDatePanel; |
123 | } | |
124 | ||
125 | /** | |
126 | * @return Returns the descriptionPanel. | |
127 | */ | |
128 | 0 | protected JPanel getDescriptionPanel() { |
129 | 0 | if (this.descriptionPanel == null) { |
130 | 0 | this.descriptionPanel = new JPanel(); |
131 | 0 | this.descriptionPanel.setBorder(new TitledBorder("Description")); |
132 | 0 | this.descriptionPanel.setLayout(new BorderLayout()); |
133 | 0 | this.descriptionPanel.add(this.getDescriptionScrollPane(), |
134 | 0 | BorderLayout.CENTER); |
135 | } | |
136 | 0 | return descriptionPanel; |
137 | } | |
138 | ||
139 | /** | |
140 | * @return Returns the expirationDatePanel. | |
141 | 0 | */ |
142 | 0 | protected JPanel getExpirationDatePanel() { |
143 | 0 | if (this.expirationDatePanel == null) { |
144 | 0 | this.expirationDatePanel = new JPanel(); |
145 | 0 | this.expirationDatePanel.setBorder(new TitledBorder( |
146 | "Expiration Date")); | |
147 | 0 | this.expirationDatePanel.setLayout(new BorderLayout()); |
148 | 0 | this.expirationDatePanel.add(this.getExpirationDateChooser(), |
149 | BorderLayout.CENTER); | |
150 | } | |
151 | 0 | return expirationDatePanel; |
152 | } | |
153 | ||
154 | 0 | /** |
155 | 0 | * @return Returns the guIdPanel. |
156 | 0 | */ |
157 | 0 | protected JPanel getGuIdPanel() { |
158 | 0 | if (this.guIdPanel == null) { |
159 | 0 | this.guIdPanel = new JPanel(); |
160 | 0 | this.guIdPanel.setBorder(new TitledBorder( |
161 | "Global Unique Identifier")); | |
162 | 0 | this.guIdPanel.setLayout(new BorderLayout()); |
163 | 0 | this.guIdPanel.add(this.getGuIdTextField(), BorderLayout.CENTER); |
164 | } | |
165 | 0 | return guIdPanel; |
166 | } | |
167 | 0 | |
168 | 0 | /** |
169 | 0 | * @return Returns the namePanel. |
170 | 0 | */ |
171 | 0 | protected JPanel getNamePanel() { |
172 | 0 | if (this.namePanel == null) { |
173 | 0 | this.namePanel = new JPanel(); |
174 | 0 | this.namePanel.setBorder(new TitledBorder("Name")); |
175 | 0 | this.namePanel.setLayout(new BorderLayout()); |
176 | 0 | this.namePanel.add(this.getNameTextField(), BorderLayout.CENTER); |
177 | } | |
178 | 0 | return namePanel; |
179 | } | |
180 | 0 | |
181 | 0 | /** |
182 | 0 | * @return Returns the securityLevelPanel. |
183 | 0 | */ |
184 | protected JPanel getSecurityLevelPanel() { | |
185 | 0 | if (this.securityLevelPanel == null) { |
186 | 0 | this.securityLevelPanel = new JPanel(); |
187 | 0 | this.securityLevelPanel |
188 | .setBorder(new TitledBorder("Security Level")); | |
189 | 0 | this.securityLevelPanel.setLayout(new BorderLayout()); |
190 | 0 | this.securityLevelPanel.add(this.getSecurityLevelComboBox(), |
191 | 0 | BorderLayout.CENTER); |
192 | } | |
193 | 0 | return securityLevelPanel; |
194 | } | |
195 | ||
196 | /** | |
197 | * @return Returns the creationDateChooser. | |
198 | 0 | */ |
199 | 0 | protected JDateChooser getCreationDateChooser() { |
200 | 0 | if (this.creationDateChooser == null) { |
201 | 0 | this.creationDateChooser = new JDateChooser(); |
202 | 0 | this.creationDateChooser.setDate(backup.getCreationDate()); |
203 | 0 | this.creationDateChooser.addPropertyChangeListener( |
204 | "creationDateChanged", new PropertyChangeListener() { | |
205 | ||
206 | public void propertyChange(PropertyChangeEvent arg0) { | |
207 | logger.debug("creationDateChooser propertyChange:" | |
208 | 0 | + arg0); |
209 | backup.setCreationDate(creationDateChooser | |
210 | .getDate()); | |
211 | ||
212 | } | |
213 | }); | |
214 | } | |
215 | 0 | return creationDateChooser; |
216 | 0 | } |
217 | 0 | |
218 | 0 | /** |
219 | * @return Returns the descriptionTextArea. | |
220 | */ | |
221 | protected JTextArea getDescriptionTextArea() { | |
222 | 0 | if (this.descriptionTextArea == null) { |
223 | 0 | this.descriptionTextArea = new JTextArea(backup.getDescription()); |
224 | 0 | this.descriptionTextArea.addPropertyChangeListener( |
225 | "descriptionChanged", new PropertyChangeListener() { | |
226 | 0 | |
227 | public void propertyChange(PropertyChangeEvent arg0) { | |
228 | logger.debug("descriptionTextArea propertyChange:" | |
229 | + arg0); | |
230 | backup | |
231 | .setDescription(descriptionTextArea | |
232 | .getText()); | |
233 | 0 | |
234 | 0 | } |
235 | 0 | }); |
236 | 0 | } |
237 | 0 | return descriptionTextArea; |
238 | 0 | } |
239 | ||
240 | /** | |
241 | * @return Returns the expirationDateChooser. | |
242 | */ | |
243 | protected JDateChooser getExpirationDateChooser() { | |
244 | 0 | if (this.expirationDateChooser == null) { |
245 | 0 | this.expirationDateChooser = new JDateChooser(); |
246 | 0 | this.expirationDateChooser.setDate(backup.getExpirationDate()); |
247 | 0 | this.expirationDateChooser.addPropertyChangeListener( |
248 | "expirationDateChanged", new PropertyChangeListener() { | |
249 | ||
250 | public void propertyChange(PropertyChangeEvent arg0) { | |
251 | logger | |
252 | .debug("expirationDateChooser propertyChange:" | |
253 | 0 | + arg0); |
254 | backup.setExpirationDate(expirationDateChooser | |
255 | .getDate()); | |
256 | ||
257 | } | |
258 | }); | |
259 | } | |
260 | 0 | return expirationDateChooser; |
261 | 0 | } |
262 | 0 | |
263 | 0 | /** |
264 | 0 | * @return Returns the guIdTextField. |
265 | 0 | */ |
266 | protected JTextField getGuIdTextField() { | |
267 | 0 | if (this.guIdTextField == null) { |
268 | 0 | this.guIdTextField = new JTextField(backup.getGuId()); |
269 | 0 | this.guIdTextField.setEditable(false); |
270 | 0 | this.guIdTextField.setEnabled(false); |
271 | } | |
272 | 0 | return guIdTextField; |
273 | } | |
274 | 0 | |
275 | /** | |
276 | * @return Returns the nameTextField. | |
277 | */ | |
278 | protected JTextField getNameTextField() { | |
279 | 0 | if (this.nameTextField == null) { |
280 | 0 | this.nameTextField = new JTextField(backup.getName()); |
281 | 0 | this.nameTextField.addActionListener(new ActionListener() { |
282 | 0 | public void actionPerformed(ActionEvent arg0) { |
283 | logger.debug("nameTextField actionPerformed"); | |
284 | 0 | backup.setName(nameTextField.getText()); |
285 | } | |
286 | }); | |
287 | } | |
288 | 0 | return nameTextField; |
289 | } | |
290 | ||
291 | 0 | /** |
292 | 0 | * @return Returns the securityLevelComboBox. |
293 | */ | |
294 | 0 | protected JComboBox getSecurityLevelComboBox() { |
295 | 0 | if (this.securityLevelComboBox == null) { |
296 | 0 | this.securityLevelComboBox = new JComboBox(); |
297 | 0 | for (int i = 0; i < SecurityLevel.level.length; i++) { |
298 | 0 | this.securityLevelComboBox.addItem(SecurityLevel.level[i]); |
299 | 0 | if (ConfigurationManager.getInstance() |
300 | .getDefaultBackupSecurityLevel().toString() | |
301 | .equalsIgnoreCase(SecurityLevel.level[i])) | |
302 | 0 | this.securityLevelComboBox |
303 | .setSelectedItem(SecurityLevel.level[i]); | |
304 | } | |
305 | 0 | this.securityLevelComboBox.addActionListener(new ActionListener() { |
306 | public void actionPerformed(ActionEvent arg0) { | |
307 | logger.debug("securityLevelComboBox actionPerformed"); | |
308 | backup.setSecurityLevel(SecurityLevel | |
309 | .fromStringToSecurityLevel(securityLevelComboBox | |
310 | .getSelectedItem().toString())); | |
311 | ||
312 | } | |
313 | }); | |
314 | } | |
315 | 0 | return securityLevelComboBox; |
316 | } | |
317 | ||
318 | /** | |
319 | * @return Returns the descriptionScrollPane. | |
320 | */ | |
321 | protected JScrollPane getDescriptionScrollPane() { | |
322 | 0 | if (this.descriptionScrollPane == null) { |
323 | 0 | this.descriptionScrollPane = new JScrollPane(this |
324 | .getDescriptionTextArea()); | |
325 | } | |
326 | 0 | return descriptionScrollPane; |
327 | } | |
328 | ||
329 | /** | |
330 | * @return Returns the filePanel. | |
331 | */ | |
332 | protected JPanel getFilePanel() { | |
333 | 0 | if (this.filePanel == null) { |
334 | 0 | this.filePanel = new TabledFilePanel(backup); |
335 | } | |
336 | 0 | return filePanel; |
337 | } | |
338 | ||
339 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |