Coverage details for ui.table.model.ReducedClientWorkstationTableModel

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.network.NetworkManager;
26 import base.network.Workstation;
27  
28 @SuppressWarnings("serial") //$NON-NLS-1$
29 public class ReducedClientWorkstationTableModel extends AbstractTableModel {
30     /*
31      * private String name; private String description; private WorkstationType
32      * type; private InetAddress address; private boolean inUse = false;
330     */
340    private String[] columnNames = { Messages.getString("common.id"), Messages.getString("common.name"), Messages.getString("common.location"), Messages.getString("common.type"), Messages.getString("common.inuse") }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
350 
36     public static final int WORKSTATION_ID_COLUMN = 0;
37  
38     public static final int WORKSTATION_NAME_COLUMN = 1;
39  
40     public static final int WORKSTATION_LOCATION_COLUMN = 2;
41  
42     public static final int WORKSTATION_TYPE_COLUMN = 3;
43  
44     public static final int WORKSTATION_IN_USE_COLUMN = 4;
45  
460    public ReducedClientWorkstationTableModel() {
470        super();
480    }
490 
500    public int getColumnCount() {
510        return columnNames.length;
520    }
53  
540    public int getRowCount() {
550        return NetworkManager.getInstance().getNetwork().getClient().length;
560    }
57  
580    public String getColumnName(int column) {
590        return columnNames[column];
600    }
61  
620    public Object getValueAt(int row, int column) {
630        if (row < 0 || column < 0)
640            return null;
650        Workstation[] client = NetworkManager.getInstance().getNetwork()
660                .getClient();
670        Object result = null;
680        switch (column) {
690        case WORKSTATION_ID_COLUMN:
700            result = client[row].getId();
710            break;
720        case WORKSTATION_NAME_COLUMN:
730            result = client[row].getName();
740            break;
750        case WORKSTATION_LOCATION_COLUMN:
760            result = client[row].getLocation();
770            break;
780        case WORKSTATION_TYPE_COLUMN:
790            result = client[row].getType();
800            break;
810        case WORKSTATION_IN_USE_COLUMN:
820            result = client[row].isInUse();
830            break;
840        }
850        return result;
860    }
87  
88     @SuppressWarnings("unchecked") //$NON-NLS-1$
890    public Class getColumnClass(int column) {
900        Class result = null;
910        switch (column) {
920        case WORKSTATION_ID_COLUMN:
930            result = Integer.class;
940            break;
950        case WORKSTATION_NAME_COLUMN:
960            result = String.class;
970            break;
980        case WORKSTATION_LOCATION_COLUMN:
990            result = String.class;
1000            break;
1010        case WORKSTATION_TYPE_COLUMN:
1020            result = String.class;
1030            break;
1040        case WORKSTATION_IN_USE_COLUMN:
1050            result = Boolean.class;
1060            break;
1070        }
1080        return result;
1090    }
110  
111     /*
112      * Don't need to implement this method unless your table's editable.
113      */
1140    public boolean isCellEditable(int row, int column) {
1150        if (row < 0 || column < 0)
1160            return false;
1170        // Note that the data/cell address is constant,
1180        // no matter where the cell appears onscreen.
1190        boolean result = false;
1200        switch (column) {
1210        case WORKSTATION_ID_COLUMN:
1220            result = false;
1230            break;
1240        case WORKSTATION_NAME_COLUMN:
1250            result = false;
1260            break;
1270        case WORKSTATION_LOCATION_COLUMN:
1280            result = false;
1290            break;
1300        case WORKSTATION_TYPE_COLUMN:
1310            result = false;
1320            break;
1330        case WORKSTATION_IN_USE_COLUMN:
1340            result = false;
1350            break;
1360        }
1370        return result;
1380    }
139 }

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.