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.table; | |
21 | ||
22 | import javax.swing.DefaultCellEditor; | |
23 | import javax.swing.JComboBox; | |
24 | import javax.swing.JTable; | |
25 | import javax.swing.ListSelectionModel; | |
26 | import javax.swing.table.TableColumn; | |
27 | ||
28 | import ui.table.model.UserTableModel; | |
29 | import base.user.UserCredential; | |
30 | import base.user.UserGender; | |
31 | ||
32 | @SuppressWarnings("serial") //$NON-NLS-1$ | |
33 | public class UserTable extends JTable { | |
34 | /** | |
35 | * @param userTableSorter | |
36 | */ | |
37 | public UserTable(TableSorter userTableSorter) { | |
38 | 0 | super(userTableSorter); |
39 | 0 | initialize(); |
40 | 0 | } |
41 | ||
42 | protected void initialize() { | |
43 | 0 | this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
44 | 0 | TableColumn idColumn = this.getColumnModel().getColumn( |
45 | 0 | UserTableModel.USER_ID_COLUMN); |
46 | 0 | idColumn.setPreferredWidth(30); |
47 | 0 | idColumn.setMaxWidth(60); |
48 | ||
49 | 0 | TableColumn genderColumn = this.getColumnModel().getColumn( |
50 | 0 | UserTableModel.USER_GENDER_COLUMN); |
51 | 0 | DefaultCellEditor genderCellEditor = new DefaultCellEditor( |
52 | 0 | getUserGenderComboBox()); |
53 | 0 | genderCellEditor.setClickCountToStart(2); |
54 | 0 | genderColumn.setCellEditor(genderCellEditor); |
55 | 0 | genderColumn.setPreferredWidth(30); |
56 | ||
57 | 0 | TableColumn credentialColumn = this.getColumnModel().getColumn( |
58 | 0 | UserTableModel.USER_CREDENTIAL_COLUMN); |
59 | 0 | DefaultCellEditor credentialCellEditor = new DefaultCellEditor( |
60 | 0 | getUserCredentialComboBox()); |
61 | 0 | credentialCellEditor.setClickCountToStart(2); |
62 | 0 | credentialColumn.setCellEditor(credentialCellEditor); |
63 | 0 | credentialColumn.setPreferredWidth(40); |
64 | 0 | } |
65 | ||
66 | private JComboBox getUserGenderComboBox() { | |
67 | 0 | JComboBox comboBox = new JComboBox(); |
68 | 0 | for (int i = 0; i < UserGender.USER_GENDER.length; i++) |
69 | 0 | comboBox.addItem(UserGender.USER_GENDER[i]); |
70 | 0 | return comboBox; |
71 | } | |
72 | ||
73 | private JComboBox getUserCredentialComboBox() { | |
74 | 0 | JComboBox comboBox = new JComboBox(); |
75 | 0 | for (int i = 0; i < UserCredential.USER_CREDENTIAL.length; i++) |
76 | 0 | comboBox.addItem(UserCredential.USER_CREDENTIAL[i]); |
77 | 0 | return comboBox; |
78 | } | |
79 | ||
80 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |