summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2008-08-20 05:06:49 (EDT)
committerCarsten Drossel2008-08-20 05:06:49 (EDT)
commitd37de7cd21ccfe2e661567831ce1ef290222a547 (patch)
treeb7fffc23eb089449cac689262d1d55e50e7c55b8
parentbf017f5eb09375dbc36b47cc7f8b3c26f60d481a (diff)
downloadorg.eclipse.riena-d37de7cd21ccfe2e661567831ce1ef290222a547.zip
org.eclipse.riena-d37de7cd21ccfe2e661567831ce1ef290222a547.tar.gz
org.eclipse.riena-d37de7cd21ccfe2e661567831ce1ef290222a547.tar.bz2
fixed Bugzilla Bug 243983 (UnboundPropertyWritableList >> updateFromBean() triggers 2 changed events) by applying the changes suggested by Holger
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/TableRidgetTest.java13
-rw-r--r--org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/databinding/UnboundPropertyWritableList.java3
2 files changed, 14 insertions, 2 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/TableRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/TableRidgetTest.java
index e96c35b..4e9c2ca 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/TableRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/TableRidgetTest.java
@@ -11,9 +11,13 @@
package org.eclipse.riena.internal.ui.ridgets.swt;
import java.beans.PropertyChangeEvent;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.List;
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.riena.core.util.ReflectionUtils;
import org.eclipse.riena.tests.FTActionListener;
@@ -178,6 +182,13 @@ public class TableRidgetTest extends AbstractTableRidgetTest {
public void testUpdateFromModel() {
ITableRidget ridget = getRidget();
Table control = getUIControl();
+ final List<ChangeEvent> changeEvents = new ArrayList<ChangeEvent>();
+ IChangeListener listener = new IChangeListener() {
+ public void handleChange(ChangeEvent event) {
+ changeEvents.add(event);
+ }
+ };
+ ridget.getObservableList().addChangeListener(listener);
int oldCount = manager.getPersons().size();
@@ -191,12 +202,14 @@ public class TableRidgetTest extends AbstractTableRidgetTest {
assertEquals(newCount, manager.getPersons().size());
assertEquals(oldCount, ridget.getObservableList().size());
assertEquals(oldCount, control.getItemCount());
+ assertEquals(0, changeEvents.size());
ridget.updateFromModel();
assertEquals(newCount, manager.getPersons().size());
assertEquals(newCount, ridget.getObservableList().size());
assertEquals(newCount, control.getItemCount());
+ assertEquals(1, changeEvents.size());
}
public void testUpdateFromModelPreservesSelection() {
diff --git a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/databinding/UnboundPropertyWritableList.java b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/databinding/UnboundPropertyWritableList.java
index 4200069..a58d241 100644
--- a/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/databinding/UnboundPropertyWritableList.java
+++ b/org.eclipse.riena.ui.ridgets/src/org/eclipse/riena/ui/ridgets/databinding/UnboundPropertyWritableList.java
@@ -41,8 +41,7 @@ public class UnboundPropertyWritableList extends WritableList implements IUnboun
if (value == null) {
clear();
} else if (value instanceof Collection) {
- clear();
- addAll((Collection) value);
+ updateWrappedList(new ArrayList<Object>((Collection<?>) value));
} else {
throw new UIBindingFailure("The property '" + propertyDescriptor.getName() //$NON-NLS-1$
+ "'is not a java.util.Collection."); //$NON-NLS-1$