Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 194734 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jface/examples/databinding/snippets/Snippet026AnonymousBeanProperties.java (-1 / +1 lines)
Lines 257-263 Link Here
257
257
258
			public void propertyChange(java.beans.PropertyChangeEvent evt) {
258
			public void propertyChange(java.beans.PropertyChangeEvent evt) {
259
				listener.handlePropertyChange(new PropertyChangeEvent(evt
259
				listener.handlePropertyChange(new PropertyChangeEvent(evt
260
						.getSource(), ContactGroupContactsProperty.this));
260
						.getSource(), ContactGroupContactsProperty.this, null));
261
			}
261
			}
262
		}
262
		}
263
263
(-)src/org/eclipse/core/internal/databinding/beans/BeanSetProperty.java (-1 / +10 lines)
Lines 20-25 Link Here
20
import java.util.HashSet;
20
import java.util.HashSet;
21
import java.util.Set;
21
import java.util.Set;
22
22
23
import org.eclipse.core.databinding.observable.Diffs;
23
import org.eclipse.core.databinding.observable.set.SetDiff;
24
import org.eclipse.core.databinding.observable.set.SetDiff;
24
import org.eclipse.core.databinding.property.INativePropertyListener;
25
import org.eclipse.core.databinding.property.INativePropertyListener;
25
import org.eclipse.core.databinding.property.IPropertyChangeListener;
26
import org.eclipse.core.databinding.property.IPropertyChangeListener;
Lines 94-102 Link Here
94
		}
95
		}
95
96
96
		public void propertyChange(java.beans.PropertyChangeEvent evt) {
97
		public void propertyChange(java.beans.PropertyChangeEvent evt) {
98
			SetDiff diff;
99
			Object oldValue = evt.getOldValue();
100
			Object newValue = evt.getNewValue();
101
			if (oldValue != null && newValue != null) {
102
				diff = Diffs.computeSetDiff(asSet(oldValue), asSet(newValue));
103
			} else {
104
				diff = null;
105
			}
97
			if (propertyDescriptor.getName().equals(evt.getPropertyName())) {
106
			if (propertyDescriptor.getName().equals(evt.getPropertyName())) {
98
				listener.handlePropertyChange(new PropertyChangeEvent(evt
107
				listener.handlePropertyChange(new PropertyChangeEvent(evt
99
						.getSource(), BeanSetProperty.this));
108
						.getSource(), BeanSetProperty.this, diff));
100
			}
109
			}
101
		}
110
		}
102
	}
111
	}
(-)src/org/eclipse/core/internal/databinding/beans/BeanListProperty.java (-1 / +11 lines)
Lines 19-24 Link Here
19
import java.util.Arrays;
19
import java.util.Arrays;
20
import java.util.List;
20
import java.util.List;
21
21
22
import org.eclipse.core.databinding.observable.Diffs;
22
import org.eclipse.core.databinding.observable.list.ListDiff;
23
import org.eclipse.core.databinding.observable.list.ListDiff;
23
import org.eclipse.core.databinding.property.INativePropertyListener;
24
import org.eclipse.core.databinding.property.INativePropertyListener;
24
import org.eclipse.core.databinding.property.IPropertyChangeListener;
25
import org.eclipse.core.databinding.property.IPropertyChangeListener;
Lines 95-102 Link Here
95
96
96
		public void propertyChange(java.beans.PropertyChangeEvent evt) {
97
		public void propertyChange(java.beans.PropertyChangeEvent evt) {
97
			if (propertyDescriptor.getName().equals(evt.getPropertyName())) {
98
			if (propertyDescriptor.getName().equals(evt.getPropertyName())) {
99
				ListDiff diff;
100
				Object oldValue = evt.getOldValue();
101
				Object newValue = evt.getNewValue();
102
				if (oldValue != null && newValue != null) {
103
					diff = Diffs.computeListDiff(asList(oldValue),
104
							asList(newValue));
105
				} else {
106
					diff = null;
107
				}
98
				listener.handlePropertyChange(new PropertyChangeEvent(evt
108
				listener.handlePropertyChange(new PropertyChangeEvent(evt
99
						.getSource(), BeanListProperty.this));
109
						.getSource(), BeanListProperty.this, diff));
100
			}
110
			}
101
		}
111
		}
102
	}
112
	}
(-)src/org/eclipse/core/internal/databinding/beans/BeanMapProperty.java (-1 / +11 lines)
Lines 17-22 Link Here
17
import java.util.HashMap;
17
import java.util.HashMap;
18
import java.util.Map;
18
import java.util.Map;
19
19
20
import org.eclipse.core.databinding.observable.Diffs;
20
import org.eclipse.core.databinding.observable.map.MapDiff;
21
import org.eclipse.core.databinding.observable.map.MapDiff;
21
import org.eclipse.core.databinding.property.INativePropertyListener;
22
import org.eclipse.core.databinding.property.INativePropertyListener;
22
import org.eclipse.core.databinding.property.IPropertyChangeListener;
23
import org.eclipse.core.databinding.property.IPropertyChangeListener;
Lines 82-89 Link Here
82
83
83
		public void propertyChange(java.beans.PropertyChangeEvent evt) {
84
		public void propertyChange(java.beans.PropertyChangeEvent evt) {
84
			if (propertyDescriptor.getName().equals(evt.getPropertyName())) {
85
			if (propertyDescriptor.getName().equals(evt.getPropertyName())) {
86
				MapDiff diff;
87
				Object oldValue = evt.getOldValue();
88
				Object newValue = evt.getNewValue();
89
				if (oldValue != null && newValue != null) {
90
					diff = Diffs.computeMapDiff(asMap(oldValue),
91
							asMap(newValue));
92
				} else {
93
					diff = null;
94
				}
85
				listener.handlePropertyChange(new PropertyChangeEvent(evt
95
				listener.handlePropertyChange(new PropertyChangeEvent(evt
86
						.getSource(), BeanMapProperty.this));
96
						.getSource(), BeanMapProperty.this, diff));
87
			}
97
			}
88
		}
98
		}
89
	}
99
	}
(-)src/org/eclipse/core/internal/databinding/beans/BeanValueProperty.java (-1 / +11 lines)
Lines 15-20 Link Here
15
import java.beans.PropertyChangeListener;
15
import java.beans.PropertyChangeListener;
16
import java.beans.PropertyDescriptor;
16
import java.beans.PropertyDescriptor;
17
17
18
import org.eclipse.core.databinding.observable.Diffs;
19
import org.eclipse.core.databinding.observable.value.ValueDiff;
18
import org.eclipse.core.databinding.property.INativePropertyListener;
20
import org.eclipse.core.databinding.property.INativePropertyListener;
19
import org.eclipse.core.databinding.property.IPropertyChangeListener;
21
import org.eclipse.core.databinding.property.IPropertyChangeListener;
20
import org.eclipse.core.databinding.property.PropertyChangeEvent;
22
import org.eclipse.core.databinding.property.PropertyChangeEvent;
Lines 66-73 Link Here
66
68
67
		public void propertyChange(java.beans.PropertyChangeEvent evt) {
69
		public void propertyChange(java.beans.PropertyChangeEvent evt) {
68
			if (propertyDescriptor.getName().equals(evt.getPropertyName())) {
70
			if (propertyDescriptor.getName().equals(evt.getPropertyName())) {
71
				ValueDiff diff;
72
				Object oldValue = evt.getOldValue();
73
				Object newValue = evt.getNewValue();
74
				if (oldValue != null && newValue != null) {
75
					diff = Diffs.createValueDiff(oldValue, newValue);
76
				} else {
77
					diff = null;
78
				}
69
				listener.handlePropertyChange(new PropertyChangeEvent(evt
79
				listener.handlePropertyChange(new PropertyChangeEvent(evt
70
						.getSource(), BeanValueProperty.this));
80
						.getSource(), BeanValueProperty.this, diff));
71
			}
81
			}
72
		}
82
		}
73
	}
83
	}
(-)src/org/eclipse/core/databinding/property/value/IValueProperty.java (-4 / +4 lines)
Lines 68-78 Link Here
68
	public IObservableValue observe(Realm realm, Object source);
68
	public IObservableValue observe(Realm realm, Object source);
69
69
70
	/**
70
	/**
71
	 * Returns a factory for creating observable values in the current default
71
	 * Returns a factory for creating observable values tracking this property
72
	 * realm, tracking this property of a particular property source.
72
	 * of a particular property source.
73
	 * 
73
	 * 
74
	 * @return a factory for creating observable values in current default
74
	 * @return a factory for creating observable values tracking this property
75
	 *         realm, tracking this property of a particular property source.
75
	 *         of a particular property source.
76
	 */
76
	 */
77
	public IObservableFactory valueFactory();
77
	public IObservableFactory valueFactory();
78
78
(-)src/org/eclipse/core/databinding/property/value/ValueProperty.java (-7 / +7 lines)
Lines 17-23 Link Here
17
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
17
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
18
import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables;
18
import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables;
19
import org.eclipse.core.databinding.observable.value.IObservableValue;
19
import org.eclipse.core.databinding.observable.value.IObservableValue;
20
import org.eclipse.core.databinding.property.Property;
21
import org.eclipse.core.databinding.property.list.IListProperty;
20
import org.eclipse.core.databinding.property.list.IListProperty;
22
import org.eclipse.core.databinding.property.map.IMapProperty;
21
import org.eclipse.core.databinding.property.map.IMapProperty;
23
import org.eclipse.core.databinding.property.set.ISetProperty;
22
import org.eclipse.core.databinding.property.set.ISetProperty;
Lines 31-46 Link Here
31
 * 
30
 * 
32
 * @since 1.2
31
 * @since 1.2
33
 */
32
 */
34
public abstract class ValueProperty extends Property implements IValueProperty {
33
public abstract class ValueProperty implements IValueProperty {
35
	public IObservableValue observe(Object source) {
34
	public IObservableValue observe(Object source) {
36
		Realm realm = getPreferredRealm(source);
35
		return observe(Realm.getDefault(), source);
37
		if (realm == null)
38
			realm = Realm.getDefault();
39
		return observe(realm, source);
40
	}
36
	}
41
37
42
	public IObservableFactory valueFactory() {
38
	public IObservableFactory valueFactory() {
43
		return valueFactory(Realm.getDefault());
39
		return new IObservableFactory() {
40
			public IObservable createObservable(Object target) {
41
				return observe(target);
42
			}
43
		};
44
	}
44
	}
45
45
46
	public IObservableFactory valueFactory(final Realm realm) {
46
	public IObservableFactory valueFactory(final Realm realm) {
(-)src/org/eclipse/core/databinding/property/value/SimpleValuePropertyObservableValue.java (-6 / +9 lines)
Lines 14-19 Link Here
14
import org.eclipse.core.databinding.observable.Diffs;
14
import org.eclipse.core.databinding.observable.Diffs;
15
import org.eclipse.core.databinding.observable.Realm;
15
import org.eclipse.core.databinding.observable.Realm;
16
import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
16
import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
17
import org.eclipse.core.databinding.observable.value.ValueDiff;
17
import org.eclipse.core.databinding.property.INativePropertyListener;
18
import org.eclipse.core.databinding.property.INativePropertyListener;
18
import org.eclipse.core.databinding.property.IProperty;
19
import org.eclipse.core.databinding.property.IProperty;
19
import org.eclipse.core.databinding.property.IPropertyChangeListener;
20
import org.eclipse.core.databinding.property.IPropertyChangeListener;
Lines 54-64 Link Here
54
				listener = property
55
				listener = property
55
						.adaptListener(new IPropertyChangeListener() {
56
						.adaptListener(new IPropertyChangeListener() {
56
							public void handlePropertyChange(
57
							public void handlePropertyChange(
57
									PropertyChangeEvent event) {
58
									final PropertyChangeEvent event) {
58
								if (!isDisposed() && !updating) {
59
								if (!isDisposed() && !updating) {
59
									getRealm().exec(new Runnable() {
60
									getRealm().exec(new Runnable() {
60
										public void run() {
61
										public void run() {
61
											notifyIfChanged();
62
											notifyIfChanged((ValueDiff) event.diff);
62
										}
63
										}
63
									});
64
									});
64
								}
65
								}
Lines 77-83 Link Here
77
	}
78
	}
78
79
79
	protected Object doGetValue() {
80
	protected Object doGetValue() {
80
		notifyIfChanged();
81
		notifyIfChanged(null);
81
		return property.getValue(source);
82
		return property.getValue(source);
82
	}
83
	}
83
84
Lines 89-103 Link Here
89
			updating = false;
90
			updating = false;
90
		}
91
		}
91
92
92
		notifyIfChanged();
93
		notifyIfChanged(null);
93
	}
94
	}
94
95
95
	private void notifyIfChanged() {
96
	private void notifyIfChanged(ValueDiff diff) {
96
		if (hasListeners()) {
97
		if (hasListeners()) {
97
			Object oldValue = cachedValue;
98
			Object oldValue = cachedValue;
98
			Object newValue = cachedValue = property.getValue(source);
99
			Object newValue = cachedValue = property.getValue(source);
100
			if (diff == null)
101
				diff = Diffs.createValueDiff(oldValue, newValue);
99
			if (hasListeners() && !Util.equals(oldValue, newValue)) {
102
			if (hasListeners() && !Util.equals(oldValue, newValue)) {
100
				fireValueChange(Diffs.createValueDiff(oldValue, newValue));
103
				fireValueChange(diff);
101
			}
104
			}
102
		}
105
		}
103
	}
106
	}
(-)src/org/eclipse/core/databinding/property/value/DelegatingValueProperty.java (-11 lines)
Lines 18-24 Link Here
18
import org.eclipse.core.databinding.observable.value.IObservableValue;
18
import org.eclipse.core.databinding.observable.value.IObservableValue;
19
import org.eclipse.core.databinding.property.INativePropertyListener;
19
import org.eclipse.core.databinding.property.INativePropertyListener;
20
import org.eclipse.core.databinding.property.IPropertyChangeListener;
20
import org.eclipse.core.databinding.property.IPropertyChangeListener;
21
import org.eclipse.core.databinding.property.Property;
22
21
23
/**
22
/**
24
 * @since 1.2
23
 * @since 1.2
Lines 60-75 Link Here
60
		return valueType;
59
		return valueType;
61
	}
60
	}
62
61
63
	public Realm getPreferredRealm(Object source) {
64
		IValueProperty delegate = getDelegate(source);
65
		Realm realm = null;
66
		if (delegate instanceof Property)
67
			realm = ((Property) delegate).getPreferredRealm(source);
68
		if (realm == null)
69
			realm = super.getPreferredRealm(source);
70
		return realm;
71
	}
72
73
	public IObservableValue observe(Realm realm, Object source) {
62
	public IObservableValue observe(Realm realm, Object source) {
74
		return getDelegate(source).observe(realm, source);
63
		return getDelegate(source).observe(realm, source);
75
	}
64
	}
(-)src/org/eclipse/core/databinding/property/list/DelegatingListProperty.java (-11 lines)
Lines 19-25 Link Here
19
import org.eclipse.core.databinding.observable.list.ListDiff;
19
import org.eclipse.core.databinding.observable.list.ListDiff;
20
import org.eclipse.core.databinding.property.INativePropertyListener;
20
import org.eclipse.core.databinding.property.INativePropertyListener;
21
import org.eclipse.core.databinding.property.IPropertyChangeListener;
21
import org.eclipse.core.databinding.property.IPropertyChangeListener;
22
import org.eclipse.core.databinding.property.Property;
23
22
24
/**
23
/**
25
 * @since 1.2
24
 * @since 1.2
Lines 53-68 Link Here
53
		return elementType;
52
		return elementType;
54
	}
53
	}
55
54
56
	public Realm getPreferredRealm(Object source) {
57
		IListProperty delegate = getDelegate(source);
58
		Realm realm = null;
59
		if (delegate instanceof Property)
60
			realm = ((Property) delegate).getPreferredRealm(source);
61
		if (realm == null)
62
			realm = super.getPreferredRealm(source);
63
		return realm;
64
	}
65
66
	public IObservableList observe(Realm realm, Object source) {
55
	public IObservableList observe(Realm realm, Object source) {
67
		return getDelegate(source).observe(realm, source);
56
		return getDelegate(source).observe(realm, source);
68
	}
57
	}
(-)src/org/eclipse/core/databinding/property/list/SimpleListPropertyObservableList.java (-15 / +16 lines)
Lines 73-79 Link Here
73
								if (!isDisposed() && !updating) {
73
								if (!isDisposed() && !updating) {
74
									getRealm().exec(new Runnable() {
74
									getRealm().exec(new Runnable() {
75
										public void run() {
75
										public void run() {
76
											notifyIfChanged();
76
											notifyIfChanged((ListDiff) event.diff);
77
										}
77
										}
78
									});
78
									});
79
								}
79
								}
Lines 173-179 Link Here
173
			updating = wasUpdating;
173
			updating = wasUpdating;
174
		}
174
		}
175
175
176
		notifyIfChanged();
176
		notifyIfChanged(null);
177
	}
177
	}
178
178
179
	public Iterator iterator() {
179
	public Iterator iterator() {
Lines 219-225 Link Here
219
					updating = wasUpdating;
219
					updating = wasUpdating;
220
				}
220
				}
221
221
222
				notifyIfChanged();
222
				notifyIfChanged(null);
223
223
224
				lastElement = null;
224
				lastElement = null;
225
				lastIndex = -1;
225
				lastIndex = -1;
Lines 263-269 Link Here
263
			updating = wasUpdating;
263
			updating = wasUpdating;
264
		}
264
		}
265
265
266
		notifyIfChanged();
266
		notifyIfChanged(null);
267
267
268
		return element;
268
		return element;
269
	}
269
	}
Lines 354-360 Link Here
354
					updating = wasUpdating;
354
					updating = wasUpdating;
355
				}
355
				}
356
356
357
				notifyIfChanged();
357
				notifyIfChanged(null);
358
358
359
				lastElement = null;
359
				lastElement = null;
360
				lastIndex = -1;
360
				lastIndex = -1;
Lines 379-385 Link Here
379
					updating = wasUpdating;
379
					updating = wasUpdating;
380
				}
380
				}
381
381
382
				notifyIfChanged();
382
				notifyIfChanged(null);
383
383
384
				lastElement = o;
384
				lastElement = o;
385
				expectedModCount = modCount;
385
				expectedModCount = modCount;
Lines 404-410 Link Here
404
					updating = wasUpdating;
404
					updating = wasUpdating;
405
				}
405
				}
406
406
407
				notifyIfChanged();
407
				notifyIfChanged(null);
408
408
409
				lastElement = null;
409
				lastElement = null;
410
				lastIndex = -1;
410
				lastIndex = -1;
Lines 435-441 Link Here
435
			updating = wasUpdating;
435
			updating = wasUpdating;
436
		}
436
		}
437
437
438
		notifyIfChanged();
438
		notifyIfChanged(null);
439
439
440
		return element;
440
		return element;
441
	}
441
	}
Lines 458-464 Link Here
458
			updating = wasUpdating;
458
			updating = wasUpdating;
459
		}
459
		}
460
460
461
		notifyIfChanged();
461
		notifyIfChanged(null);
462
462
463
		return oldElement;
463
		return oldElement;
464
	}
464
	}
Lines 505-511 Link Here
505
			updating = wasUpdating;
505
			updating = wasUpdating;
506
		}
506
		}
507
507
508
		notifyIfChanged();
508
		notifyIfChanged(null);
509
509
510
		return true;
510
		return true;
511
	}
511
	}
Lines 547-553 Link Here
547
			updating = wasUpdating;
547
			updating = wasUpdating;
548
		}
548
		}
549
549
550
		notifyIfChanged();
550
		notifyIfChanged(null);
551
551
552
		return !diff.isEmpty();
552
		return !diff.isEmpty();
553
	}
553
	}
Lines 591-597 Link Here
591
			updating = wasUpdating;
591
			updating = wasUpdating;
592
		}
592
		}
593
593
594
		notifyIfChanged();
594
		notifyIfChanged(null);
595
595
596
		return !diff.isEmpty();
596
		return !diff.isEmpty();
597
	}
597
	}
Lines 620-633 Link Here
620
			updating = wasUpdating;
620
			updating = wasUpdating;
621
		}
621
		}
622
622
623
		notifyIfChanged();
623
		notifyIfChanged(null);
624
	}
624
	}
625
625
626
	private void notifyIfChanged() {
626
	private void notifyIfChanged(ListDiff diff) {
627
		if (hasListeners()) {
627
		if (hasListeners()) {
628
			List oldList = cachedList;
628
			List oldList = cachedList;
629
			List newList = cachedList = property.getList(source);
629
			List newList = cachedList = property.getList(source);
630
			ListDiff diff = Diffs.computeListDiff(oldList, newList);
630
			if (diff == null)
631
				diff = Diffs.computeListDiff(oldList, newList);
631
			if (!diff.isEmpty()) {
632
			if (!diff.isEmpty()) {
632
				fireListChange(diff);
633
				fireListChange(diff);
633
			}
634
			}
(-)src/org/eclipse/core/databinding/property/list/IListProperty.java (-4 / +4 lines)
Lines 66-76 Link Here
66
	public IObservableList observe(Realm realm, Object source);
66
	public IObservableList observe(Realm realm, Object source);
67
67
68
	/**
68
	/**
69
	 * Returns a factory for creating observable lists in the current default
69
	 * Returns a factory for creating observable lists tracking this property of
70
	 * realm, tracking this property of a particular property source.
70
	 * a particular property source.
71
	 * 
71
	 * 
72
	 * @return a factory for creating observable lists in current default realm,
72
	 * @return a factory for creating observable lists tracking this property of
73
	 *         tracking this property of a particular property source.
73
	 *         a particular property source.
74
	 */
74
	 */
75
	public IObservableFactory listFactory();
75
	public IObservableFactory listFactory();
76
76
(-)src/org/eclipse/core/databinding/property/list/ListProperty.java (-7 / +7 lines)
Lines 18-24 Link Here
18
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
18
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
19
import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables;
19
import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables;
20
import org.eclipse.core.databinding.observable.value.IObservableValue;
20
import org.eclipse.core.databinding.observable.value.IObservableValue;
21
import org.eclipse.core.databinding.property.Property;
22
import org.eclipse.core.databinding.property.value.IValueProperty;
21
import org.eclipse.core.databinding.property.value.IValueProperty;
23
import org.eclipse.core.internal.databinding.property.ListPropertyDetailValuesList;
22
import org.eclipse.core.internal.databinding.property.ListPropertyDetailValuesList;
24
23
Lines 27-42 Link Here
27
 * 
26
 * 
28
 * @since 1.2
27
 * @since 1.2
29
 */
28
 */
30
public abstract class ListProperty extends Property implements IListProperty {
29
public abstract class ListProperty implements IListProperty {
31
	public IObservableList observe(Object source) {
30
	public IObservableList observe(Object source) {
32
		Realm realm = getPreferredRealm(source);
31
		return observe(Realm.getDefault(), source);
33
		if (realm == null)
34
			realm = Realm.getDefault();
35
		return observe(realm, source);
36
	}
32
	}
37
33
38
	public IObservableFactory listFactory() {
34
	public IObservableFactory listFactory() {
39
		return listFactory(Realm.getDefault());
35
		return new IObservableFactory() {
36
			public IObservable createObservable(Object target) {
37
				return observe(target);
38
			}
39
		};
40
	}
40
	}
41
41
42
	public IObservableFactory listFactory(final Realm realm) {
42
	public IObservableFactory listFactory(final Realm realm) {
(-)src/org/eclipse/core/databinding/observable/value/ValueDiff.java (-1 / +3 lines)
Lines 7-23 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Matthew Hall - bug 194734
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.core.databinding.observable.value;
13
package org.eclipse.core.databinding.observable.value;
13
14
14
import org.eclipse.core.databinding.observable.Diffs;
15
import org.eclipse.core.databinding.observable.Diffs;
16
import org.eclipse.core.databinding.observable.IDiff;
15
17
16
/**
18
/**
17
 * @since 1.0
19
 * @since 1.0
18
 * 
20
 * 
19
 */
21
 */
20
public abstract class ValueDiff {
22
public abstract class ValueDiff implements IDiff {
21
	/**
23
	/**
22
	 * Creates a value diff.
24
	 * Creates a value diff.
23
	 */
25
	 */
(-)src/org/eclipse/core/databinding/property/map/DelegatingMapProperty.java (-11 lines)
Lines 19-25 Link Here
19
import org.eclipse.core.databinding.observable.map.MapDiff;
19
import org.eclipse.core.databinding.observable.map.MapDiff;
20
import org.eclipse.core.databinding.property.INativePropertyListener;
20
import org.eclipse.core.databinding.property.INativePropertyListener;
21
import org.eclipse.core.databinding.property.IPropertyChangeListener;
21
import org.eclipse.core.databinding.property.IPropertyChangeListener;
22
import org.eclipse.core.databinding.property.Property;
23
22
24
/**
23
/**
25
 * @since 1.2
24
 * @since 1.2
Lines 58-73 Link Here
58
		return valueType;
57
		return valueType;
59
	}
58
	}
60
59
61
	public Realm getPreferredRealm(Object source) {
62
		IMapProperty delegate = getDelegate(source);
63
		Realm realm = null;
64
		if (delegate instanceof Property)
65
			realm = ((Property) delegate).getPreferredRealm(source);
66
		if (realm == null)
67
			realm = super.getPreferredRealm(source);
68
		return realm;
69
	}
70
71
	public IObservableMap observe(Realm realm, Object source) {
60
	public IObservableMap observe(Realm realm, Object source) {
72
		return getDelegate(source).observe(realm, source);
61
		return getDelegate(source).observe(realm, source);
73
	}
62
	}
(-)src/org/eclipse/core/databinding/property/map/SimpleMapPropertyObservableMap.java (-7 / +8 lines)
Lines 85-91 Link Here
85
								if (!isDisposed() && !updating) {
85
								if (!isDisposed() && !updating) {
86
									getRealm().exec(new Runnable() {
86
									getRealm().exec(new Runnable() {
87
										public void run() {
87
										public void run() {
88
											notifyIfChanged();
88
											notifyIfChanged((MapDiff) event.diff);
89
										}
89
										}
90
									});
90
									});
91
								}
91
								}
Lines 165-171 Link Here
165
				updating = wasUpdating;
165
				updating = wasUpdating;
166
			}
166
			}
167
167
168
			notifyIfChanged();
168
			notifyIfChanged(null);
169
169
170
			last = null;
170
			last = null;
171
			expectedModCount = modCount;
171
			expectedModCount = modCount;
Lines 208-214 Link Here
208
			updating = wasUpdating;
208
			updating = wasUpdating;
209
		}
209
		}
210
210
211
		notifyIfChanged();
211
		notifyIfChanged(null);
212
212
213
		return oldValue;
213
		return oldValue;
214
	}
214
	}
Lines 249-255 Link Here
249
			updating = wasUpdating;
249
			updating = wasUpdating;
250
		}
250
		}
251
251
252
		notifyIfChanged();
252
		notifyIfChanged(null);
253
	}
253
	}
254
254
255
	public Object remove(Object key) {
255
	public Object remove(Object key) {
Lines 259-274 Link Here
259
259
260
	public Collection values() {
260
	public Collection values() {
261
		getterCalled();
261
		getterCalled();
262
		// AbstractMap depends on entrySet() to fulfil keySet() API, so all
262
		// AbstractMap depends on entrySet() to fulfil values() API, so all
263
		// getterCalled() and comodification checks will still be handled
263
		// getterCalled() and comodification checks will still be handled
264
		return super.values();
264
		return super.values();
265
	}
265
	}
266
266
267
	private void notifyIfChanged() {
267
	private void notifyIfChanged(MapDiff diff) {
268
		if (hasListeners()) {
268
		if (hasListeners()) {
269
			Map oldMap = cachedMap;
269
			Map oldMap = cachedMap;
270
			Map newMap = cachedMap = property.getMap(source);
270
			Map newMap = cachedMap = property.getMap(source);
271
			MapDiff diff = Diffs.computeMapDiff(oldMap, newMap);
271
			if (diff == null)
272
				diff = Diffs.computeMapDiff(oldMap, newMap);
272
			if (!diff.isEmpty())
273
			if (!diff.isEmpty())
273
				fireMapChange(diff);
274
				fireMapChange(diff);
274
		}
275
		}
(-)src/org/eclipse/core/databinding/property/map/MapProperty.java (-7 / +7 lines)
Lines 18-24 Link Here
18
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
18
import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory;
19
import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables;
19
import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables;
20
import org.eclipse.core.databinding.observable.value.IObservableValue;
20
import org.eclipse.core.databinding.observable.value.IObservableValue;
21
import org.eclipse.core.databinding.property.Property;
22
import org.eclipse.core.databinding.property.value.IValueProperty;
21
import org.eclipse.core.databinding.property.value.IValueProperty;
23
import org.eclipse.core.internal.databinding.property.MapPropertyDetailValuesMap;
22
import org.eclipse.core.internal.databinding.property.MapPropertyDetailValuesMap;
24
23
Lines 27-42 Link Here
27
 * 
26
 * 
28
 * @since 1.2
27
 * @since 1.2
29
 */
28
 */
30
public abstract class MapProperty extends Property implements IMapProperty {
29
public abstract class MapProperty implements IMapProperty {
31
	public IObservableMap observe(Object source) {
30
	public IObservableMap observe(Object source) {
32
		Realm realm = getPreferredRealm(source);
31
		return observe(Realm.getDefault(), source);
33
		if (realm == null)
34
			realm = Realm.getDefault();
35
		return observe(realm, source);
36
	}
32
	}
37
33
38
	public IObservableFactory mapFactory() {
34
	public IObservableFactory mapFactory() {
39
		return mapFactory(Realm.getDefault());
35
		return new IObservableFactory() {
36
			public IObservable createObservable(Object target) {
37
				return observe(target);
38
			}
39
		};
40
	}
40
	}
41
41
42
	public IObservableFactory mapFactory(final Realm realm) {
42
	public IObservableFactory mapFactory(final Realm realm) {
(-)src/org/eclipse/core/databinding/property/map/IMapProperty.java (-4 / +4 lines)
Lines 75-85 Link Here
75
	public IObservableMap observe(Realm realm, Object source);
75
	public IObservableMap observe(Realm realm, Object source);
76
76
77
	/**
77
	/**
78
	 * Returns a factory for creating observable maps in the current default
78
	 * Returns a factory for creating observable maps tracking this property of
79
	 * realm, tracking this property of a particular property source.
79
	 * a particular property source.
80
	 * 
80
	 * 
81
	 * @return a factory for creating observable maps in current default realm,
81
	 * @return a factory for creating observable maps tracking this property of
82
	 *         tracking this property of a particular property source.
82
	 *         a particular property source.
83
	 */
83
	 */
84
	public IObservableFactory mapFactory();
84
	public IObservableFactory mapFactory();
85
85
(-)src/org/eclipse/core/databinding/property/set/SetProperty.java (-7 / +7 lines)
Lines 18-24 Link Here
18
import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables;
18
import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables;
19
import org.eclipse.core.databinding.observable.set.IObservableSet;
19
import org.eclipse.core.databinding.observable.set.IObservableSet;
20
import org.eclipse.core.databinding.observable.value.IObservableValue;
20
import org.eclipse.core.databinding.observable.value.IObservableValue;
21
import org.eclipse.core.databinding.property.Property;
22
import org.eclipse.core.databinding.property.map.IMapProperty;
21
import org.eclipse.core.databinding.property.map.IMapProperty;
23
import org.eclipse.core.databinding.property.value.IValueProperty;
22
import org.eclipse.core.databinding.property.value.IValueProperty;
24
import org.eclipse.core.internal.databinding.property.SetPropertyDetailValuesMap;
23
import org.eclipse.core.internal.databinding.property.SetPropertyDetailValuesMap;
Lines 28-43 Link Here
28
 * 
27
 * 
29
 * @since 1.2
28
 * @since 1.2
30
 */
29
 */
31
public abstract class SetProperty extends Property implements ISetProperty {
30
public abstract class SetProperty implements ISetProperty {
32
	public IObservableSet observe(Object source) {
31
	public IObservableSet observe(Object source) {
33
		Realm realm = getPreferredRealm(source);
32
		return observe(Realm.getDefault(), source);
34
		if (realm == null)
35
			realm = Realm.getDefault();
36
		return observe(realm, source);
37
	}
33
	}
38
34
39
	public IObservableFactory setFactory() {
35
	public IObservableFactory setFactory() {
40
		return setFactory(Realm.getDefault());
36
		return new IObservableFactory() {
37
			public IObservable createObservable(Object target) {
38
				return observe(target);
39
			}
40
		};
41
	}
41
	}
42
42
43
	public IObservableFactory setFactory(final Realm realm) {
43
	public IObservableFactory setFactory(final Realm realm) {
(-)src/org/eclipse/core/databinding/property/set/ISetProperty.java (-4 / +4 lines)
Lines 68-78 Link Here
68
	public IObservableSet observe(Realm realm, Object source);
68
	public IObservableSet observe(Realm realm, Object source);
69
69
70
	/**
70
	/**
71
	 * Returns a factory for creating observable sets in the current default
71
	 * Returns a factory for creating observable sets tracking this property of
72
	 * realm, tracking this property of a particular property source.
72
	 * a particular property source.
73
	 * 
73
	 * 
74
	 * @return a factory for creating observable sets in current default realm,
74
	 * @return a factory for creating observable sets tracking this property of
75
	 *         tracking this property of a particular property source.
75
	 *         a particular property source.
76
	 */
76
	 */
77
	public IObservableFactory setFactory();
77
	public IObservableFactory setFactory();
78
78
(-)src/org/eclipse/core/databinding/property/set/SimpleSetPropertyObservableSet.java (-14 / +11 lines)
Lines 70-76 Link Here
70
								if (!isDisposed() && !updating) {
70
								if (!isDisposed() && !updating) {
71
									getRealm().exec(new Runnable() {
71
									getRealm().exec(new Runnable() {
72
										public void run() {
72
										public void run() {
73
											notifyIfChanged();
73
											notifyIfChanged((SetDiff) event.diff);
74
										}
74
										}
75
									});
75
									});
76
								}
76
								}
Lines 113-122 Link Here
113
		return getSet().containsAll(c);
113
		return getSet().containsAll(c);
114
	}
114
	}
115
115
116
	protected int doGetSize() {
117
		return getSet().size();
118
	}
119
120
	public boolean isEmpty() {
116
	public boolean isEmpty() {
121
		getterCalled();
117
		getterCalled();
122
		return getSet().isEmpty();
118
		return getSet().isEmpty();
Lines 153-159 Link Here
153
			updating = wasUpdating;
149
			updating = wasUpdating;
154
		}
150
		}
155
151
156
		notifyIfChanged();
152
		notifyIfChanged(null);
157
153
158
		return true;
154
		return true;
159
	}
155
	}
Lines 196-202 Link Here
196
					updating = wasUpdating;
192
					updating = wasUpdating;
197
				}
193
				}
198
194
199
				notifyIfChanged();
195
				notifyIfChanged(null);
200
196
201
				last = null;
197
				last = null;
202
				expectedModCount = modCount;
198
				expectedModCount = modCount;
Lines 228-234 Link Here
228
			updating = wasUpdating;
224
			updating = wasUpdating;
229
		}
225
		}
230
226
231
		notifyIfChanged();
227
		notifyIfChanged(null);
232
228
233
		return true;
229
		return true;
234
	}
230
	}
Lines 264-270 Link Here
264
			updating = wasUpdating;
260
			updating = wasUpdating;
265
		}
261
		}
266
262
267
		notifyIfChanged();
263
		notifyIfChanged(null);
268
264
269
		return true;
265
		return true;
270
	}
266
	}
Lines 301-307 Link Here
301
			updating = wasUpdating;
297
			updating = wasUpdating;
302
		}
298
		}
303
299
304
		notifyIfChanged();
300
		notifyIfChanged(null);
305
301
306
		return true;
302
		return true;
307
	}
303
	}
Lines 343-349 Link Here
343
			updating = wasUpdating;
339
			updating = wasUpdating;
344
		}
340
		}
345
341
346
		notifyIfChanged();
342
		notifyIfChanged(null);
347
343
348
		return true;
344
		return true;
349
	}
345
	}
Lines 366-379 Link Here
366
			updating = wasUpdating;
362
			updating = wasUpdating;
367
		}
363
		}
368
364
369
		notifyIfChanged();
365
		notifyIfChanged(null);
370
	}
366
	}
371
367
372
	private void notifyIfChanged() {
368
	private void notifyIfChanged(SetDiff diff) {
373
		if (hasListeners()) {
369
		if (hasListeners()) {
374
			Set oldSet = cachedSet;
370
			Set oldSet = cachedSet;
375
			Set newSet = cachedSet = property.getSet(source);
371
			Set newSet = cachedSet = property.getSet(source);
376
			SetDiff diff = Diffs.computeSetDiff(oldSet, newSet);
372
			if (diff == null)
373
				diff = Diffs.computeSetDiff(oldSet, newSet);
377
			if (!diff.isEmpty())
374
			if (!diff.isEmpty())
378
				fireSetChange(diff);
375
				fireSetChange(diff);
379
		}
376
		}
(-)src/org/eclipse/core/databinding/property/set/DelegatingSetProperty.java (-11 lines)
Lines 19-25 Link Here
19
import org.eclipse.core.databinding.observable.set.SetDiff;
19
import org.eclipse.core.databinding.observable.set.SetDiff;
20
import org.eclipse.core.databinding.property.INativePropertyListener;
20
import org.eclipse.core.databinding.property.INativePropertyListener;
21
import org.eclipse.core.databinding.property.IPropertyChangeListener;
21
import org.eclipse.core.databinding.property.IPropertyChangeListener;
22
import org.eclipse.core.databinding.property.Property;
23
22
24
/**
23
/**
25
 * @since 1.2
24
 * @since 1.2
Lines 52-67 Link Here
52
		return elementType;
51
		return elementType;
53
	}
52
	}
54
53
55
	public Realm getPreferredRealm(Object source) {
56
		ISetProperty delegate = getDelegate(source);
57
		Realm realm = null;
58
		if (delegate instanceof Property)
59
			realm = ((Property) delegate).getPreferredRealm(source);
60
		if (realm == null)
61
			realm = super.getPreferredRealm(source);
62
		return realm;
63
	}
64
65
	public IObservableSet observe(Realm realm, Object source) {
54
	public IObservableSet observe(Realm realm, Object source) {
66
		return getDelegate(source).observe(realm, source);
55
		return getDelegate(source).observe(realm, source);
67
	}
56
	}
(-)src/org/eclipse/core/databinding/observable/set/SetDiff.java (-2 / +4 lines)
Lines 7-24 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Matthew Hall - bug 251884
10
 *     Matthew Hall - bugs 251884, 194734
11
 *******************************************************************************/
11
 *******************************************************************************/
12
12
13
package org.eclipse.core.databinding.observable.set;
13
package org.eclipse.core.databinding.observable.set;
14
14
15
import java.util.Set;
15
import java.util.Set;
16
16
17
import org.eclipse.core.databinding.observable.IDiff;
18
17
/**
19
/**
18
 * @since 1.0
20
 * @since 1.0
19
 *
21
 *
20
 */
22
 */
21
public abstract class SetDiff {
23
public abstract class SetDiff implements IDiff {
22
	
24
	
23
	/**
25
	/**
24
	 * @return the set of added elements
26
	 * @return the set of added elements
(-)src/org/eclipse/core/databinding/property/Property.java (-49 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Matthew Hall and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Matthew Hall - initial API and implementation (bug 194734)
10
 *     Matthew Hall - bug 195222
11
 ******************************************************************************/
12
13
package org.eclipse.core.databinding.property;
14
15
import org.eclipse.core.databinding.observable.Realm;
16
import org.eclipse.core.databinding.property.list.IListProperty;
17
import org.eclipse.core.databinding.property.map.IMapProperty;
18
import org.eclipse.core.databinding.property.set.ISetProperty;
19
import org.eclipse.core.databinding.property.value.IValueProperty;
20
21
/**
22
 * Abstract IProperty implementation
23
 * 
24
 * @since 1.2
25
 */
26
public abstract class Property implements IProperty {
27
	/**
28
	 * Returns the preferred realm to use when observing the specified property
29
	 * source. This method is used to determine the default realm for methods
30
	 * lacking an explicit or implicit realm.
31
	 * <p>
32
	 * The default implementation of this method returns <code>null</code>
33
	 * (indicating no preference). Subclasses may override this method to
34
	 * return an appropriate realm.
35
	 * 
36
	 * @param source
37
	 *            the property source
38
	 * @return the preferred realm to use when observing the specified property
39
	 *         source, or null if the source object has no implicit preference.
40
	 * 
41
	 * @see IValueProperty#observe(Object)
42
	 * @see IListProperty#observe(Object)
43
	 * @see ISetProperty#observe(Object)
44
	 * @see IMapProperty#observe(Object)
45
	 */
46
	public Realm getPreferredRealm(Object source) {
47
		return null;
48
	}
49
}
(-)src/org/eclipse/core/databinding/property/PropertyChangeEvent.java (-2 / +15 lines)
Lines 13-18 Link Here
13
13
14
import java.util.EventObject;
14
import java.util.EventObject;
15
15
16
import org.eclipse.core.databinding.observable.IDiff;
16
import org.eclipse.core.internal.databinding.Util;
17
import org.eclipse.core.internal.databinding.Util;
17
18
18
/**
19
/**
Lines 29-44 Link Here
29
	public final IProperty property;
30
	public final IProperty property;
30
31
31
	/**
32
	/**
33
	 * A diff object describing the change in state, or null for an unknown
34
	 * change.
35
	 */
36
	public final IDiff diff;
37
38
	/**
32
	 * Constructs a PropertyChangeEvent with the given attributes
39
	 * Constructs a PropertyChangeEvent with the given attributes
33
	 * 
40
	 * 
34
	 * @param source
41
	 * @param source
35
	 *            the property source
42
	 *            the property source
36
	 * @param property
43
	 * @param property
37
	 *            the property that changed on the source
44
	 *            the property that changed on the source
45
	 * @param diff
46
	 *            a diff describing the change in state, or null if the change
47
	 *            is unknown.
38
	 */
48
	 */
39
	public PropertyChangeEvent(Object source, IProperty property) {
49
	public PropertyChangeEvent(Object source, IProperty property, IDiff diff) {
40
		super(source);
50
		super(source);
41
		this.property = property;
51
		this.property = property;
52
		this.diff = diff;
42
	}
53
	}
43
54
44
	public boolean equals(Object obj) {
55
	public boolean equals(Object obj) {
Lines 51-63 Link Here
51
62
52
		PropertyChangeEvent that = (PropertyChangeEvent) obj;
63
		PropertyChangeEvent that = (PropertyChangeEvent) obj;
53
		return Util.equals(getSource(), that.getSource())
64
		return Util.equals(getSource(), that.getSource())
54
				&& Util.equals(this.property, that.property);
65
				&& Util.equals(this.property, that.property)
66
				&& Util.equals(this.diff, that.diff);
55
	}
67
	}
56
68
57
	public int hashCode() {
69
	public int hashCode() {
58
		int hash = 17;
70
		int hash = 17;
59
		hash = hash * 37 + getSource().hashCode();
71
		hash = hash * 37 + getSource().hashCode();
60
		hash = hash * 37 + property.hashCode();
72
		hash = hash * 37 + property.hashCode();
73
		hash = hash * 37 + (diff == null ? 0 : diff.hashCode());
61
		return hash;
74
		return hash;
62
	}
75
	}
63
}
76
}
(-)src/org/eclipse/core/databinding/observable/map/MapDiff.java (-2 / +4 lines)
Lines 7-13 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Matthew Hall - bug 251884
10
 *     Matthew Hall - bugs 251884, 194734
11
 *******************************************************************************/
11
 *******************************************************************************/
12
12
13
package org.eclipse.core.databinding.observable.map;
13
package org.eclipse.core.databinding.observable.map;
Lines 16-26 Link Here
16
import java.util.Map;
16
import java.util.Map;
17
import java.util.Set;
17
import java.util.Set;
18
18
19
import org.eclipse.core.databinding.observable.IDiff;
20
19
/**
21
/**
20
 * @since 1.1
22
 * @since 1.1
21
 * 
23
 * 
22
 */
24
 */
23
public abstract class MapDiff {
25
public abstract class MapDiff implements IDiff {
24
	/**
26
	/**
25
	 * Returns true if the diff has no added, removed or changed entries.
27
	 * Returns true if the diff has no added, removed or changed entries.
26
	 * 
28
	 * 
(-)src/org/eclipse/core/databinding/observable/list/ListDiff.java (-2 / +3 lines)
Lines 7-19 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Matthew Hall - bug 208858, 251884
10
 *     Matthew Hall - bugs 208858, 251884, 194734
11
 *******************************************************************************/
11
 *******************************************************************************/
12
12
13
package org.eclipse.core.databinding.observable.list;
13
package org.eclipse.core.databinding.observable.list;
14
14
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.core.databinding.observable.IDiff;
17
import org.eclipse.core.internal.databinding.Util;
18
import org.eclipse.core.internal.databinding.Util;
18
19
19
/**
20
/**
Lines 21-27 Link Here
21
 * 
22
 * 
22
 * @since 1.0
23
 * @since 1.0
23
 */
24
 */
24
public abstract class ListDiff {
25
public abstract class ListDiff implements IDiff {
25
26
26
	/**
27
	/**
27
	 * Returns a ListDiffEntry array representing the differences in the list,
28
	 * Returns a ListDiffEntry array representing the differences in the list,
(-)src/org/eclipse/core/databinding/observable/IDiff.java (+29 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 Matthew Hall and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Matthew Hall - initial API and implementation (bug 194734)
10
 ******************************************************************************/
11
12
package org.eclipse.core.databinding.observable;
13
14
import org.eclipse.core.databinding.observable.list.ListDiff;
15
import org.eclipse.core.databinding.observable.map.MapDiff;
16
import org.eclipse.core.databinding.observable.set.SetDiff;
17
import org.eclipse.core.databinding.observable.value.ValueDiff;
18
19
/**
20
 * Marker interface for objects which describe a difference in state.
21
 * 
22
 * @since 1.2
23
 * @see ValueDiff
24
 * @see ListDiff
25
 * @see SetDiff
26
 * @see MapDiff
27
 */
28
public interface IDiff {
29
}
(-)src/org/eclipse/jface/internal/databinding/viewers/SelectionProviderSingleSelectionProperty.java (-4 / +3 lines)
Lines 72-81 Link Here
72
		}
72
		}
73
73
74
		public void selectionChanged(SelectionChangedEvent event) {
74
		public void selectionChanged(SelectionChangedEvent event) {
75
			listener
75
			listener.handlePropertyChange(new PropertyChangeEvent(event
76
					.handlePropertyChange(new PropertyChangeEvent(event
76
					.getSource(),
77
							.getSource(),
77
					SelectionProviderSingleSelectionProperty.this, null));
78
							SelectionProviderSingleSelectionProperty.this));
79
		}
78
		}
80
	}
79
	}
81
80
(-)src/org/eclipse/jface/internal/databinding/viewers/ViewerSetProperty.java (-4 / +4 lines)
Lines 22-33 Link Here
22
 * 
22
 * 
23
 */
23
 */
24
public abstract class ViewerSetProperty extends SimpleSetProperty {
24
public abstract class ViewerSetProperty extends SimpleSetProperty {
25
	public Realm getPreferredRealm(Object source) {
25
	public IObservableSet observe(Object source) {
26
		if (source instanceof Viewer) {
26
		if (source instanceof Viewer) {
27
			return SWTObservables.getRealm(((Viewer) source).getControl()
27
			return observe(SWTObservables.getRealm(((Viewer) source)
28
					.getDisplay());
28
					.getControl().getDisplay()), source);
29
		}
29
		}
30
		return super.getPreferredRealm(source);
30
		return super.observe(source);
31
	}
31
	}
32
32
33
	public IObservableSet observe(Realm realm, Object source) {
33
	public IObservableSet observe(Realm realm, Object source) {
(-)src/org/eclipse/jface/internal/databinding/viewers/ViewerValueProperty.java (-4 / +4 lines)
Lines 22-33 Link Here
22
 * 
22
 * 
23
 */
23
 */
24
public abstract class ViewerValueProperty extends SimpleValueProperty {
24
public abstract class ViewerValueProperty extends SimpleValueProperty {
25
	public Realm getPreferredRealm(Object source) {
25
	public IObservableValue observe(Object source) {
26
		if (source instanceof Viewer) {
26
		if (source instanceof Viewer) {
27
			return SWTObservables.getRealm(((Viewer) source).getControl()
27
			return observe(SWTObservables.getRealm(((Viewer) source)
28
					.getDisplay());
28
					.getControl().getDisplay()), source);
29
		}
29
		}
30
		return super.getPreferredRealm(source);
30
		return super.observe(source);
31
	}
31
	}
32
32
33
	public IObservableValue observe(Realm realm, Object source) {
33
	public IObservableValue observe(Realm realm, Object source) {
(-)src/org/eclipse/jface/internal/databinding/viewers/CheckableCheckedElementsProperty.java (-1 / +9 lines)
Lines 12-21 Link Here
12
12
13
package org.eclipse.jface.internal.databinding.viewers;
13
package org.eclipse.jface.internal.databinding.viewers;
14
14
15
import java.util.Collections;
15
import java.util.HashSet;
16
import java.util.HashSet;
16
import java.util.Iterator;
17
import java.util.Iterator;
17
import java.util.Set;
18
import java.util.Set;
18
19
20
import org.eclipse.core.databinding.observable.Diffs;
19
import org.eclipse.core.databinding.observable.set.SetDiff;
21
import org.eclipse.core.databinding.observable.set.SetDiff;
20
import org.eclipse.core.databinding.property.INativePropertyListener;
22
import org.eclipse.core.databinding.property.INativePropertyListener;
21
import org.eclipse.core.databinding.property.IPropertyChangeListener;
23
import org.eclipse.core.databinding.property.IPropertyChangeListener;
Lines 95-102 Link Here
95
		}
97
		}
96
98
97
		public void checkStateChanged(CheckStateChangedEvent event) {
99
		public void checkStateChanged(CheckStateChangedEvent event) {
100
			Object element = event.getElement();
101
			boolean checked = event.getChecked();
102
			Set elementSet = Collections.singleton(element);
103
			Set additions = checked ? elementSet : Collections.EMPTY_SET;
104
			Set removals = checked ? Collections.EMPTY_SET : elementSet;
105
			SetDiff diff = Diffs.createSetDiff(additions, removals);
98
			listener.handlePropertyChange(new PropertyChangeEvent(event
106
			listener.handlePropertyChange(new PropertyChangeEvent(event
99
					.getSource(), CheckableCheckedElementsProperty.this));
107
					.getSource(), CheckableCheckedElementsProperty.this, diff));
100
		}
108
		}
101
	}
109
	}
102
110
(-)src/org/eclipse/jface/internal/databinding/viewers/ViewerListProperty.java (-4 / +4 lines)
Lines 22-33 Link Here
22
 * 
22
 * 
23
 */
23
 */
24
public abstract class ViewerListProperty extends SimpleListProperty {
24
public abstract class ViewerListProperty extends SimpleListProperty {
25
	public Realm getPreferredRealm(Object source) {
25
	public IObservableList observe(Object source) {
26
		if (source instanceof Viewer) {
26
		if (source instanceof Viewer) {
27
			return SWTObservables.getRealm(((Viewer) source).getControl()
27
			return observe(SWTObservables.getRealm(((Viewer) source)
28
					.getDisplay());
28
					.getControl().getDisplay()), source);
29
		}
29
		}
30
		return super.getPreferredRealm(source);
30
		return super.observe(source);
31
	}
31
	}
32
32
33
	public IObservableList observe(Realm realm, Object source) {
33
	public IObservableList observe(Realm realm, Object source) {
(-)src/org/eclipse/jface/internal/databinding/viewers/SelectionProviderMultipleSelectionProperty.java (-1 / +1 lines)
Lines 76-82 Link Here
76
		public void selectionChanged(SelectionChangedEvent event) {
76
		public void selectionChanged(SelectionChangedEvent event) {
77
			listener.handlePropertyChange(new PropertyChangeEvent(event
77
			listener.handlePropertyChange(new PropertyChangeEvent(event
78
					.getSource(),
78
					.getSource(),
79
					SelectionProviderMultipleSelectionProperty.this));
79
					SelectionProviderMultipleSelectionProperty.this, null));
80
		}
80
		}
81
	}
81
	}
82
82
(-)src/org/eclipse/jface/internal/databinding/swt/WidgetValueProperty.java (-10 / +11 lines)
Lines 39-51 Link Here
39
		this.events = events;
39
		this.events = events;
40
	}
40
	}
41
41
42
	public Realm getPreferredRealm(Object source) {
43
		if (source instanceof Widget) {
44
			return SWTObservables.getRealm(((Widget) source).getDisplay());
45
		}
46
		return super.getPreferredRealm(source);
47
	}
48
49
	protected INativePropertyListener adaptListener(
42
	protected INativePropertyListener adaptListener(
50
			IPropertyChangeListener listener) {
43
			IPropertyChangeListener listener) {
51
		return new WidgetListener(listener);
44
		return new WidgetListener(listener);
Lines 85-100 Link Here
85
78
86
		public void handleEvent(Event event) {
79
		public void handleEvent(Event event) {
87
			listener.handlePropertyChange(new PropertyChangeEvent(event.widget,
80
			listener.handlePropertyChange(new PropertyChangeEvent(event.widget,
88
					WidgetValueProperty.this));
81
					WidgetValueProperty.this, null));
82
		}
83
	}
84
85
	public IObservableValue observe(Object source) {
86
		if (source instanceof Widget) {
87
			return observe(SWTObservables.getRealm(((Widget) source)
88
					.getDisplay()), source);
89
		}
89
		}
90
		return super.observe(source);
90
	}
91
	}
91
92
92
	public IObservableValue observe(Realm realm, Object source) {
93
	public IObservableValue observe(Realm realm, Object source) {
93
		return wrapObservable(super.observe(realm, source), (Widget) source);
94
		return wrapObservable(super.observe(realm, source), (Widget) source);
94
	}
95
	}
95
96
96
	protected ISWTObservableValue wrapObservable(
97
	protected ISWTObservableValue wrapObservable(IObservableValue observable,
97
			IObservableValue observable, Widget widget) {
98
			Widget widget) {
98
		return new SWTObservableValueDecorator(observable, widget);
99
		return new SWTObservableValueDecorator(observable, widget);
99
	}
100
	}
100
}
101
}
(-)src/org/eclipse/jface/internal/databinding/swt/WidgetListProperty.java (-4 / +6 lines)
Lines 22-31 Link Here
22
 * 
22
 * 
23
 */
23
 */
24
public abstract class WidgetListProperty extends SimpleListProperty {
24
public abstract class WidgetListProperty extends SimpleListProperty {
25
	public Realm getPreferredRealm(Object source) {
25
	public IObservableList observe(Object source) {
26
		if (source instanceof Widget)
26
		if (source instanceof Widget) {
27
			return SWTObservables.getRealm(((Widget) source).getDisplay());
27
			return observe(SWTObservables.getRealm(((Widget) source)
28
		return super.getPreferredRealm(source);
28
					.getDisplay()), source);
29
		}
30
		return super.observe(source);
29
	}
31
	}
30
32
31
	public IObservableList observe(Realm realm, Object source) {
33
	public IObservableList observe(Realm realm, Object source) {

Return to bug 194734