Line | Hits | Source |
---|---|---|
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.Color; | |
24 | import java.awt.GridLayout; | |
25 | ||
26 | import javax.swing.JPanel; | |
27 | import javax.swing.JTextField; | |
28 | import javax.swing.border.TitledBorder; | |
29 | ||
30 | import ui.Messages; | |
31 | import base.user.EAddress; | |
32 | ||
33 | @SuppressWarnings("serial") //$NON-NLS-1$ | |
34 | public class EAddressPanel extends JPanel { | |
35 | ||
36 | private JPanel addressPanel; | |
37 | ||
38 | private JTextField addressTextField; | |
39 | ||
40 | private JPanel descriptionPanel; | |
41 | ||
42 | private JTextField descriptionTextField; | |
43 | ||
44 | private EAddress eAddress; | |
45 | ||
46 | /** | |
47 | * @param eAddress | |
48 | * The eAddress from whic must be retrieved each displayed | |
49 | * information. | |
50 | 0 | */ |
51 | 0 | public EAddressPanel(EAddress eAddress) { |
52 | 0 | this.eAddress = eAddress; |
53 | 0 | initialize(); |
54 | 0 | } |
55 | 0 | |
56 | 0 | protected void initialize() { |
57 | 0 | this.setLayout(new GridLayout(2, 1)); |
58 | 0 | this.add(getAddressPanel()); |
59 | 0 | this.add(getDescriptionPanel()); |
60 | 0 | } |
61 | 0 | |
62 | /** | |
63 | * @return Returns the addressPanel. | |
64 | */ | |
65 | 0 | protected JPanel getAddressPanel() { |
66 | 0 | if (addressPanel == null) { |
67 | 0 | addressPanel = new JPanel(); |
68 | 0 | addressPanel.setBorder(new TitledBorder(Messages.getString("common.elettronicmailaddress"))); //$NON-NLS-1$ |
69 | 0 | addressPanel.setLayout(new BorderLayout()); |
70 | 0 | addressPanel.add(getAddressTextField(), BorderLayout.CENTER); |
71 | 0 | } |
72 | 0 | return addressPanel; |
73 | 0 | } |
74 | ||
75 | /** | |
76 | * @return Returns the addressTextField. | |
77 | */ | |
78 | 0 | protected JTextField getAddressTextField() { |
79 | 0 | if (addressTextField == null) { |
80 | 0 | addressTextField = new JTextField(eAddress != null ? eAddress |
81 | 0 | .toString() : ""); //$NON-NLS-1$ |
82 | 0 | } |
83 | 0 | return addressTextField; |
84 | 0 | } |
85 | ||
86 | /** | |
87 | * @return Returns the descriptionPanel. | |
88 | */ | |
89 | 0 | protected JPanel getDescriptionPanel() { |
90 | 0 | if (descriptionPanel == null) { |
91 | 0 | descriptionPanel = new JPanel(); |
92 | 0 | descriptionPanel.setBorder(new TitledBorder(Messages.getString("common.description"))); //$NON-NLS-1$ |
93 | 0 | descriptionPanel.setLayout(new BorderLayout()); |
94 | 0 | descriptionPanel |
95 | 0 | .add(getDescriptionTextField(), BorderLayout.CENTER); |
96 | 0 | } |
97 | 0 | return descriptionPanel; |
98 | 0 | } |
99 | ||
100 | /** | |
101 | * @return Returns the descriptionTextField. | |
102 | */ | |
103 | 0 | protected JTextField getDescriptionTextField() { |
104 | 0 | if (descriptionTextField == null) { |
105 | 0 | descriptionTextField = new JTextField(eAddress != null ? eAddress |
106 | 0 | .getDescription() : ""); //$NON-NLS-1$ |
107 | 0 | } |
108 | 0 | return descriptionTextField; |
109 | 0 | } |
110 | ||
111 | 0 | public String getEAddress() { |
112 | 0 | return this.addressTextField.getText(); |
113 | 0 | } |
114 | ||
115 | 0 | public String getEAddressDescription() { |
116 | 0 | return this.descriptionTextField.getText(); |
117 | 0 | } |
118 | ||
119 | 0 | public void setAddressError(boolean isError) { |
120 | 0 | if (isError) |
121 | 0 | ((TitledBorder) this.getAddressPanel().getBorder()) |
122 | 0 | .setTitleColor(Color.RED); |
123 | 0 | else |
124 | 0 | ((TitledBorder) this.getAddressPanel().getBorder()) |
125 | 0 | .setTitleColor(new TitledBorder("").getTitleColor()); //$NON-NLS-1$ |
126 | 0 | this.getAddressPanel().updateUI(); |
127 | 0 | } |
128 | 0 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |