Coverage details for ui.dialog.UserAddressBookDialog

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 package ui.dialog;
21  
22 import java.awt.BorderLayout;
23 import java.awt.Dimension;
24 import java.awt.GridLayout;
25 import java.awt.Toolkit;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28  
29 import javax.swing.JButton;
30 import javax.swing.JDialog;
31 import javax.swing.JLabel;
32 import javax.swing.JPanel;
33 import javax.swing.border.TitledBorder;
34  
35 import org.apache.log4j.Logger;
36  
37 import ui.Messages;
38 import ui.panel.UserAddressBookPanel;
39 import base.user.User;
40  
410@SuppressWarnings("serial") //$NON-NLS-1$
420public class UserAddressBookDialog extends JDialog {
430 
440    private static final transient Logger logger = Logger
450            .getLogger(UserAddressBookDialog.class.getName());
46  
47     private JPanel contentPanel;
48  
49     private UserAddressBookPanel userAddressBookPanel;
50  
51     private JPanel buttonPanel;
52  
53     private JButton closeButton;
54  
55     private final User user;
560 
570    public UserAddressBookDialog(User user) {
580        this.user = user;
590        initialize();
600    }
61  
620    protected void initialize() {
630        this.setResizable(false);
640        this.setSize(550, 600);
650        // Center the dialog
660        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
670        Dimension frameSize = this.getSize();
680        if (frameSize.height > screenSize.height) {
690            frameSize.height = screenSize.height;
700        }
710        if (frameSize.width > screenSize.width) {
720            frameSize.width = screenSize.width;
730        }
740        this.setLocation((screenSize.width - frameSize.width) / 2,
750                (screenSize.height - frameSize.height) / 2);
760 
770        this.setContentPane(getContentPanel());
780        this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
790    }
80  
81     /**
82      * @return Returns the contentPanel.
83      */
840    protected JPanel getContentPanel() {
850        if (contentPanel == null) {
860            contentPanel = new JPanel();
870            contentPanel.setLayout(new BorderLayout());
880            contentPanel.add(getUserAddressBookPanel(), BorderLayout.CENTER);
890            contentPanel.add(getButtonPanel(), BorderLayout.SOUTH);
900        }
910        return contentPanel;
92     }
93  
94     /**
95      * @return Returns the buttonPanel.
96      */
970    protected JPanel getButtonPanel() {
980        if (buttonPanel == null) {
990            buttonPanel = new JPanel();
1000            buttonPanel.setBorder(new TitledBorder(Messages.getString("dialog.availableactions"))); //$NON-NLS-1$
1010            buttonPanel.setLayout(new GridLayout(1, 3));
1020            buttonPanel.add(new JLabel("")); //$NON-NLS-1$
1030            buttonPanel.add(getCloseButton());
1040            buttonPanel.add(new JLabel("")); //$NON-NLS-1$
105  
1060        }
1070        return buttonPanel;
108     }
109  
110     /**
111      * @return Returns the userAddressBookPanel.
112      */
1130    protected UserAddressBookPanel getUserAddressBookPanel() {
1140        if (userAddressBookPanel == null) {
1150            userAddressBookPanel = new UserAddressBookPanel(getUser());
1160        }
1170        return userAddressBookPanel;
118     }
119  
120     /**
121      * @return Returns the user.
122      */
1230    protected User getUser() {
1240        return user;
125     }
126  
127     /**
128      * @return Returns the closeButton.
129      */
1300    protected JButton getCloseButton() {
1310        if (closeButton == null) {
1320            closeButton = new JButton(Messages.getString("button.close")); //$NON-NLS-1$
133             // closeButton.setIcon(new
1340            // ImageIcon(this.getClass().getResource("/icon/16x16/actions/window-close.png")));
1350            closeButton.addActionListener(new ActionListener() {
136                 public void actionPerformed(ActionEvent arg0) {
137                     logger.debug("actionPerformed closeButton"); //$NON-NLS-1$
138                     setVisible(false);
139                 }
140             });
1410        }
1420        return closeButton;
143     }
144 }

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.