Coverage details for ui.panel.PhoneNumberPanel

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.panel;
21  
22 import java.awt.BorderLayout;
23 import java.awt.GridLayout;
24  
25 import javax.swing.JPanel;
26 import javax.swing.JTextField;
27 import javax.swing.border.TitledBorder;
28  
29 import ui.Messages;
30 import base.user.PhoneNumber;
31  
32 @SuppressWarnings("serial") //$NON-NLS-1$
33 public class PhoneNumberPanel extends JPanel {
34  
35     private JPanel areaCodePanel;
36  
37     private JTextField areaCodeTextField;
38  
39     private JPanel exchangePanel;
40  
41     private JTextField exchangeTextField;
42  
43     private JPanel numberPanel;
44  
45     private JTextField numberTextField;
46  
47     private JPanel descriptionPanel;
48  
49     private JTextField descriptionTextField;
50  
510    public String getPhoneNumberAreaCode() {
520        return this.getAreaCodeTextField().getText();
530    }
54  
550    public String getPhoneNumberExchange() {
560        return this.getExchangeTextField().getText();
570    }
58  
590    public String getPhoneNumberNumber() {
600        return this.getNumberTextField().getText();
610    }
62  
630    public String getPhoneNumberDescription() {
640        return this.getDescriptionTextField().getText();
650    }
66  
67     private PhoneNumber phoneNumber;
68  
69     /**
70      * @param phoneNumber
71      * The PhoneNumber from which the displayed informations must be
72      * retrieved.
730     */
740    public PhoneNumberPanel(PhoneNumber phoneNumber) {
750        this.phoneNumber = phoneNumber;
760        initialize();
770    }
780 
790    protected void initialize() {
800        this.setLayout(new GridLayout(4, 1));
810        this.add(getAreaCodePanel());
820        this.add(getExchangePanel());
830        this.add(getNumberPanel());
840        this.add(getDescriptionPanel());
850    }
860 
87     /**
88      * @return Returns the areaCodePanel.
89      */
900    protected JPanel getAreaCodePanel() {
910        if (areaCodePanel == null) {
920            areaCodePanel = new JPanel();
930            areaCodePanel.setBorder(new TitledBorder(Messages.getString("common.areacode"))); //$NON-NLS-1$
940            areaCodePanel.setLayout(new BorderLayout());
950            areaCodePanel.add(getAreaCodeTextField(), BorderLayout.CENTER);
960        }
970        return areaCodePanel;
980    }
99  
100     /**
101      * @return Returns the descriptionPanel.
102      */
1030    protected JPanel getDescriptionPanel() {
1040        if (descriptionPanel == null) {
1050            descriptionPanel = new JPanel();
1060            descriptionPanel.setBorder(new TitledBorder(Messages.getString("common.description"))); //$NON-NLS-1$
1070            descriptionPanel.setLayout(new BorderLayout());
1080            descriptionPanel
1090                    .add(getDescriptionTextField(), BorderLayout.CENTER);
1100        }
1110        return descriptionPanel;
1120    }
113  
114     /**
115      * @return Returns the exchangePanel.
116      */
1170    protected JPanel getExchangePanel() {
1180        if (exchangePanel == null) {
1190            exchangePanel = new JPanel();
1200            exchangePanel.setBorder(new TitledBorder(Messages.getString("common.exchange"))); //$NON-NLS-1$
1210            exchangePanel.setLayout(new BorderLayout());
1220            exchangePanel.add(getExchangeTextField(), BorderLayout.CENTER);
1230        }
1240        return exchangePanel;
1250    }
126  
127     /**
128      * @return Returns the numberPanel.
129      */
1300    protected JPanel getNumberPanel() {
1310        if (numberPanel == null) {
1320            numberPanel = new JPanel();
1330            numberPanel.setBorder(new TitledBorder(Messages.getString("common.number"))); //$NON-NLS-1$
1340            numberPanel.setLayout(new BorderLayout());
1350            numberPanel.add(getNumberTextField(), BorderLayout.CENTER);
1360        }
1370        return numberPanel;
1380    }
139  
140     /**
141      * @return Returns the areaCodeTextField.
142      */
1430    protected JTextField getAreaCodeTextField() {
1440        if (areaCodeTextField == null) {
1450            areaCodeTextField = new JTextField();
1460            areaCodeTextField.setText(phoneNumber != null ? "" //$NON-NLS-1$
1470                    + phoneNumber.getAreaCode() : Messages.getString("phonenumber.default.areacode")); //$NON-NLS-1$
1480        }
1490        return areaCodeTextField;
1500    }
151  
152     /**
153      * @return Returns the descriptionTextField.
154      */
1550    protected JTextField getDescriptionTextField() {
1560        if (descriptionTextField == null) {
1570            descriptionTextField = new JTextField();
1580            descriptionTextField.setText(phoneNumber != null ? phoneNumber
1590                    .getDescription() : ""); //$NON-NLS-1$
1600        }
1610        return descriptionTextField;
1620    }
163  
164     /**
165      * @return Returns the exchangeTextField.
166      */
1670    protected JTextField getExchangeTextField() {
1680        if (exchangeTextField == null) {
1690            exchangeTextField = new JTextField();
1700            exchangeTextField.setText(phoneNumber != null ? phoneNumber
1710                    .getExchange() : ""); //$NON-NLS-1$
1720        }
1730        return exchangeTextField;
1740    }
175  
176     /**
177      * @return Returns the numberTextField.
178      */
1790    protected JTextField getNumberTextField() {
1800        if (numberTextField == null) {
1810            numberTextField = new JTextField();
1820            numberTextField.setText(phoneNumber != null ? phoneNumber
1830                    .getNumber() : ""); //$NON-NLS-1$
1840        }
1850        return numberTextField;
1860    }
187  
188 }

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.