comparison org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet026AnonymousBeanProperties.d @ 100:e884642ad36e

more work on examples
author Frank Benoit <benoit@tionex.de>
date Thu, 23 Apr 2009 00:02:38 +0200
parents 5d5bd660917f
children
comparison
equal deleted inserted replaced
99:5d5bd660917f 100:e884642ad36e
111 propertyChangeSupport.firePropertyChange(propertyName, oldValue, 111 propertyChangeSupport.firePropertyChange(propertyName, oldValue,
112 newValue); 112 newValue);
113 } 113 }
114 } 114 }
115 115
116 public static class ContactGroup extends AbstractModelObject implements 116 public static class ContactGroup : AbstractModelObject ,
117 Comparable { 117 Comparable {
118 private String name; 118 private String name;
119 private Set contacts = new TreeSet(); 119 private Set contacts = new TreeSet();
120 120
121 ContactGroup(String name) { 121 ContactGroup(String name) {
122 this.name = checkNull(name); 122 this.name = checkNull(name);
123 } 123 }
124 124
125 private String checkNull(String string) { 125 private String checkNull(String string) {
126 if (string == null) 126 if (string is null)
127 throw new NullPointerException(); 127 throw new NullPointerException();
128 return string; 128 return string;
129 } 129 }
130 130
131 public String getName() { 131 public String getName() {
158 ContactGroup that = (ContactGroup) o; 158 ContactGroup that = (ContactGroup) o;
159 return this.name.compareTo(that.name); 159 return this.name.compareTo(that.name);
160 } 160 }
161 } 161 }
162 162
163 public static class Contact extends AbstractModelObject implements 163 public static class Contact : AbstractModelObject ,
164 Comparable { 164 Comparable {
165 private String name; 165 private String name;
166 private String status; 166 private String status;
167 167
168 private String checkNull(String string) { 168 private String checkNull(String string) {
169 if (string == null) 169 if (string is null)
170 throw new NullPointerException(); 170 throw new NullPointerException();
171 return string; 171 return string;
172 } 172 }
173 173
174 public Contact(String name, String status) { 174 public Contact(String name, String status) {
194 } 194 }
195 195
196 public int compareTo(Object o) { 196 public int compareTo(Object o) {
197 Contact that = (Contact) o; 197 Contact that = (Contact) o;
198 int result = this.name.compareTo(that.name); 198 int result = this.name.compareTo(that.name);
199 if (result == 0) 199 if (result is 0)
200 result = this.status.compareTo(that.status); 200 result = this.status.compareTo(that.status);
201 return result; 201 return result;
202 } 202 }
203 } 203 }
204 204
205 public static class ApplicationModel extends AbstractModelObject { 205 public static class ApplicationModel : AbstractModelObject {
206 private Set groups = new TreeSet(); 206 private Set groups = new TreeSet();
207 207
208 public Set getGroups() { 208 public Set getGroups() {
209 return new TreeSet(groups); 209 return new TreeSet(groups);
210 } 210 }
221 * Set property for the "contacts" property of a ContactGroup. Since 221 * Set property for the "contacts" property of a ContactGroup. Since
222 * ContactGroup does not have a setContacts() method we have to write our 222 * ContactGroup does not have a setContacts() method we have to write our
223 * own property to apply set changes incrementally through the addContact 223 * own property to apply set changes incrementally through the addContact
224 * and removeContact methods. 224 * and removeContact methods.
225 */ 225 */
226 public static class ContactGroupContactsProperty extends SimpleSetProperty { 226 public static class ContactGroupContactsProperty : SimpleSetProperty {
227 public Object getElementType() { 227 public Object getElementType() {
228 return Contact.class; 228 return Contact.class;
229 } 229 }
230 230
231 protected Set doGetSet(Object source) { 231 protected Set doGetSet(Object source) {
232 if (source == null) 232 if (source is null)
233 return Collections.EMPTY_SET; 233 return Collections.EMPTY_SET;
234 return ((ContactGroup) source).getContacts(); 234 return ((ContactGroup) source).getContacts();
235 } 235 }
236 236
237 protected void doSetSet(Object source, Set set, SetDiff diff) { 237 protected void doSetSet(Object source, Set set, SetDiff diff) {
249 public INativePropertyListener adaptListener( 249 public INativePropertyListener adaptListener(
250 final ISimplePropertyListener listener) { 250 final ISimplePropertyListener listener) {
251 return new Listener(this, listener); 251 return new Listener(this, listener);
252 } 252 }
253 253
254 private class Listener extends NativePropertyListener implements 254 private class Listener : NativePropertyListener ,
255 PropertyChangeListener { 255 PropertyChangeListener {
256 Listener(IProperty property, ISimplePropertyListener listener) { 256 Listener(IProperty property, ISimplePropertyListener listener) {
257 super(property, listener); 257 super(property, listener);
258 } 258 }
259 259