1 package net.sourceforge.argval.manifestinfo.swing;
2
3
4 import java.util.ArrayList;
5
6 import javax.swing.event.TableModelListener;
7 import javax.swing.table.TableModel;
8
9 import net.sourceforge.argval.manifestinfo.ManifestInfo;
10 import net.sourceforge.argval.manifestinfo.ManifestInfoManager;
11 import net.sourceforge.argval.packageinfo.PackageInfo;
12
13
14
15
16
17
18
19
20 public class ManifestInfoTableModel implements TableModel {
21
22 public final String columnNames[] =
23 new String[] {
24 "Specification Title", "Specification Version", "Specification Vendor",
25 "Implementation Title", "Implementation Version", "Implementation Vendor",
26 "Filename"
27 };
28
29 private final ArrayList<TableModelListener> tableModelListenerList = new ArrayList<TableModelListener>();
30
31 private ManifestInfoManager manager;
32
33
34 public ManifestInfoTableModel(ManifestInfoManager manifestInfoManager) {
35 super();
36 this.manager = manifestInfoManager;
37 }
38
39
40 public Class<?> getColumnClass(int columnIndex) {
41 return null;
42 }
43
44
45 public int getColumnCount() {
46 return columnNames.length;
47 }
48
49
50 public String getColumnName(int columnIndex) {
51 return (columnIndex < columnNames.length) ? columnNames[columnIndex] : null;
52 }
53
54
55 public int getRowCount() {
56 return manager.getTitleSet().size();
57 }
58
59
60 public Object getValueAt(int rowIndex, int columnIndex) {
61 String title = (String)manager.getTitleSet().toArray()[rowIndex];
62 ManifestInfo manifestInfo = manager.getManifestInfo(title);
63 PackageInfo packageInfo = manifestInfo.getPackageInfo();
64 final Object result;
65 switch (columnIndex) {
66 case 0:
67 result = packageInfo.getSpecificationTitle();
68 break;
69 case 1:
70 result = packageInfo.getSpecificationVersion();
71 break;
72 case 2:
73 result = packageInfo.getSpecificationVendor();
74 break;
75 case 3:
76 result = packageInfo.getImplementationTitle();
77 break;
78 case 4:
79 result = packageInfo.getImplementationVersion();
80 break;
81 case 5:
82 result = packageInfo.getImplementationVendor();
83 break;
84 case 6:
85 result = manifestInfo.getJarPath();
86 break;
87 default:
88 result = null;
89 }
90 return result;
91 }
92
93
94 public boolean isCellEditable(int rowIndex, int columnIndex) {
95 return false;
96 }
97
98
99 public void setValueAt(Object value, int rowIndex, int columnIndex) {
100
101 }
102
103
104 public void addTableModelListener(TableModelListener tml) {
105 if (! tableModelListenerList.contains(tml)) {
106 tableModelListenerList.add(tml);
107 }
108 }
109
110 public void removeTableModelListener(TableModelListener tml) {
111 tableModelListenerList.remove(tml);
112 }
113
114 }