Coverage details for ui.dialog.BackupDialog

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.dialog;
22  
23 import java.awt.BorderLayout;
24 import java.awt.Dimension;
250import java.awt.GridLayout;
26 import java.awt.Toolkit;
270import java.awt.event.ActionEvent;
28 import java.awt.event.ActionListener;
29  
30 import javax.swing.JButton;
31 import javax.swing.JDialog;
32 import javax.swing.JPanel;
33 import javax.swing.border.TitledBorder;
34  
35 import org.apache.log4j.Logger;
36  
37 import ui.Messages;
380import ui.command.CommandExecutor;
390import ui.command.IO.SaveBackupCommand;
400import ui.panel.BackupPanel;
41  
420@SuppressWarnings("serial") //$NON-NLS-1$
430public class BackupDialog extends JDialog {
440 
450    private static final transient Logger logger = Logger
460            .getLogger(BackupDialog.class.getName());
470 
480    private BackupPanel backupPanel;
490 
50     private JPanel buttonPanel;
510 
520    private JButton saveButton;
53  
540    private JButton closeButton;
550 
560    public BackupDialog() {
570        initialize();
580    }
590 
600    protected void initialize() {
610        this.setResizable(false);
620        this.setSize(300, 400);
630        // Center the dialog
640        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
650        Dimension frameSize = this.getSize();
660        if (frameSize.height > screenSize.height) {
670            frameSize.height = screenSize.height;
680        }
690        if (frameSize.width > screenSize.width) {
700            frameSize.width = screenSize.width;
710        }
720        this.setLocation((screenSize.width - frameSize.width) / 2,
730                (screenSize.height - frameSize.height) / 2);
740 
750        this.setLayout(new BorderLayout());
760        this.add(getBackupPanel(), BorderLayout.CENTER);
770        this.add(getButtonPanel(), BorderLayout.SOUTH);
780    }
790 
800    /**
810     * @return Returns the backupPanel.
82      */
830    protected BackupPanel getBackupPanel() {
840        if (backupPanel == null) {
850            backupPanel = new BackupPanel();
860        }
870        return backupPanel;
88     }
89  
900    /**
910     * @return Returns the buttonPanel.
920     */
930    protected JPanel getButtonPanel() {
940        if (buttonPanel == null) {
950            buttonPanel = new JPanel();
960            buttonPanel.setBorder(new TitledBorder(Messages.getString("dialog.availableactions"))); //$NON-NLS-1$
970            buttonPanel.setLayout(new GridLayout(1, 2));
980            buttonPanel.add(getSaveButton());
990            buttonPanel.add(getCloseButton());
1000        }
1010        return buttonPanel;
102     }
103  
104     /**
105      * @return Returns the closeButton.
1060     */
1070    protected JButton getCloseButton() {
1080        if (closeButton == null) {
1090            closeButton = new JButton(Messages.getString("button.close")); //$NON-NLS-1$
1100            closeButton.addActionListener(new ActionListener() {
111                 public void actionPerformed(ActionEvent arg0) {
112                     logger.debug("actionPerformed closeButton"); //$NON-NLS-1$
113                     setVisible(false);
114                 }
115             });
1160        }
1170        return closeButton;
118     }
119  
120     /**
121      * @return Returns the saveButton.
122      */
1230    protected JButton getSaveButton() {
1240        if (saveButton == null) {
1250            saveButton = new JButton(Messages.getString("button.save")); //$NON-NLS-1$
1260            saveButton.addActionListener(new ActionListener() {
127                 public void actionPerformed(ActionEvent arg0) {
128                     logger.debug("actionPerformed saveButton"); //$NON-NLS-1$
129                     CommandExecutor.getInstance().executeCommand(
130                             new SaveBackupCommand(getBackupPanel()), false);
131                     setVisible(false);
132                 }
133             });
1340        }
1350        return saveButton;
136     }
137 }

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.