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  package ui.panel;
21  
22  import java.awt.BorderLayout;
23  import java.awt.FlowLayout;
24  import java.awt.event.ActionEvent;
25  import java.awt.event.ActionListener;
26  
27  import javax.swing.JButton;
28  import javax.swing.JPanel;
29  import javax.swing.JTextField;
30  import javax.swing.border.TitledBorder;
31  
32  import org.apache.log4j.Logger;
33  
34  import ui.Messages;
35  
36  @SuppressWarnings("serial") //$NON-NLS-1$
37  public class UserSearchPanel extends JPanel {
38  
39  	private static final transient Logger logger = Logger
40  			.getLogger(UserSearchPanel.class.getName());
41  
42  
43  	private String[] data;
44  
45  	private JPanel contentPanel;
46  
47  	private JPanel buttonPanel;
48  
49  	private JTextField searchTextField;
50  
51  	public UserSearchPanel() {
52  		initialize();
53  	}
54  
55  	protected void initialize() {
56  		this.setLayout(new BorderLayout());
57  		this.add(getContentPanel(), BorderLayout.CENTER);
58  	}
59  
60  	/***
61  	 * @return Returns the data.
62  	 */
63  	protected String[] getData() {
64  		return data;
65  	}
66  
67  	/***
68  	 * @param data
69  	 *            The data to set.
70  	 */
71  	protected void setData(String[] data) {
72  		this.data = data;
73  	}
74  
75  	/***
76  	 * @return Returns the buttonPanel.
77  	 */
78  	protected JPanel getButtonPanel() {
79  		if (buttonPanel == null) {
80  			buttonPanel = new JPanel();
81  			buttonPanel.setLayout(new FlowLayout());
82  			JButton searchButton = new JButton(Messages.getString("button.search")); //$NON-NLS-1$
83  			buttonPanel.add(searchButton);
84  
85  			searchButton.addActionListener(new ActionListener() {
86  				public void actionPerformed(ActionEvent arg0) {
87  					logger.debug("actionPerformed saveButton"); //$NON-NLS-1$
88  				}
89  			});
90  		}
91  		return buttonPanel;
92  	}
93  
94  	/***
95  	 * @return Returns the contentPanel.
96  	 */
97  	protected JPanel getContentPanel() {
98  		if (contentPanel == null) {
99  			contentPanel = new JPanel();
100 			TitledBorder titledBorder = new TitledBorder(Messages.getString("panel.usersearchpanel.searchuser")); //$NON-NLS-1$
101 			contentPanel.setBorder(titledBorder);
102 			contentPanel.setLayout(new BorderLayout());
103 			contentPanel.add(getSearchTextField(), BorderLayout.CENTER);
104 			contentPanel.add(getButtonPanel(), BorderLayout.SOUTH);
105 		}
106 		return contentPanel;
107 	}
108 
109 	/***
110 	 * @return Returns the searchTextField.
111 	 */
112 	protected JTextField getSearchTextField() {
113 		if (searchTextField == null) {
114 			searchTextField = new JTextField();
115 		}
116 		return searchTextField;
117 	}
118 
119 }