comparison org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/set/UnionSet.d @ 85:6be48cf9f95c

Work on databinding
author Frank Benoit <benoit@tionex.de>
date Sat, 18 Apr 2009 13:54:50 +0200
parents 383ce7bd736b
children
comparison
equal deleted inserted replaced
84:fcf926c91ca4 85:6be48cf9f95c
12 12
13 module org.eclipse.core.databinding.observable.set.UnionSet; 13 module org.eclipse.core.databinding.observable.set.UnionSet;
14 import org.eclipse.core.databinding.observable.set.ISetChangeListener; 14 import org.eclipse.core.databinding.observable.set.ISetChangeListener;
15 import org.eclipse.core.databinding.observable.set.SetChangeEvent; 15 import org.eclipse.core.databinding.observable.set.SetChangeEvent;
16 import org.eclipse.core.databinding.observable.set.IObservableSet; 16 import org.eclipse.core.databinding.observable.set.IObservableSet;
17 import org.eclipse.core.databinding.observable.IObservable;
17 import org.eclipse.core.databinding.observable.set.ObservableSet; 18 import org.eclipse.core.databinding.observable.set.ObservableSet;
18 19
19 import java.lang.all; 20 import java.lang.all;
20 21
21 import java.util.ArrayList; 22 import java.util.ArrayList;
64 /** 65 /**
65 * @param childSets 66 * @param childSets
66 */ 67 */
67 public this(IObservableSet[] childSets) { 68 public this(IObservableSet[] childSets) {
68 super(childSets[0].getRealm(), null, childSets[0].getElementType()); 69 super(childSets[0].getRealm(), null, childSets[0].getElementType());
69 System.arraycopy(childSets, 0, this.childSets = new IObservableSet[childSets.length], 0, childSets.length); 70 childSetChangeListener = new ChildSetChangeListener();
70 this.stalenessTracker = new StalenessTracker(childSets, 71 stalenessConsumer = new StalenessConsumer();
72 this.childSets = new IObservableSet[childSets.length];
73 for( int i = 0; i < childSets.length; i++ ){
74 this.childSets[i] = childSets[i];
75 }
76 this.stalenessTracker = new StalenessTracker(arraycast!(IObservable)(childSets),
71 stalenessConsumer); 77 stalenessConsumer);
72 } 78 }
73 79
74 private ISetChangeListener childSetChangeListener = new class() ISetChangeListener { 80 private ISetChangeListener childSetChangeListener;
81 class ChildSetChangeListener : ISetChangeListener {
75 public void handleSetChange(SetChangeEvent event) { 82 public void handleSetChange(SetChangeEvent event) {
76 processAddsAndRemoves(event.diff.getAdditions(), event.diff.getRemovals()); 83 processAddsAndRemoves(event.diff.getAdditions(), event.diff.getRemovals());
77 } 84 }
78 }; 85 }
79 86
80 private IStalenessConsumer stalenessConsumer = new class() IStalenessConsumer { 87 private IStalenessConsumer stalenessConsumer;
88 class StalenessConsumer : IStalenessConsumer {
81 public void setStale(bool stale) { 89 public void setStale(bool stale) {
82 bool oldStale = this.outer.stale; 90 bool oldStale = this.outer.stale;
83 this.outer.stale = stale; 91 this.outer.stale = stale;
84 if (stale && !oldStale) { 92 if (stale && !oldStale) {
85 fireStale(); 93 fireStale();
86 } 94 }
87 } 95 }
88 }; 96 }
89 97
90 public bool isStale() { 98 public bool isStale() {
91 getterCalled(); 99 getterCalled();
92 if (refCounts !is null) { 100 if (refCounts !is null) {
93 return stale; 101 return stale;
152 for (int i = 0; i < childSets.length; i++) { 160 for (int i = 0; i < childSets.length; i++) {
153 IObservableSet next = childSets[i]; 161 IObservableSet next = childSets[i];
154 next.addSetChangeListener(childSetChangeListener); 162 next.addSetChangeListener(childSetChangeListener);
155 incrementRefCounts(next); 163 incrementRefCounts(next);
156 } 164 }
157 stalenessTracker = new StalenessTracker(childSets, stalenessConsumer); 165 stalenessTracker = new StalenessTracker(arraycast!(IObservable)(childSets), stalenessConsumer);
158 setWrappedSet(refCounts.keySet()); 166 setWrappedSet(refCounts.keySet());
159 } 167 }
160 168
161 protected void lastListenerRemoved() { 169 protected void lastListenerRemoved() {
162 super.lastListenerRemoved(); 170 super.lastListenerRemoved();