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.Dimension;
25  
26  import javax.swing.JPanel;
27  import javax.swing.JScrollPane;
28  import javax.swing.JTable;
29  import javax.swing.border.TitledBorder;
30  import javax.swing.table.TableModel;
31  
32  import org.apache.log4j.Logger;
33  
34  import ui.table.TableSorter;
35  import base.jdbs.ui.TransfersTableModel;
36  
37  @SuppressWarnings("serial")
38  public class TabledTransfersPanel extends JPanel {
39  
40  	private static final transient Logger logger = Logger
41  			.getLogger(TabledTransfersPanel.class.getName());
42  
43  	private JTable transfersTable;
44  
45  	private JScrollPane transfersTableScrollPane;
46  
47  	private TableSorter transfersTableSorter;
48  
49  	private TableModel transfersTableModel;
50  
51  	public TabledTransfersPanel() {
52  		initialize();
53  	}
54  
55  	protected void initialize() {
56  		this.setBorder(new TitledBorder("Transfers Panel"));
57  		this.setLayout(new BorderLayout());
58  		this.add(getTransfersTableScrollPane(), BorderLayout.CENTER);
59  		// this.add(getButtonPanel(), BorderLayout.EAST);
60  	}
61  
62  	/***
63  	 * @return Returns the transfersTable.
64  	 */
65  	protected JTable getTransfersTable() {
66  		if (this.transfersTable == null) {
67  			this.transfersTable = new JTable(getTransfersTableSorter());
68  			this.transfersTable
69  					.setPreferredScrollableViewportSize(new Dimension(500, 70));
70  			// We need to place it here to avoid a ciclyc call...
71  			this.transfersTableSorter.setTableHeader(transfersTable
72  					.getTableHeader());
73  			// Set up tool tips for column headers.
74  			this.transfersTable
75  					.getTableHeader()
76  					.setToolTipText(
77  							"Click to specify sorting; Control-Click to specify secondary sorting.");
78  		}
79  		return transfersTable;
80  	}
81  
82  	/***
83  	 * @return Returns the transfersTableScrollPane.
84  	 */
85  	protected JScrollPane getTransfersTableScrollPane() {
86  		if (this.transfersTableScrollPane == null) {
87  			this.transfersTableScrollPane = new JScrollPane(getTransfersTable());
88  		}
89  		return transfersTableScrollPane;
90  	}
91  
92  	/***
93  	 * @return Returns the transfersTableSorter.
94  	 */
95  	protected TableSorter getTransfersTableSorter() {
96  		if (this.transfersTableSorter == null) {
97  			this.transfersTableSorter = new TableSorter(
98  					getTransfersTableModel());
99  		}
100 		return transfersTableSorter;
101 	}
102 
103 	/***
104 	 * @return Returns the transfersTableModel.
105 	 */
106 	protected TableModel getTransfersTableModel() {
107 		if (this.transfersTableModel == null) {
108 			this.transfersTableModel = new TransfersTableModel();
109 		}
110 		return transfersTableModel;
111 	}
112 
113 }