Coverage details for 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 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.util.Date;
280 
29 import javax.swing.ImageIcon;
300import javax.swing.JButton;
31 import javax.swing.JFileChooser;
32 import javax.swing.JPanel;
33 import javax.swing.JTextField;
34 import javax.swing.border.TitledBorder;
35  
36 import org.apache.log4j.Logger;
37  
38 import ui.Messages;
39 import base.ConfigurationManager;
40  
41 /**
42  * @author skunk
43  *
44  */
450@SuppressWarnings("serial") //$NON-NLS-1$
460public class BackupPanel extends JPanel {
470 
480    private static final transient Logger logger = Logger
490            .getLogger(BackupPanel.class.getName());
500 
51     /*
52      * private final int id; private String name; private String description;
53      * private Date date; private String originalBackupDestinationPath; private
54      * String currentBackupLocationPath="";
55      */
56  
57     private JPanel namePanel;
58  
59     private JTextField nameTextField;
60  
61     private JPanel descriptionPanel;
62  
630    private JTextField descriptionTextField;
640 
650    private JPanel datePanel;
66  
67     private Date currentDate;
680 
690    private JTextField dateTextField;
700 
710    private JPanel dbLocationPathPanel;
720 
730    private JTextField dbLocationPathTextField;
740 
75     private JPanel zipLocationPathPanel;
76  
77     private JTextField zipLocationPathTextField;
78  
79     private JButton chooseZipLocationPathButton;
800 
810    public BackupPanel() {
820        initialize();
830    }
840 
850    protected void initialize() {
860        this.setLayout(new GridLayout(5, 1));
870        this.add(getNamePanel());
880        this.add(getDatePanel());
890        this.add(getDescriptionPanel());
900        this.add(getDbLocationPathPanel());
910        this.add(getZipLocationPathPanel());
920    }
930 
940    /**
950     * @return Returns the datePanel.
960     */
970    protected JPanel getDatePanel() {
980        if (datePanel == null) {
990            datePanel = new JPanel();
1000            datePanel.setBorder(new TitledBorder(Messages.getString("common.date"))); //$NON-NLS-1$
1010            datePanel.setLayout(new BorderLayout());
1020            datePanel.add(getDateTextField(), BorderLayout.CENTER);
1030        }
1040        return datePanel;
1050    }
1060 
1070    /**
1080     * @return Returns the dateTextField.
1090     */
1100    protected JTextField getDateTextField() {
1110        if (dateTextField == null) {
1120            dateTextField = new JTextField();
1130            dateTextField.setText(getCurrentDate().toString());
1140            dateTextField.setEditable(false);
1150        }
1160        return dateTextField;
1170    }
118  
1190    /**
1200     * @return Returns the descriptionPanel.
121      */
1220    protected JPanel getDescriptionPanel() {
1230        if (descriptionPanel == null) {
1240            descriptionPanel = new JPanel();
1250            descriptionPanel.setBorder(new TitledBorder(Messages.getString("common.description"))); //$NON-NLS-1$
1260            descriptionPanel.setLayout(new BorderLayout());
1270            descriptionPanel
1280                    .add(getDescriptionTextField(), BorderLayout.CENTER);
1290        }
1300        return descriptionPanel;
1310    }
132  
1330    /**
1340     * @return Returns the descriptionTextField.
135      */
1360    protected JTextField getDescriptionTextField() {
1370        if (descriptionTextField == null) {
1380            descriptionTextField = new JTextField();
1390        }
1400        return descriptionTextField;
1410    }
142  
143     /**
144      * @return Returns the zipLocationPathPanel.
145      */
1460    protected JPanel getZipLocationPathPanel() {
1470        if (zipLocationPathPanel == null) {
1480            zipLocationPathPanel = new JPanel();
1490            zipLocationPathPanel.setBorder(new TitledBorder(
1500                    Messages.getString("panel.backuppanel.zippedarchivedestinationpath"))); //$NON-NLS-1$
1510            zipLocationPathPanel.setLayout(new BorderLayout());
1520            zipLocationPathPanel.add(getZipLocationPathTextField(),
1530                    BorderLayout.CENTER);
1540            zipLocationPathPanel.add(getChooseZipLocationPathButton(),
1550                    BorderLayout.EAST);
1560        }
1570        return zipLocationPathPanel;
1580    }
1590 
160     /**
1610     * @return Returns the zipLocationPathTextField.
1620     */
1630    protected JTextField getZipLocationPathTextField() {
1640        if (zipLocationPathTextField == null) {
1650            zipLocationPathTextField = new JTextField();
1660            zipLocationPathTextField.setEditable(false);
1670        }
1680        return zipLocationPathTextField;
1690    }
170  
171     /**
1720     * @return Returns the dbLocationPathPanel.
1730     */
1740    protected JPanel getDbLocationPathPanel() {
1750        if (dbLocationPathPanel == null) {
1760            dbLocationPathPanel = new JPanel();
1770            dbLocationPathPanel
1780                    .setBorder(new TitledBorder(Messages.getString("panel.backuppanel.envolveddatabase"))); //$NON-NLS-1$
1790            dbLocationPathPanel.setLayout(new BorderLayout());
1800            dbLocationPathPanel.add(getDbLocationPathTextField(),
1810                    BorderLayout.CENTER);
1820        }
1830        return dbLocationPathPanel;
1840    }
1850 
1860    /**
1870     * @return Returns the dbLocationPathTextField.
1880     */
1890    protected JTextField getDbLocationPathTextField() {
1900        if (dbLocationPathTextField == null) {
1910            dbLocationPathTextField = new JTextField();
1920            dbLocationPathTextField.setText(ConfigurationManager.getInstance()
1930                    .getDataBasePath());
1940            dbLocationPathTextField.setEditable(false);
1950        }
1960        return dbLocationPathTextField;
1970    }
1980 
1990    /**
2000     * @return Returns the namePanel.
201      */
2020    protected JPanel getNamePanel() {
2030        if (namePanel == null) {
2040            namePanel = new JPanel();
2050            namePanel.setBorder(new TitledBorder(Messages.getString("common.name"))); //$NON-NLS-1$
2060            namePanel.setLayout(new BorderLayout());
2070            namePanel.add(getNameTextField(), BorderLayout.CENTER);
2080        }
2090        return namePanel;
2100    }
2110 
2120    /**
213      * @return Returns the nameTextField.
2140     */
2150    protected JTextField getNameTextField() {
2160        if (nameTextField == null) {
2170            nameTextField = new JTextField();
2180            nameTextField.setText(Messages.getString("common.backup")); //$NON-NLS-1$
2190        }
2200        return nameTextField;
2210    }
222  
223     /**
224      * @return Returns the chooseZipLocationPathButton.
225      */
2260    protected JButton getChooseZipLocationPathButton() {
2270        if (chooseZipLocationPathButton == null) {
2280            chooseZipLocationPathButton = new JButton();
2290            chooseZipLocationPathButton.setToolTipText(Messages.getString("common.choosefolder")); //$NON-NLS-1$
2300            chooseZipLocationPathButton.setIcon(new ImageIcon(this.getClass()
2310                    .getResource("/icon/16x16/actions/document-open.png"))); //$NON-NLS-1$
2320            chooseZipLocationPathButton.addActionListener(new ActionListener() {
2330                public void actionPerformed(ActionEvent arg0) {
234                     logger.debug("actionPerformed chooseZipLocationPathButton"); //$NON-NLS-1$
235                     JFileChooser chooser = new JFileChooser();
2360                    chooser
237                             .setDialogTitle(Messages.getString("panel.backuppanel.message1")); //$NON-NLS-1$
238                     chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
239                     chooser.setApproveButtonText(Messages.getString("button.select")); //$NON-NLS-1$
240                     if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
241                         getZipLocationPathTextField().setText(
242                                 chooser.getSelectedFile().getPath());
2430                    }
244                 }
245             });
2460        }
2470        return chooseZipLocationPathButton;
2480    }
249  
2500    /**
251      * @return The backup's date.
252      */
2530    public Date getBackupDate() {
2540        return this.getCurrentDate();
2550    }
256  
2570    /**
258      * @return The backup's name.
259      */
2600    public String getBackupName() {
2610        return this.getNameTextField().getText();
2620    }
263  
2640    /**
265      * @return The backup's description.
266      */
2670    public String getBackupDescription() {
2680        return this.getDescriptionTextField().getText();
2690    }
270  
2710    /**
2720     * @return The backup's database location path.
273      */
2740    public String getDbLocationPath() {
2750        return this.getDbLocationPathTextField().getText();
2760    }
277  
278     /**
279      * @return The compressed backup file's path.
280      */
2810    public String getZipLocationPath() {
2820        return this.getZipLocationPathTextField().getText();
2830    }
284  
285     /**
286      * @return Returns the currentDate.
287      */
2880    protected Date getCurrentDate() {
2890        if (currentDate == null) {
2900            currentDate = new Date();
2910        }
2920        return currentDate;
2930    }
294 }

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.