Mercurial > projects > dwt2
comparison org.eclipse.core.databinding/src/org/eclipse/core/databinding/ListBinding.d @ 85:6be48cf9f95c
Work on databinding
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 18 Apr 2009 13:54:50 +0200 |
parents | 383ce7bd736b |
children | 9e0ab372d5d8 |
comparison
equal
deleted
inserted
replaced
84:fcf926c91ca4 | 85:6be48cf9f95c |
---|---|
41 private UpdateListStrategy modelToTarget; | 41 private UpdateListStrategy modelToTarget; |
42 private IObservableValue validationStatusObservable; | 42 private IObservableValue validationStatusObservable; |
43 private bool updatingTarget; | 43 private bool updatingTarget; |
44 private bool updatingModel; | 44 private bool updatingModel; |
45 | 45 |
46 private IListChangeListener targetChangeListener = new class() IListChangeListener { | 46 private IListChangeListener targetChangeListener; |
47 private class TargetChangeListener : IListChangeListener { | |
47 public void handleListChange(ListChangeEvent event) { | 48 public void handleListChange(ListChangeEvent event) { |
48 if (!updatingTarget) { | 49 if (!updatingTarget) { |
49 doUpdate(cast(IObservableList) getTarget(), | 50 doUpdate(cast(IObservableList) getTarget(), |
50 cast(IObservableList) getModel(), event.diff, | 51 cast(IObservableList) getModel(), event.diff, |
51 targetToModel, false, false); | 52 targetToModel, false, false); |
52 } | 53 } |
53 } | 54 } |
54 }; | 55 } |
55 private IListChangeListener modelChangeListener = new class() IListChangeListener { | 56 private IListChangeListener modelChangeListener; |
57 class ModelChangeListener : IListChangeListener { | |
56 public void handleListChange(ListChangeEvent event) { | 58 public void handleListChange(ListChangeEvent event) { |
57 if (!updatingModel) { | 59 if (!updatingModel) { |
58 doUpdate(cast(IObservableList) getModel(), | 60 doUpdate(cast(IObservableList) getModel(), |
59 cast(IObservableList) getTarget(), event.diff, | 61 cast(IObservableList) getTarget(), event.diff, |
60 modelToTarget, false, false); | 62 modelToTarget, false, false); |
69 * @param targetToModelStrategy | 71 * @param targetToModelStrategy |
70 */ | 72 */ |
71 public this(IObservableList target, IObservableList model, | 73 public this(IObservableList target, IObservableList model, |
72 UpdateListStrategy targetToModelStrategy, | 74 UpdateListStrategy targetToModelStrategy, |
73 UpdateListStrategy modelToTargetStrategy) { | 75 UpdateListStrategy modelToTargetStrategy) { |
76 targetChangeListener = new TargetChangeListener(); | |
77 modelChangeListener = new ModelChangeListener(); | |
74 super(target, model); | 78 super(target, model); |
75 this.targetToModel = targetToModelStrategy; | 79 this.targetToModel = targetToModelStrategy; |
76 this.modelToTarget = modelToTargetStrategy; | 80 this.modelToTarget = modelToTargetStrategy; |
77 if ((targetToModel.getUpdatePolicy() & UpdateValueStrategy.POLICY_UPDATE) !is 0) { | 81 if ((targetToModel.getUpdatePolicy() & UpdateValueStrategy.POLICY_UPDATE) !is 0) { |
78 target.addListChangeListener(targetChangeListener); | 82 target.addListChangeListener(targetChangeListener); |
90 return validationStatusObservable; | 94 return validationStatusObservable; |
91 } | 95 } |
92 | 96 |
93 protected void preInit() { | 97 protected void preInit() { |
94 validationStatusObservable = new WritableValue(context | 98 validationStatusObservable = new WritableValue(context |
95 .getValidationRealm(), Status.OK_STATUS, IStatus.classinfo); | 99 .getValidationRealm(), cast(Object)Status.OK_STATUS, typeid(IStatus)); |
96 } | 100 } |
97 | 101 |
98 protected void postInit() { | 102 protected void postInit() { |
99 if (modelToTarget.getUpdatePolicy() is UpdateListStrategy.POLICY_UPDATE) { | 103 if (modelToTarget.getUpdatePolicy() is UpdateListStrategy.POLICY_UPDATE) { |
100 updateModelToTarget(); | 104 updateModelToTarget(); |
166 ListDiffEntry[] diffEntries = diff_.getDifferences(); | 170 ListDiffEntry[] diffEntries = diff_.getDifferences(); |
167 for (int i = 0; i < diffEntries.length; i++) { | 171 for (int i = 0; i < diffEntries.length; i++) { |
168 ListDiffEntry listDiffEntry = diffEntries[i]; | 172 ListDiffEntry listDiffEntry = diffEntries[i]; |
169 if (listDiffEntry.isAddition()) { | 173 if (listDiffEntry.isAddition()) { |
170 IStatus setterStatus = updateListStrategy_ | 174 IStatus setterStatus = updateListStrategy_ |
171 .doAdd( | 175 .doAdd_package( |
172 destination_, | 176 destination_, |
173 updateListStrategy_ | 177 updateListStrategy_ |
174 .convert(listDiffEntry | 178 .convert(listDiffEntry |
175 .getElement()), | 179 .getElement()), |
176 listDiffEntry.getPosition()); | 180 listDiffEntry.getPosition()); |
178 mergeStatus(multiStatus, setterStatus); | 182 mergeStatus(multiStatus, setterStatus); |
179 // TODO - at this point, the two lists | 183 // TODO - at this point, the two lists |
180 // will be out of sync if an error occurred... | 184 // will be out of sync if an error occurred... |
181 } else { | 185 } else { |
182 IStatus setterStatus = updateListStrategy_ | 186 IStatus setterStatus = updateListStrategy_ |
183 .doRemove(destination_, | 187 .doRemove_package(destination_, |
184 listDiffEntry.getPosition()); | 188 listDiffEntry.getPosition()); |
185 | 189 |
186 mergeStatus(multiStatus, setterStatus); | 190 mergeStatus(multiStatus, setterStatus); |
187 // TODO - at this point, the two lists | 191 // TODO - at this point, the two lists |
188 // will be out of sync if an error occurred... | 192 // will be out of sync if an error occurred... |