1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package p3j.gui.misc;
17
18 import javax.swing.AbstractListModel;
19
20 import p3j.pppm.ProjectionModel;
21 import p3j.pppm.sets.SetType;
22
23
24
25
26
27
28
29
30
31
32 public class SetTypesListModel extends AbstractListModel<SetType> {
33
34
35 private static final long serialVersionUID = 8369935030761632549L;
36
37
38 private ProjectionModel projection;
39
40
41
42
43
44
45
46 public SetTypesListModel(ProjectionModel currentProjection) {
47 this.projection = currentProjection;
48 }
49
50 @Override
51 public SetType getElementAt(int index) {
52 return this.projection.getSetType(index);
53 }
54
55 @Override
56 public int getSize() {
57 return this.projection.getNumOfSetTypes();
58 }
59
60
61
62
63
64
65
66 public void removeSetType(int index) {
67 this.projection.removeSetType(index);
68 this.fireContentsChanged(this, index, getSize() + 1);
69 }
70
71
72
73
74
75
76
77
78
79 public void addSetType(String name, String desc) {
80 int index = this.projection.getNumOfSetTypes();
81 this.projection.createSetType(name, desc);
82 this.fireContentsChanged(this, index, index + 1);
83 }
84
85
86
87
88
89
90
91 public void setTypeChanged(int stIndex) {
92 this.fireContentsChanged(this, stIndex, stIndex);
93 }
94
95 public ProjectionModel getProjection() {
96 return projection;
97 }
98
99 public void setProjection(ProjectionModel scenario) {
100 this.projection = scenario;
101 }
102
103 }