Git

1 import java.util.Hashtable;\r
2 import java.util.Vector;\r
3 import javax.swing.table.*;\r
4 \r
5 public class DownloadTableModel extends RefreshAbstractTableModel\r
6 {\r
7 \r
8         Hashtable fileInfos;\r
9         String columns[]={"Number","File Name","Size","Downloaded","%","Rate","ETA","Running"};\r
10         DonkeyCore donkeyCore;\r
11         \r
12         public DownloadTableModel(Hashtable fileInfos,DonkeyCore donkeyCore)\r
13         {\r
14                 this.donkeyCore=donkeyCore;\r
15                 this.fileInfos=fileInfos;\r
16         }\r
17         \r
18         public int getColumnCount()\r
19         {\r
20                 return columns.length;\r
21         }\r
22         \r
23         public String getColumnName(int col)\r
24         {\r
25                 return columns[col];\r
26         }\r
27 \r
28         public int getRowCount()\r
29         {\r
30                 return fileInfos.size();\r
31         }\r
32         \r
33         public Object getValueAt(int row,int col)\r
34         {\r
35                 if (col==0) return fileInfos.keySet().toArray()[row];\r
36                 return ((Vector)fileInfos.values().toArray()[row]).get(col-1);\r
37         }\r
38 \r
39         public boolean isCellEditable(int row,int col)\r
40         {\r
41                 return col==columns.length-1;\r
42         }\r
43         \r
44         public void setValueAt(Object o,int row,int col)\r
45         {\r
46                 Long id=(Long)getValueAt(row,0);\r
47                 Vector fileInfo=(Vector)fileInfos.get(id);\r
48                 donkeyCore.switchDownload((Long)getValueAt(row,0),((Boolean)o).booleanValue());\r
49         }\r
50 \r
51 }