01: package vicazh.hyperpool.stream.net.http.html;
02:
03: import java.util.*;
04: import javax.swing.table.*;
05:
06: /**
07: * The http task table model
08: *
09: * @author Victor Zhigunov
10: * @version 0.4.0
11: */
12: public class ITaskModel extends AbstractTableModel {
13: private Object dir;
14:
15: private Object address;
16:
17: private Object received;
18:
19: private Object found;
20:
21: /**
22: * @param dir
23: * column name for dir
24: * @param address
25: * column name for address
26: * @param received
27: * column name for received
28: * @param found
29: * column name for found
30: */
31: public ITaskModel(Object dir, Object address, Object received,
32: Object found) {
33: this .dir = dir;
34: this .address = address;
35: this .received = received;
36: this .found = found;
37: }
38:
39: List<Task> data;
40:
41: public void setData(List<Task> data) {
42: this .data = data;
43: fireTableDataChanged();
44: }
45:
46: public Class<?> getColumnClass(int c) {
47: switch (c) {
48: case 2:
49: return Integer.class;
50: case 3:
51: return Integer.class;
52: }
53: return String.class;
54: }
55:
56: public boolean isCellEditable(int row, int col) {
57: return false;
58: }
59:
60: public Object getValueAt(int i, int j) {
61: Task task = data.get(i);
62: switch (j) {
63: case 0:
64: return task;
65: case 1:
66: return task.getAddress();
67: case 2:
68: return new Integer(task.index);
69: case 3:
70: return new Integer(task.size);
71: }
72: return null;
73: }
74:
75: public int getColumnCount() {
76: return 4;
77: }
78:
79: public int getRowCount() {
80: return data == null ? 0 : data.size();
81: }
82:
83: public String getColumnName(int i) {
84: switch (i) {
85: case 0:
86: return dir.toString();
87: case 1:
88: return address.toString();
89: case 2:
90: return received.toString();
91: case 3:
92: return found.toString();
93: }
94: return null;
95: }
96: }
|