Coverage details for base.jdbs.ui.panel.BackupPanel

LineHitsSource
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  */
490@SuppressWarnings("serial")
500public class BackupPanel extends JPanel {
510 
520    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;
620 
63     private JPanel expirationDatePanel;
640 
650    private JPanel securityLevelPanel;
660 
670    private JPanel filePanel;
68  
690    private JTextField guIdTextField;
70  
71     private JTextField nameTextField;
720 
730    private JScrollPane descriptionScrollPane;
740 
750    private JTextArea descriptionTextArea;
76  
77     private JDateChooser creationDateChooser;
780 
790    private JDateChooser expirationDateChooser;
800 
81     private JComboBox securityLevelComboBox;
820 
830    private final Backup backup;
840 
850    public BackupPanel(Backup backup) {
860        this.backup = backup;
870        initialize();
880    }
890 
900    protected void initialize() {
910        this.setLayout(new GridLayout(2, 1));
920        JPanel topPanel = new JPanel();
930        topPanel.setLayout(new GridLayout(3, 2));
940 
950        topPanel.add(this.getGuIdPanel());
960        topPanel.add(this.getNamePanel());
970        topPanel.add(this.getDescriptionPanel());
980        topPanel.add(this.getSecurityLevelPanel());
990        topPanel.add(this.getCreationDatePanel());
1000        topPanel.add(this.getExpirationDatePanel());
101  
1020        JPanel bottomPanel = new JPanel();
1030        bottomPanel.setLayout(new BorderLayout());
1040        bottomPanel.add(this.getFilePanel());
1050 
1060        this.add(topPanel);
1070        this.add(bottomPanel);
1080 
1090    }
110  
111     /**
112      * @return Returns the creationDatePanel.
113      */
114     protected JPanel getCreationDatePanel() {
1150        if (this.creationDatePanel == null) {
1160            this.creationDatePanel = new JPanel();
1170            this.creationDatePanel.setBorder(new TitledBorder("Creation Date"));
1180            this.creationDatePanel.setLayout(new BorderLayout());
1190            this.creationDatePanel.add(this.getCreationDateChooser(),
120                     BorderLayout.CENTER);
1210        }
1220        return creationDatePanel;
123     }
124  
125     /**
126      * @return Returns the descriptionPanel.
127      */
1280    protected JPanel getDescriptionPanel() {
1290        if (this.descriptionPanel == null) {
1300            this.descriptionPanel = new JPanel();
1310            this.descriptionPanel.setBorder(new TitledBorder("Description"));
1320            this.descriptionPanel.setLayout(new BorderLayout());
1330            this.descriptionPanel.add(this.getDescriptionScrollPane(),
1340                    BorderLayout.CENTER);
135         }
1360        return descriptionPanel;
137     }
138  
139     /**
140      * @return Returns the expirationDatePanel.
1410     */
1420    protected JPanel getExpirationDatePanel() {
1430        if (this.expirationDatePanel == null) {
1440            this.expirationDatePanel = new JPanel();
1450            this.expirationDatePanel.setBorder(new TitledBorder(
146                     "Expiration Date"));
1470            this.expirationDatePanel.setLayout(new BorderLayout());
1480            this.expirationDatePanel.add(this.getExpirationDateChooser(),
149                     BorderLayout.CENTER);
150         }
1510        return expirationDatePanel;
152     }
153  
1540    /**
1550     * @return Returns the guIdPanel.
1560     */
1570    protected JPanel getGuIdPanel() {
1580        if (this.guIdPanel == null) {
1590            this.guIdPanel = new JPanel();
1600            this.guIdPanel.setBorder(new TitledBorder(
161                     "Global Unique Identifier"));
1620            this.guIdPanel.setLayout(new BorderLayout());
1630            this.guIdPanel.add(this.getGuIdTextField(), BorderLayout.CENTER);
164         }
1650        return guIdPanel;
166     }
1670 
1680    /**
1690     * @return Returns the namePanel.
1700     */
1710    protected JPanel getNamePanel() {
1720        if (this.namePanel == null) {
1730            this.namePanel = new JPanel();
1740            this.namePanel.setBorder(new TitledBorder("Name"));
1750            this.namePanel.setLayout(new BorderLayout());
1760            this.namePanel.add(this.getNameTextField(), BorderLayout.CENTER);
177         }
1780        return namePanel;
179     }
1800 
1810    /**
1820     * @return Returns the securityLevelPanel.
1830     */
184     protected JPanel getSecurityLevelPanel() {
1850        if (this.securityLevelPanel == null) {
1860            this.securityLevelPanel = new JPanel();
1870            this.securityLevelPanel
188                     .setBorder(new TitledBorder("Security Level"));
1890            this.securityLevelPanel.setLayout(new BorderLayout());
1900            this.securityLevelPanel.add(this.getSecurityLevelComboBox(),
1910                    BorderLayout.CENTER);
192         }
1930        return securityLevelPanel;
194     }
195  
196     /**
197      * @return Returns the creationDateChooser.
1980     */
1990    protected JDateChooser getCreationDateChooser() {
2000        if (this.creationDateChooser == null) {
2010            this.creationDateChooser = new JDateChooser();
2020            this.creationDateChooser.setDate(backup.getCreationDate());
2030            this.creationDateChooser.addPropertyChangeListener(
204                     "creationDateChanged", new PropertyChangeListener() {
205  
206                         public void propertyChange(PropertyChangeEvent arg0) {
207                             logger.debug("creationDateChooser propertyChange:"
2080                                    + arg0);
209                             backup.setCreationDate(creationDateChooser
210                                     .getDate());
211  
212                         }
213                     });
214         }
2150        return creationDateChooser;
2160    }
2170 
2180    /**
219      * @return Returns the descriptionTextArea.
220      */
221     protected JTextArea getDescriptionTextArea() {
2220        if (this.descriptionTextArea == null) {
2230            this.descriptionTextArea = new JTextArea(backup.getDescription());
2240            this.descriptionTextArea.addPropertyChangeListener(
225                     "descriptionChanged", new PropertyChangeListener() {
2260 
227                         public void propertyChange(PropertyChangeEvent arg0) {
228                             logger.debug("descriptionTextArea propertyChange:"
229                                     + arg0);
230                             backup
231                                     .setDescription(descriptionTextArea
232                                             .getText());
2330 
2340                        }
2350                    });
2360        }
2370        return descriptionTextArea;
2380    }
239  
240     /**
241      * @return Returns the expirationDateChooser.
242      */
243     protected JDateChooser getExpirationDateChooser() {
2440        if (this.expirationDateChooser == null) {
2450            this.expirationDateChooser = new JDateChooser();
2460            this.expirationDateChooser.setDate(backup.getExpirationDate());
2470            this.expirationDateChooser.addPropertyChangeListener(
248                     "expirationDateChanged", new PropertyChangeListener() {
249  
250                         public void propertyChange(PropertyChangeEvent arg0) {
251                             logger
252                                     .debug("expirationDateChooser propertyChange:"
2530                                            + arg0);
254                             backup.setExpirationDate(expirationDateChooser
255                                     .getDate());
256  
257                         }
258                     });
259         }
2600        return expirationDateChooser;
2610    }
2620 
2630    /**
2640     * @return Returns the guIdTextField.
2650     */
266     protected JTextField getGuIdTextField() {
2670        if (this.guIdTextField == null) {
2680            this.guIdTextField = new JTextField(backup.getGuId());
2690            this.guIdTextField.setEditable(false);
2700            this.guIdTextField.setEnabled(false);
271         }
2720        return guIdTextField;
273     }
2740 
275     /**
276      * @return Returns the nameTextField.
277      */
278     protected JTextField getNameTextField() {
2790        if (this.nameTextField == null) {
2800            this.nameTextField = new JTextField(backup.getName());
2810            this.nameTextField.addActionListener(new ActionListener() {
2820                public void actionPerformed(ActionEvent arg0) {
283                     logger.debug("nameTextField actionPerformed");
2840                    backup.setName(nameTextField.getText());
285                 }
286             });
287         }
2880        return nameTextField;
289     }
290  
2910    /**
2920     * @return Returns the securityLevelComboBox.
293      */
2940    protected JComboBox getSecurityLevelComboBox() {
2950        if (this.securityLevelComboBox == null) {
2960            this.securityLevelComboBox = new JComboBox();
2970            for (int i = 0; i < SecurityLevel.level.length; i++) {
2980                this.securityLevelComboBox.addItem(SecurityLevel.level[i]);
2990                if (ConfigurationManager.getInstance()
300                         .getDefaultBackupSecurityLevel().toString()
301                         .equalsIgnoreCase(SecurityLevel.level[i]))
3020                    this.securityLevelComboBox
303                             .setSelectedItem(SecurityLevel.level[i]);
304             }
3050            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         }
3150        return securityLevelComboBox;
316     }
317  
318     /**
319      * @return Returns the descriptionScrollPane.
320      */
321     protected JScrollPane getDescriptionScrollPane() {
3220        if (this.descriptionScrollPane == null) {
3230            this.descriptionScrollPane = new JScrollPane(this
324                     .getDescriptionTextArea());
325         }
3260        return descriptionScrollPane;
327     }
328  
329     /**
330      * @return Returns the filePanel.
331      */
332     protected JPanel getFilePanel() {
3330        if (this.filePanel == null) {
3340            this.filePanel = new TabledFilePanel(backup);
335         }
3360        return filePanel;
337     }
338  
339 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.