Coverage details for ui.table.model.ReducedUserTableModel

LineHitsSource
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 {
300 
310    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$
320 
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  
410    public ReducedUserTableModel() {
420        super();
430    }
440 
450    public int getColumnCount() {
460        return columnNames.length;
470    }
48  
490    public int getRowCount() {
500        return InternetCafeManager.getInstance().getUser().length;
510    }
52  
530    public String getColumnName(int col) {
540        return columnNames[col];
550    }
56  
570    public Object getValueAt(int row, int column) {
580        if (row < 0 || column < 0)
590            return null;
600        User[] user = InternetCafeManager.getInstance().getUser();
610        Object result = null;
620        switch (column) {
630        case USER_ID_COLUMN:// Id
640            result = user[row].getId();
650            break;
660        case USER_NAME_COLUMN:// Name
670            result = user[row].getName();
680            break;
690        case USER_SURNAME_COLUMN:// Surname
700            result = user[row].getSurname();
710            break;
720        case USER_NICKNAME_COLUMN:// Nickname
730            result = user[row].getNickname();
740            break;
750        }
760        return result;
770    }
78  
79     @SuppressWarnings("unchecked") //$NON-NLS-1$
800    public Class getColumnClass(int column) {
810        if (column < 0)
820            return null;
830        Class result = null;
840        switch (column) {
850        case USER_ID_COLUMN:// Id
860            result = Integer.class;
870            break;
880        case USER_NAME_COLUMN:// Name
890            result = String.class;
900            break;
910        case USER_SURNAME_COLUMN:// Surname
920            result = String.class;
930            break;
940        case USER_NICKNAME_COLUMN:// Nickname
950            result = String.class;
960            break;
970        }
980        return result;
990    }
100  
101     /*
102      * Don't need to implement this method unless your table's editable.
103      */
1040    public boolean isCellEditable(int row, int column) {
1050        if (row < 0 || column < 0)
1060            return false;
1070        // Note that the data/cell address is constant,
1080        // no matter where the cell appears onscreen.
1090        boolean result = false;
1100        switch (column) {
1110        case USER_ID_COLUMN:// Id
1120            result = false;
1130            break;
1140        case USER_NAME_COLUMN:// Name
1150            result = false;
1160            break;
1170        case USER_SURNAME_COLUMN:// Surname
1180            result = false;
1190            break;
1200        case USER_NICKNAME_COLUMN:// Nickname
1210            result = false;
1220            break;
1230        }
1240        return result;
1250    }
126 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.