001: package vicazh.hyperpool.stream.net.http;
002:
003: import java.util.*;
004: import javax.swing.table.*;
005:
006: /**
007: * The reconnect table model
008: *
009: * @author Victor Zhigunov
010: * @version 0.4.0
011: */
012: public class IReconnectModel extends AbstractTableModel {
013:
014: private Object status;
015:
016: private Object file;
017:
018: private Object length;
019:
020: private Object index;
021:
022: private Object progress;
023:
024: private Object retry;
025:
026: private Object client;
027:
028: private Object location;
029:
030: /**
031: * @param status
032: * column name for status
033: * @param file
034: * column name for file
035: * @param length
036: * column name for length
037: * @param index
038: * column name for index
039: * @param progress
040: * column name for progress
041: * @param retry
042: * column name for retry
043: * @param client
044: * column name for client name
045: * @param location
046: * column name for location
047: */
048: public IReconnectModel(Object status, Object file, Object length,
049: Object index, Object progress, Object retry, Object client,
050: Object location) {
051: this .status = status;
052: this .file = file;
053: this .length = length;
054: this .index = index;
055: this .progress = progress;
056: this .retry = retry;
057: this .client = client;
058: this .location = location;
059: }
060:
061: List<ReconnectItem> data;
062:
063: public void setData(List<ReconnectItem> data) {
064: this .data = data;
065: fireTableDataChanged();
066: }
067:
068: public Class<?> getColumnClass(int c) {
069: switch (c) {
070: case 0:
071: return Boolean.class;
072: case 2:
073: return Long.class;
074: case 3:
075: return Long.class;
076: case 5:
077: return Integer.class;
078: }
079: return String.class;
080: }
081:
082: public boolean isCellEditable(int row, int col) {
083: return false;
084: }
085:
086: public int getRowCount() {
087: if (data == null)
088: return 0;
089: return data.size();
090: }
091:
092: public String getColumnName(int columnIndex) {
093: switch (columnIndex) {
094: case 0:
095: return status.toString();
096: case 1:
097: return file.toString();
098: case 2:
099: return length.toString();
100: case 3:
101: return index.toString();
102: case 4:
103: return progress.toString();
104: case 5:
105: return retry.toString();
106: case 6:
107: return client.toString();
108: case 7:
109: return location.toString();
110: }
111: return null;
112: }
113:
114: public Object getValueAt(int row, int column) {
115: ReconnectItem c = data.get(row);
116: switch (column) {
117: case 0:
118: return new Boolean(c.accept);
119: case 1:
120: return c;
121: case 2:
122: return new Long(c.length);
123: case 3:
124: return new Long(c.index);
125: case 4:
126: return c.length == 0 ? null : new Integer(
127: (int) (c.index * 100 / c.length));
128: case 5:
129: return new Integer(c.retryindex);
130: case 6:
131: return c.client;
132: case 7:
133: return c.location;
134: }
135: return null;
136: }
137:
138: public int getColumnCount() {
139: return 8;
140: }
141: }
|