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 | ||
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.PeerTableModel; | |
36 | ||
37 | @SuppressWarnings("serial") | |
38 | 0 | public class PeerPanel extends JPanel{ |
39 | ||
40 | 0 | private static final transient Logger logger = Logger.getLogger(PeerPanel.class.getName()); |
41 | ||
42 | /**The table where the neighborhood peers must be shown.**/ | |
43 | private JTable peerTable; | |
44 | /**This is needed to scroll the peers displayed in the peerTable.**/ | |
45 | private JScrollPane peerTableScrollPane; | |
46 | /**This is needed to sort the content of the peerTable.**/ | |
47 | private TableSorter peerTableSorter; | |
48 | /**This is the model for the network table.**/ | |
49 | private TableModel peerTableModel; | |
50 | /**The button panel is needed to offer some functions to the user.**/ | |
51 | private JPanel buttonPanel; | |
52 | ||
53 | /**This is the default constructor.**/ | |
54 | 0 | public PeerPanel(){ |
55 | 0 | initialize(); |
56 | 0 | } |
57 | ||
58 | /** | |
59 | * This method initializes the panel configuring and setting its components. | |
60 | */ | |
61 | protected void initialize(){ | |
62 | 0 | this.setBorder(new TitledBorder("Peer Panel")); |
63 | 0 | this.setLayout(new BorderLayout()); |
64 | 0 | this.add(getPeerTableScrollPane(), BorderLayout.CENTER); |
65 | 0 | this.add(getButtonPanel(), BorderLayout.EAST); |
66 | 0 | } |
67 | ||
68 | /** | |
69 | * @return Returns the peerTable. | |
70 | */ | |
71 | protected JTable getPeerTable() { | |
72 | 0 | if (peerTable == null) { |
73 | 0 | peerTable = new JTable(getPeerTableSorter()); |
74 | 0 | peerTable.setPreferredScrollableViewportSize(new Dimension(500, 70)); |
75 | // We need to place it here to avoid a ciclyc call... | |
76 | 0 | peerTableSorter.setTableHeader(peerTable.getTableHeader()); |
77 | // Set up tool tips for column headers. | |
78 | 0 | peerTable.getTableHeader().setToolTipText("Click to specify sorting; Control-Click to specify secondary sorting."); |
79 | } | |
80 | 0 | return peerTable; |
81 | } | |
82 | ||
83 | /** | |
84 | * @return Returns the peerTableScrollPane. | |
85 | */ | |
86 | protected JScrollPane getPeerTableScrollPane() { | |
87 | 0 | if (peerTableScrollPane == null) { |
88 | 0 | peerTableScrollPane = new JScrollPane(getPeerTable()); |
89 | } | |
90 | 0 | return peerTableScrollPane; |
91 | } | |
92 | ||
93 | /** | |
94 | * @return Returns the peerTableSorter. | |
95 | */ | |
96 | protected TableSorter getPeerTableSorter() { | |
97 | 0 | if (peerTableSorter == null) { |
98 | 0 | peerTableSorter = new TableSorter(getPeerTableModel()); |
99 | } | |
100 | 0 | return peerTableSorter; |
101 | } | |
102 | ||
103 | /** | |
104 | * @return Returns the peerTableModel. | |
105 | */ | |
106 | protected TableModel getPeerTableModel() { | |
107 | 0 | if (peerTableModel == null) { |
108 | 0 | peerTableModel = new PeerTableModel(); |
109 | } | |
110 | 0 | return peerTableModel; |
111 | } | |
112 | ||
113 | /** | |
114 | * @return the buttonPanel | |
115 | */ | |
116 | protected JPanel getButtonPanel() { | |
117 | 0 | if(buttonPanel == null){ |
118 | 0 | buttonPanel = new JPanel(); |
119 | 0 | buttonPanel.setLayout(new BorderLayout()); |
120 | } | |
121 | 0 | return buttonPanel; |
122 | } | |
123 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |