comparison org.eclipse.core.databinding.beans/src/org/eclipse/core/databinding/beans/PojoObservables.d @ 98:48d4ee626868

rm databinding.observable seems to be duplicate, databinding.beans now building
author Frank Benoit <benoit@tionex.de>
date Wed, 22 Apr 2009 07:30:21 +0200
parents c86eb8b3098e
children
comparison
equal deleted inserted replaced
97:c86eb8b3098e 98:48d4ee626868
76 */ 76 */
77 public static IObservableValue observeValue(Realm realm, Object pojo, 77 public static IObservableValue observeValue(Realm realm, Object pojo,
78 String propertyName) { 78 String propertyName) {
79 79
80 PropertyDescriptor descriptor = BeansObservables.getPropertyDescriptor( 80 PropertyDescriptor descriptor = BeansObservables.getPropertyDescriptor(
81 pojo.getClass(), propertyName); 81 Class.fromObject(pojo), propertyName);
82 return new JavaBeanObservableValue(realm, pojo, descriptor, false); 82 return new JavaBeanObservableValue(realm, pojo, descriptor, false);
83 } 83 }
84 84
85 /** 85 /**
86 * Returns an observable map in the default realm tracking the current 86 * Returns an observable map in the default realm tracking the current
138 * given pojo object 138 * given pojo object
139 */ 139 */
140 public static IObservableMap observeMap(Realm realm, Object pojo, 140 public static IObservableMap observeMap(Realm realm, Object pojo,
141 String propertyName) { 141 String propertyName) {
142 PropertyDescriptor descriptor = BeansObservables.getPropertyDescriptor( 142 PropertyDescriptor descriptor = BeansObservables.getPropertyDescriptor(
143 pojo.getClass(), propertyName); 143 Class.fromObject(pojo), propertyName);
144 return new JavaBeanPropertyObservableMap(realm, pojo, descriptor, false); 144 return new JavaBeanPropertyObservableMap(realm, pojo, descriptor, false);
145 } 145 }
146 146
147 /** 147 /**
148 * Returns an observable list in the given realm tracking the 148 * Returns an observable list in the given realm tracking the
188 * of the given bean object 188 * of the given bean object
189 */ 189 */
190 public static IObservableList observeList(Realm realm, Object pojo, 190 public static IObservableList observeList(Realm realm, Object pojo,
191 String propertyName, Class elementType) { 191 String propertyName, Class elementType) {
192 PropertyDescriptor propertyDescriptor = BeansObservables 192 PropertyDescriptor propertyDescriptor = BeansObservables
193 .getPropertyDescriptor(pojo.getClass(), propertyName); 193 .getPropertyDescriptor(Class.fromObject(pojo), propertyName);
194 elementType = BeansObservables.getCollectionElementType(elementType, 194 elementType = BeansObservables.getCollectionElementType(elementType,
195 propertyDescriptor); 195 propertyDescriptor);
196 196
197 return new JavaBeanObservableList(realm, pojo, propertyDescriptor, 197 return new JavaBeanObservableList(realm, pojo, propertyDescriptor,
198 elementType, false); 198 elementType, false);
226 * property for given pojo object 226 * property for given pojo object
227 */ 227 */
228 public static IObservableSet observeSet(Realm realm, Object pojo, 228 public static IObservableSet observeSet(Realm realm, Object pojo,
229 String propertyName, Class elementType) { 229 String propertyName, Class elementType) {
230 PropertyDescriptor propertyDescriptor = BeansObservables 230 PropertyDescriptor propertyDescriptor = BeansObservables
231 .getPropertyDescriptor(pojo.getClass(), propertyName); 231 .getPropertyDescriptor(Class.fromObject(pojo), propertyName);
232 elementType = BeansObservables.getCollectionElementType(elementType, 232 elementType = BeansObservables.getCollectionElementType(elementType,
233 propertyDescriptor); 233 propertyDescriptor);
234 234
235 return new JavaBeanObservableSet(realm, pojo, propertyDescriptor, 235 return new JavaBeanObservableSet(realm, pojo, propertyDescriptor,
236 elementType, false); 236 elementType, false);
244 * the realm to use 244 * the realm to use
245 * @param propertyName 245 * @param propertyName
246 * the name of the property 246 * the name of the property
247 * @return an observable value factory 247 * @return an observable value factory
248 */ 248 */
249 public static IObservableFactory valueFactory(final Realm realm, 249 public static IObservableFactory valueFactory(Realm realm,
250 final String propertyName) { 250 String propertyName) {
251 return new class() IObservableFactory { 251 return new class(realm, propertyName) IObservableFactory {
252 Realm realm_;
253 String propertyName_;
254 this(Realm r, String p){
255 realm_=r;
256 propertyName_=p;
257 }
252 public IObservable createObservable(Object target) { 258 public IObservable createObservable(Object target) {
253 return observeValue(realm, target, propertyName); 259 return observeValue(realm_, target, propertyName_);
254 } 260 }
255 }; 261 };
256 } 262 }
257 263
258 /** 264 /**
264 * @param propertyName 270 * @param propertyName
265 * the name of the property 271 * the name of the property
266 * @param elementType 272 * @param elementType
267 * @return an observable list factory 273 * @return an observable list factory
268 */ 274 */
269 public static IObservableFactory listFactory(final Realm realm, 275 public static IObservableFactory listFactory(Realm realm,
270 final String propertyName, final Class elementType) { 276 String propertyName, Class elementType) {
271 return new class() IObservableFactory { 277 return new class(realm, propertyName, elementType) IObservableFactory {
278 Realm realm_;
279 String propertyName_;
280 Class elementType_;
281 this(Realm r, String p, Class e){
282 realm_=r;
283 propertyName_=p;
284 elementType_=e;
285 }
272 public IObservable createObservable(Object target) { 286 public IObservable createObservable(Object target) {
273 return observeList(realm, target, propertyName, elementType); 287 return observeList(realm_, target, propertyName_, elementType_);
274 } 288 }
275 }; 289 };
276 } 290 }
277 291
278 /** 292 /**
283 * the realm to use 297 * the realm to use
284 * @param propertyName 298 * @param propertyName
285 * the name of the property 299 * the name of the property
286 * @return an observable set factory 300 * @return an observable set factory
287 */ 301 */
288 public static IObservableFactory setFactory(final Realm realm, 302 public static IObservableFactory setFactory(Realm realm,
289 final String propertyName) { 303 String propertyName) {
290 return new class() IObservableFactory { 304 return new class(realm, propertyName) IObservableFactory {
305 Realm realm_;
306 String propertyName_;
307 this(Realm r, String p){
308 realm_=r;
309 propertyName_=p;
310 }
291 public IObservable createObservable(Object target) { 311 public IObservable createObservable(Object target) {
292 return observeSet(realm, target, propertyName); 312 return observeSet(realm_, target, propertyName_);
293 } 313 }
294 }; 314 };
295 } 315 }
296 316
297 /** 317 /**
299 * @param propertyName 319 * @param propertyName
300 * @param elementType 320 * @param elementType
301 * can be <code>null</code> 321 * can be <code>null</code>
302 * @return an observable set factory for creating observable sets 322 * @return an observable set factory for creating observable sets
303 */ 323 */
304 public static IObservableFactory setFactory(final Realm realm, 324 public static IObservableFactory setFactory(Realm realm,
305 final String propertyName, final Class elementType) { 325 String propertyName, Class elementType) {
306 return new class() IObservableFactory { 326 return new class(realm, propertyName, elementType) IObservableFactory {
327 Realm realm_;
328 String propertyName_;
329 Class elementType_;
330 this(Realm r, String p, Class e){
331 realm_=r;
332 propertyName_=p;
333 elementType_=e;
334 }
307 public IObservable createObservable(Object target) { 335 public IObservable createObservable(Object target) {
308 return observeSet(realm, target, propertyName, elementType); 336 return observeSet(realm_, target, propertyName_, elementType_);
309 } 337 }
310 }; 338 };
311 } 339 }
312 340
313 /** 341 /**
321 * factory. 349 * factory.
322 * @param propertyName 350 * @param propertyName
323 * the name of the property 351 * the name of the property
324 * @return a factory for creating {@link IObservableMap} objects. 352 * @return a factory for creating {@link IObservableMap} objects.
325 */ 353 */
326 public static IObservableFactory mapPropertyFactory(final Realm realm, 354 public static IObservableFactory mapPropertyFactory(Realm realm,
327 final String propertyName) { 355 String propertyName) {
328 return new class() IObservableFactory { 356 return new class(realm, propertyName) IObservableFactory {
357 Realm realm_;
358 String propertyName_;
359 this(Realm r, String p){
360 realm_=r;
361 propertyName_=p;
362 }
329 public IObservable createObservable(Object target) { 363 public IObservable createObservable(Object target) {
330 return observeMap(realm, target, propertyName); 364 return observeMap(realm_, target, propertyName_);
331 } 365 }
332 }; 366 };
333 } 367 }
334 368
335 /** 369 /**
378 IObservableValue master, String propertyName, Class propertyType) { 412 IObservableValue master, String propertyName, Class propertyType) {
379 IObservableList observableList = MasterDetailObservables.detailList( 413 IObservableList observableList = MasterDetailObservables.detailList(
380 master, listFactory(realm, propertyName, propertyType), 414 master, listFactory(realm, propertyName, propertyType),
381 propertyType); 415 propertyType);
382 BeanObservableListDecorator decorator = new BeanObservableListDecorator( 416 BeanObservableListDecorator decorator = new BeanObservableListDecorator(
383 observableList, master, BeansObservables 417 observableList, cast(Object)master, BeansObservables
384 .getValueTypePropertyDescriptor(master, propertyName)); 418 .getValueTypePropertyDescriptor(master, propertyName));
385 419
386 return decorator; 420 return decorator;
387 } 421 }
388 422
406 440
407 IObservableSet observableSet = MasterDetailObservables.detailSet( 441 IObservableSet observableSet = MasterDetailObservables.detailSet(
408 master, setFactory(realm, propertyName, propertyType), 442 master, setFactory(realm, propertyName, propertyType),
409 propertyType); 443 propertyType);
410 BeanObservableSetDecorator decorator = new BeanObservableSetDecorator( 444 BeanObservableSetDecorator decorator = new BeanObservableSetDecorator(
411 observableSet, master, BeansObservables 445 observableSet, cast(Object)master, BeansObservables
412 .getValueTypePropertyDescriptor(master, propertyName)); 446 .getValueTypePropertyDescriptor(master, propertyName));
413 447
414 return decorator; 448 return decorator;
415 } 449 }
416 450
427 public static IObservableMap observeDetailMap(Realm realm, 461 public static IObservableMap observeDetailMap(Realm realm,
428 IObservableValue master, String propertyName) { 462 IObservableValue master, String propertyName) {
429 IObservableMap observableMap = MasterDetailObservables.detailMap( 463 IObservableMap observableMap = MasterDetailObservables.detailMap(
430 master, mapPropertyFactory(realm, propertyName)); 464 master, mapPropertyFactory(realm, propertyName));
431 BeanObservableMapDecorator decorator = new BeanObservableMapDecorator( 465 BeanObservableMapDecorator decorator = new BeanObservableMapDecorator(
432 observableMap, master, BeansObservables 466 observableMap, cast(Object)master, BeansObservables
433 .getValueTypePropertyDescriptor(master, propertyName)); 467 .getValueTypePropertyDescriptor(master, propertyName));
434 return decorator; 468 return decorator;
435 } 469 }
436 } 470 }