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.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; | |
33 | 0 | */ |
34 | 0 | 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$ |
35 | 0 | |
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 | ||
46 | 0 | public ReducedClientWorkstationTableModel() { |
47 | 0 | super(); |
48 | 0 | } |
49 | 0 | |
50 | 0 | public int getColumnCount() { |
51 | 0 | return columnNames.length; |
52 | 0 | } |
53 | ||
54 | 0 | public int getRowCount() { |
55 | 0 | return NetworkManager.getInstance().getNetwork().getClient().length; |
56 | 0 | } |
57 | ||
58 | 0 | public String getColumnName(int column) { |
59 | 0 | return columnNames[column]; |
60 | 0 | } |
61 | ||
62 | 0 | public Object getValueAt(int row, int column) { |
63 | 0 | if (row < 0 || column < 0) |
64 | 0 | return null; |
65 | 0 | Workstation[] client = NetworkManager.getInstance().getNetwork() |
66 | 0 | .getClient(); |
67 | 0 | Object result = null; |
68 | 0 | switch (column) { |
69 | 0 | case WORKSTATION_ID_COLUMN: |
70 | 0 | result = client[row].getId(); |
71 | 0 | break; |
72 | 0 | case WORKSTATION_NAME_COLUMN: |
73 | 0 | result = client[row].getName(); |
74 | 0 | break; |
75 | 0 | case WORKSTATION_LOCATION_COLUMN: |
76 | 0 | result = client[row].getLocation(); |
77 | 0 | break; |
78 | 0 | case WORKSTATION_TYPE_COLUMN: |
79 | 0 | result = client[row].getType(); |
80 | 0 | break; |
81 | 0 | case WORKSTATION_IN_USE_COLUMN: |
82 | 0 | result = client[row].isInUse(); |
83 | 0 | break; |
84 | 0 | } |
85 | 0 | return result; |
86 | 0 | } |
87 | ||
88 | @SuppressWarnings("unchecked") //$NON-NLS-1$ | |
89 | 0 | public Class getColumnClass(int column) { |
90 | 0 | Class result = null; |
91 | 0 | switch (column) { |
92 | 0 | case WORKSTATION_ID_COLUMN: |
93 | 0 | result = Integer.class; |
94 | 0 | break; |
95 | 0 | case WORKSTATION_NAME_COLUMN: |
96 | 0 | result = String.class; |
97 | 0 | break; |
98 | 0 | case WORKSTATION_LOCATION_COLUMN: |
99 | 0 | result = String.class; |
100 | 0 | break; |
101 | 0 | case WORKSTATION_TYPE_COLUMN: |
102 | 0 | result = String.class; |
103 | 0 | break; |
104 | 0 | case WORKSTATION_IN_USE_COLUMN: |
105 | 0 | result = Boolean.class; |
106 | 0 | break; |
107 | 0 | } |
108 | 0 | return result; |
109 | 0 | } |
110 | ||
111 | /* | |
112 | * Don't need to implement this method unless your table's editable. | |
113 | */ | |
114 | 0 | public boolean isCellEditable(int row, int column) { |
115 | 0 | if (row < 0 || column < 0) |
116 | 0 | return false; |
117 | 0 | // Note that the data/cell address is constant, |
118 | 0 | // no matter where the cell appears onscreen. |
119 | 0 | boolean result = false; |
120 | 0 | switch (column) { |
121 | 0 | case WORKSTATION_ID_COLUMN: |
122 | 0 | result = false; |
123 | 0 | break; |
124 | 0 | case WORKSTATION_NAME_COLUMN: |
125 | 0 | result = false; |
126 | 0 | break; |
127 | 0 | case WORKSTATION_LOCATION_COLUMN: |
128 | 0 | result = false; |
129 | 0 | break; |
130 | 0 | case WORKSTATION_TYPE_COLUMN: |
131 | 0 | result = false; |
132 | 0 | break; |
133 | 0 | case WORKSTATION_IN_USE_COLUMN: |
134 | 0 | result = false; |
135 | 0 | break; |
136 | 0 | } |
137 | 0 | return result; |
138 | 0 | } |
139 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |