 
| 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.model; | |
| 21 | ||
| 22 | import javax.swing.table.AbstractTableModel; | |
| 23 | ||
| 24 | import ui.Messages; | |
| 25 | import base.InternetCafeManager; | |
| 26 | import base.user.User; | |
| 27 | ||
| 28 | @SuppressWarnings("serial") //$NON-NLS-1$ | |
| 29 | public class ReducedUserTableModel extends AbstractTableModel { | |
| 30 | 0 | |
| 31 | 0 | String[] columnNames = { Messages.getString("common.id"), Messages.getString("common.name"), Messages.getString("common.surname"), Messages.getString("common.nickname"), }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ | 
| 32 | 0 | |
| 33 | public static final int USER_ID_COLUMN = 0; | |
| 34 | ||
| 35 | public static final int USER_NAME_COLUMN = 1; | |
| 36 | ||
| 37 | public static final int USER_SURNAME_COLUMN = 2; | |
| 38 | ||
| 39 | public static final int USER_NICKNAME_COLUMN = 3; | |
| 40 | ||
| 41 | 0 | public ReducedUserTableModel() { | 
| 42 | 0 | super(); | 
| 43 | 0 | } | 
| 44 | 0 | |
| 45 | 0 | public int getColumnCount() { | 
| 46 | 0 | return columnNames.length; | 
| 47 | 0 | } | 
| 48 | ||
| 49 | 0 | public int getRowCount() { | 
| 50 | 0 | return InternetCafeManager.getInstance().getUser().length; | 
| 51 | 0 | } | 
| 52 | ||
| 53 | 0 | public String getColumnName(int col) { | 
| 54 | 0 | return columnNames[col]; | 
| 55 | 0 | } | 
| 56 | ||
| 57 | 0 | public Object getValueAt(int row, int column) { | 
| 58 | 0 | if (row < 0 || column < 0) | 
| 59 | 0 | return null; | 
| 60 | 0 | User[] user = InternetCafeManager.getInstance().getUser(); | 
| 61 | 0 | Object result = null; | 
| 62 | 0 | switch (column) { | 
| 63 | 0 | case USER_ID_COLUMN:// Id | 
| 64 | 0 | result = user[row].getId(); | 
| 65 | 0 | break; | 
| 66 | 0 | case USER_NAME_COLUMN:// Name | 
| 67 | 0 | result = user[row].getName(); | 
| 68 | 0 | break; | 
| 69 | 0 | case USER_SURNAME_COLUMN:// Surname | 
| 70 | 0 | result = user[row].getSurname(); | 
| 71 | 0 | break; | 
| 72 | 0 | case USER_NICKNAME_COLUMN:// Nickname | 
| 73 | 0 | result = user[row].getNickname(); | 
| 74 | 0 | break; | 
| 75 | 0 | } | 
| 76 | 0 | return result; | 
| 77 | 0 | } | 
| 78 | ||
| 79 | @SuppressWarnings("unchecked") //$NON-NLS-1$ | |
| 80 | 0 | public Class getColumnClass(int column) { | 
| 81 | 0 | if (column < 0) | 
| 82 | 0 | return null; | 
| 83 | 0 | Class result = null; | 
| 84 | 0 | switch (column) { | 
| 85 | 0 | case USER_ID_COLUMN:// Id | 
| 86 | 0 | result = Integer.class; | 
| 87 | 0 | break; | 
| 88 | 0 | case USER_NAME_COLUMN:// Name | 
| 89 | 0 | result = String.class; | 
| 90 | 0 | break; | 
| 91 | 0 | case USER_SURNAME_COLUMN:// Surname | 
| 92 | 0 | result = String.class; | 
| 93 | 0 | break; | 
| 94 | 0 | case USER_NICKNAME_COLUMN:// Nickname | 
| 95 | 0 | result = String.class; | 
| 96 | 0 | break; | 
| 97 | 0 | } | 
| 98 | 0 | return result; | 
| 99 | 0 | } | 
| 100 | ||
| 101 | /* | |
| 102 | * Don't need to implement this method unless your table's editable. | |
| 103 | */ | |
| 104 | 0 | public boolean isCellEditable(int row, int column) { | 
| 105 | 0 | if (row < 0 || column < 0) | 
| 106 | 0 | return false; | 
| 107 | 0 | // Note that the data/cell address is constant, | 
| 108 | 0 | // no matter where the cell appears onscreen. | 
| 109 | 0 | boolean result = false; | 
| 110 | 0 | switch (column) { | 
| 111 | 0 | case USER_ID_COLUMN:// Id | 
| 112 | 0 | result = false; | 
| 113 | 0 | break; | 
| 114 | 0 | case USER_NAME_COLUMN:// Name | 
| 115 | 0 | result = false; | 
| 116 | 0 | break; | 
| 117 | 0 | case USER_SURNAME_COLUMN:// Surname | 
| 118 | 0 | result = false; | 
| 119 | 0 | break; | 
| 120 | 0 | case USER_NICKNAME_COLUMN:// Nickname | 
| 121 | 0 | result = false; | 
| 122 | 0 | break; | 
| 123 | 0 | } | 
| 124 | 0 | return result; | 
| 125 | 0 | } | 
| 126 | } | 
| 
this report was generated by version 1.0.5 of jcoverage. | 
copyright © 2003, jcoverage ltd. all rights reserved. |