1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.ximtec.igesture.core;
28
29 import java.util.ArrayList;
30 import java.util.List;
31
32
33
34
35
36
37
38 public class TestClass extends DefaultDataObject {
39
40 public static final String PROPERTY_GESTURES = "gestures";
41 public static final String PROPERTY_NAME = "name";
42 private ArrayList<Gesture<?>> gestures;
43 private String name;
44
45
46 public TestClass(String name) {
47 this.name = name;
48 this.gestures = new ArrayList<Gesture<?>>();
49 }
50
51
52
53
54
55
56 public String getName() {
57 return this.name;
58 }
59
60 public void setName(String name){
61 String oldName = this.name;
62 this.name = name;
63
64 for(Gesture<?> gesture:gestures){
65 gesture.setName(name);
66 }
67
68 propertyChangeSupport.firePropertyChange(PROPERTY_NAME, oldName, this.name);
69 }
70
71
72
73
74
75
76 @SuppressWarnings("unchecked")
77 public List<Gesture<?>> getGestures() {
78 return (List<Gesture<?>>)gestures.clone();
79 }
80
81
82
83
84
85
86 public void add(Gesture<?> gesture) {
87 gesture.setName(this.getName());
88 gestures.add(gesture);
89 propertyChangeSupport.fireIndexedPropertyChange(PROPERTY_GESTURES, 0,
90 null, gesture);
91 }
92
93
94
95
96
97
98 public void remove(Gesture<?> gesture) {
99 gestures.remove(gesture);
100 propertyChangeSupport.fireIndexedPropertyChange(PROPERTY_GESTURES, 0,
101 gesture, null);
102 }
103
104
105
106
107
108
109 public int size() {
110 return gestures.size();
111 }
112
113
114 @Override
115 public int hashCode() {
116 return name != null ? name.hashCode():0;
117 }
118
119 @Override
120 public boolean equals(Object object) {
121 if(object == this){
122 return true;
123 }
124
125 if(!(object instanceof TestClass)){
126 return false;
127 }
128 TestClass o = (TestClass)object;
129 if(this.getName() != null && this.getName().equals(o.getName())){
130 return true;
131 }
132
133 return false;
134 }
135
136 @Override
137 public void accept(Visitor visitor) {
138 visitor.visit(this);
139
140 for (Gesture<?> gesture : gestures) {
141 gesture.accept(visitor);
142 }
143
144 }
145 }