View Javadoc

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 base.jdbs.ui.panel;
22  
23  import java.awt.BorderLayout;
24  import java.awt.GridLayout;
25  
26  import javax.swing.JPanel;
27  import javax.swing.JScrollPane;
28  import javax.swing.JTextArea;
29  import javax.swing.JTextField;
30  import javax.swing.border.TitledBorder;
31  
32  import org.apache.log4j.Logger;
33  
34  import base.jdbs.network.NetworkManager;
35  
36  /***
37   * @author skunk
38   * 
39   */
40  @SuppressWarnings("serial")
41  public class InfoPanel extends JPanel {
42  
43  	private static final transient Logger logger = Logger
44  			.getLogger(InfoPanel.class.getName());
45  
46  	private JPanel peerGroupIdPanel;
47  
48  	private JPanel peerGroupNamePanel;
49  
50  	private JPanel peerGroupAdvertisementPanel;
51  
52  	private JPanel peerGroupAdvertisementTypePanel;
53  
54  	private JPanel peerGroupAdvertisementDescriptionPanel;
55  
56  	private JPanel peerIdPanel;
57  
58  	private JPanel peerNamePanel;
59  
60  	private JTextField peerGroupIdTextField;
61  
62  	private JTextField peerGroupNameTextField;
63  
64  	private JScrollPane peerGroupAdvertisementScrollPane;
65  
66  	private JTextArea peerGroupAdvertisementTextArea;
67  
68  	private JTextField peerGroupAdvertisementTypeTextField;
69  
70  	private JTextField peerGroupAdvertisementDescriptionTextField;
71  
72  	private JTextField peerIdTextField;
73  
74  	private JTextField peerNameTextField;
75  
76  	public InfoPanel() {
77  		initialize();
78  	}
79  
80  	protected void initialize() {
81  		this.setLayout(new GridLayout(7, 1));
82  		this.add(this.getPeerGroupIdPanel());
83  		this.add(this.getPeerGroupNamePanel());
84  		this.add(this.getPeerGroupAdvertisementPanel());
85  		this.add(this.getPeerGroupAdvertisementTypePanel());
86  		this.add(this.getPeerGroupAdvertisementDescriptionPanel());
87  
88  		this.add(this.getPeerIdPanel());
89  		this.add(this.getPeerNamePanel());
90  	}
91  
92  	/***
93  	 * @return Returns the peerGroupIdTextField.
94  	 */
95  	protected JTextField getPeerGroupIdTextField() {
96  		if (this.peerGroupIdTextField == null) {
97  			this.peerGroupIdTextField = new JTextField();
98  			this.peerGroupIdTextField.setEditable(false);
99  			this.peerGroupIdTextField.setText(NetworkManager.getInstance().getJdbsPeerGroup().getPeerGroupID().toString());
100 		}
101 		return peerGroupIdTextField;
102 	}
103 
104 	/***
105 	 * @return Returns the peerGroupNameTextField.
106 	 */
107 	protected JTextField getPeerGroupNameTextField() {
108 		if (this.peerGroupNameTextField == null) {
109 			this.peerGroupNameTextField = new JTextField();
110 			this.peerGroupNameTextField.setEditable(false);
111 			this.peerGroupNameTextField.setText(NetworkManager.getInstance().getJdbsPeerGroup().getPeerGroupName());
112 		}
113 		return peerGroupNameTextField;
114 	}
115 
116 	/***
117 	 * @return Returns the peerGroupAdvertisementTextArea.
118 	 */
119 	protected JTextArea getPeerGroupAdvertisementTextArea() {
120 		if (this.peerGroupAdvertisementTextArea == null) {
121 			this.peerGroupAdvertisementTextArea = new JTextArea();
122 			this.peerGroupAdvertisementTextArea.setEditable(false);
123 			this.peerGroupAdvertisementTextArea.setText(NetworkManager.getInstance().getJdbsPeerGroup().getPeerAdvertisement().toString());
124 		}
125 		return peerGroupAdvertisementTextArea;
126 	}
127 
128 	/***
129 	 * @return Returns the peerGroupAdvertisementTypeTextField.
130 	 */
131 	protected JTextField getPeerGroupAdvertisementTypeTextField() {
132 		if (this.peerGroupAdvertisementTypeTextField == null) {
133 			this.peerGroupAdvertisementTypeTextField = new JTextField();
134 			this.peerGroupAdvertisementTypeTextField.setEditable(false);
135 			this.peerGroupAdvertisementTypeTextField.setText(NetworkManager.getInstance().getJdbsPeerGroup().getPeerAdvertisement().getAdvType());
136 		}
137 		return peerGroupAdvertisementTypeTextField;
138 	}
139 
140 	/***
141 	 * @return Returns the peerGroupAdvertisementDescriptionTextField.
142 	 */
143 	protected JTextField getPeerGroupAdvertisementDescriptionTextField() {
144 		if (this.peerGroupAdvertisementDescriptionTextField == null) {
145 			this.peerGroupAdvertisementDescriptionTextField = new JTextField();
146 			this.peerGroupAdvertisementDescriptionTextField.setEditable(false);
147 			this.peerGroupAdvertisementDescriptionTextField.setText(NetworkManager.getInstance().getJdbsPeerGroup().getPeerAdvertisement().getDescription());
148 		}
149 		return peerGroupAdvertisementDescriptionTextField;
150 	}
151 
152 	/***
153 	 * @return Returns the peerIdTextField.
154 	 */
155 	protected JTextField getPeerIdTextField() {
156 		if (this.peerIdTextField == null) {
157 			this.peerIdTextField = new JTextField();
158 			this.peerIdTextField.setEditable(false);
159 			this.peerIdTextField.setText(NetworkManager.getInstance().getJdbsPeerGroup().getPeerID().toString());
160 		}
161 		return peerIdTextField;
162 	}
163 
164 	/***
165 	 * @return Returns the peerNameTextField.
166 	 */
167 	protected JTextField getPeerNameTextField() {
168 		if (this.peerNameTextField == null) {
169 			this.peerNameTextField = new JTextField();
170 			this.peerNameTextField.setEditable(false);
171 			this.peerNameTextField.setText(NetworkManager.getInstance().getJdbsPeerGroup().getPeerName());
172 		}
173 		return peerNameTextField;
174 	}
175 
176 	/***
177 	 * @return Returns the peerGroupIdPanel.
178 	 */
179 	protected JPanel getPeerGroupIdPanel() {
180 		if (this.peerGroupIdPanel == null) {
181 			this.peerGroupIdPanel = new JPanel();
182 			this.peerGroupIdPanel.setBorder(new TitledBorder("Peer Group ID"));
183 			this.peerGroupIdPanel.setLayout(new BorderLayout());
184 			this.peerGroupIdPanel.add(this.getPeerGroupIdTextField(),
185 					BorderLayout.CENTER);
186 		}
187 		return peerGroupIdPanel;
188 	}
189 
190 	/***
191 	 * @return Returns the peerGroupNamePanel.
192 	 */
193 	protected JPanel getPeerGroupNamePanel() {
194 		if (this.peerGroupNamePanel == null) {
195 			this.peerGroupNamePanel = new JPanel();
196 			this.peerGroupNamePanel.setBorder(new TitledBorder(
197 					"Peer Group Name"));
198 			this.peerGroupNamePanel.setLayout(new BorderLayout());
199 			this.peerGroupNamePanel.add(this.getPeerGroupNameTextField(),
200 					BorderLayout.CENTER);
201 		}
202 		return peerGroupNamePanel;
203 	}
204 
205 	/***
206 	 * @return Returns the peerGroupAdvertisementScrollPane.
207 	 */
208 	protected JScrollPane getPeerGroupAdvertisementScrollPane() {
209 		if (this.peerGroupAdvertisementScrollPane == null) {
210 			this.peerGroupAdvertisementScrollPane = new JScrollPane(this
211 					.getPeerGroupAdvertisementTextArea());
212 
213 		}
214 		return peerGroupAdvertisementScrollPane;
215 	}
216 
217 	/***
218 	 * @return Returns the peerGroupAdvertisementPanel.
219 	 */
220 	protected JPanel getPeerGroupAdvertisementPanel() {
221 		if (this.peerGroupAdvertisementPanel == null) {
222 			this.peerGroupAdvertisementPanel = new JPanel();
223 			this.peerGroupAdvertisementPanel.setBorder(new TitledBorder(
224 					"Peer Group Advertisement"));
225 			this.peerGroupAdvertisementPanel.setLayout(new BorderLayout());
226 			this.peerGroupAdvertisementPanel
227 					.add(this.getPeerGroupAdvertisementScrollPane(),
228 							BorderLayout.CENTER);
229 		}
230 		return peerGroupAdvertisementPanel;
231 	}
232 
233 	/***
234 	 * @return Returns the peerGroupAdvertisementTypePanel.
235 	 */
236 	protected JPanel getPeerGroupAdvertisementTypePanel() {
237 		if (this.peerGroupAdvertisementTypePanel == null) {
238 			this.peerGroupAdvertisementTypePanel = new JPanel();
239 			this.peerGroupAdvertisementTypePanel.setBorder(new TitledBorder(
240 					"Peer Group Advertisement Type"));
241 			this.peerGroupAdvertisementTypePanel.setLayout(new BorderLayout());
242 			this.peerGroupAdvertisementTypePanel.add(this
243 					.getPeerGroupAdvertisementTypeTextField(),
244 					BorderLayout.CENTER);
245 		}
246 		return peerGroupAdvertisementTypePanel;
247 	}
248 
249 	/***
250 	 * @return Returns the peerGroupAdvertisementDescriptionPanel.
251 	 */
252 	protected JPanel getPeerGroupAdvertisementDescriptionPanel() {
253 		if (this.peerGroupAdvertisementDescriptionPanel == null) {
254 			this.peerGroupAdvertisementDescriptionPanel = new JPanel();
255 			this.peerGroupAdvertisementDescriptionPanel
256 					.setBorder(new TitledBorder(
257 							"Peer Group Advertisement Description"));
258 			this.peerGroupAdvertisementDescriptionPanel
259 					.setLayout(new BorderLayout());
260 			this.peerGroupAdvertisementDescriptionPanel.add(this
261 					.getPeerGroupAdvertisementDescriptionTextField(),
262 					BorderLayout.CENTER);
263 		}
264 		return peerGroupAdvertisementDescriptionPanel;
265 	}
266 
267 	/***
268 	 * @return Returns the peerIdPanel.
269 	 */
270 	protected JPanel getPeerIdPanel() {
271 		if (this.peerIdPanel == null) {
272 			this.peerIdPanel = new JPanel();
273 			this.peerIdPanel.setBorder(new TitledBorder("Peer ID"));
274 			this.peerIdPanel.setLayout(new BorderLayout());
275 			this.peerIdPanel
276 					.add(this.getPeerIdTextField(), BorderLayout.CENTER);
277 		}
278 		return peerIdPanel;
279 	}
280 
281 	/***
282 	 * @return Returns the peerNamePanel.
283 	 */
284 	protected JPanel getPeerNamePanel() {
285 		if (this.peerNamePanel == null) {
286 			this.peerNamePanel = new JPanel();
287 			this.peerNamePanel.setBorder(new TitledBorder("Peer Name"));
288 			this.peerNamePanel.setLayout(new BorderLayout());
289 			this.peerNamePanel.add(this.getPeerNameTextField(),
290 					BorderLayout.CENTER);
291 		}
292 		return peerNamePanel;
293 	}
294 
295 }