package vicazh.hyperpool.stream.net.http;
import java.util.*;
import javax.swing.table.*;
/**
* The reconnect table model
*
* @author Victor Zhigunov
* @version 0.4.0
*/
public class IReconnectModel extends AbstractTableModel {
private Object status;
private Object file;
private Object length;
private Object index;
private Object progress;
private Object retry;
private Object client;
private Object location;
/**
* @param status
* column name for status
* @param file
* column name for file
* @param length
* column name for length
* @param index
* column name for index
* @param progress
* column name for progress
* @param retry
* column name for retry
* @param client
* column name for client name
* @param location
* column name for location
*/
public IReconnectModel(Object status, Object file, Object length,
Object index, Object progress, Object retry, Object client,
Object location) {
this.status = status;
this.file = file;
this.length = length;
this.index = index;
this.progress = progress;
this.retry = retry;
this.client = client;
this.location = location;
}
List<ReconnectItem> data;
public void setData(List<ReconnectItem> data) {
this.data = data;
fireTableDataChanged();
}
public Class<?> getColumnClass(int c) {
switch (c) {
case 0:
return Boolean.class;
case 2:
return Long.class;
case 3:
return Long.class;
case 5:
return Integer.class;
}
return String.class;
}
public boolean isCellEditable(int row, int col) {
return false;
}
public int getRowCount() {
if (data == null)
return 0;
return data.size();
}
public String getColumnName(int columnIndex) {
switch (columnIndex) {
case 0:
return status.toString();
case 1:
return file.toString();
case 2:
return length.toString();
case 3:
return index.toString();
case 4:
return progress.toString();
case 5:
return retry.toString();
case 6:
return client.toString();
case 7:
return location.toString();
}
return null;
}
public Object getValueAt(int row, int column) {
ReconnectItem c = data.get(row);
switch (column) {
case 0:
return new Boolean(c.accept);
case 1:
return c;
case 2:
return new Long(c.length);
case 3:
return new Long(c.index);
case 4:
return c.length == 0 ? null : new Integer(
(int) (c.index * 100 / c.length));
case 5:
return new Integer(c.retryindex);
case 6:
return c.client;
case 7:
return c.location;
}
return null;
}
public int getColumnCount() {
return 8;
}
}
|