1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.jadira.dependencynavigator.gui;
19
20
21 import org.jadira.dependencynavigator.controller.model.DuplicatesListManager;
22 import org.jadira.dependencynavigator.model.ArtifactInstanceMap;
23
24 import javax.swing.event.TableModelListener;
25 import javax.swing.table.TableModel;
26
27 public class VersionsTableModel implements TableModel, SelectableTableModel {
28
29 private DuplicatesListManager duplicatesListManager;
30
31 public VersionsTableModel(DuplicatesListManager duplicatesListManager) {
32 this.duplicatesListManager = duplicatesListManager;
33 }
34
35 public boolean isSelected(int row) {
36 return duplicatesListManager.getVersionsListManager().get(row).isSelected();
37 }
38
39 public int getColumnCount() {
40 return 4;
41 }
42
43 public int getRowCount() {
44 return duplicatesListManager.getVersionsListManager().size();
45 }
46
47 public boolean isCellEditable(int rowIndex, int columnIndex) {
48 return false;
49 }
50
51 public Class<String> getColumnClass(int columnIndex) {
52 return String.class;
53 }
54
55 public Object getValueAt(int rowIndex, int columnIndex) {
56 ArtifactInstanceMap instanceMap = duplicatesListManager.getVersionsListManager().get(rowIndex);
57 switch (columnIndex) {
58 case 0:
59 return instanceMap.getGroupId();
60 case 1:
61 return instanceMap.getArtifactId();
62 case 2:
63 return instanceMap.getVersion();
64 case 3:
65 return String.valueOf(instanceMap.getInstances().size());
66 default:
67 throw new IllegalArgumentException("Column index out of bounds " + columnIndex);
68 }
69 }
70
71 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
72 throw new UnsupportedOperationException();
73 }
74
75 public String getColumnName(int columnIndex) {
76 switch (columnIndex) {
77 case 0:
78 return "Group";
79 case 1:
80 return "Artifact";
81 case 2:
82 return "Version";
83 case 3:
84 return "Instances";
85 default:
86 throw new IllegalArgumentException("Column index out of bounds " + columnIndex);
87 }
88 }
89
90 public void addTableModelListener(TableModelListener l) {
91 }
92
93 public void removeTableModelListener(TableModelListener l) {
94 }
95
96 }