diff options
author | Ovidio Mallo | 2010-04-25 18:03:40 +0000 |
---|---|---|
committer | Ovidio Mallo | 2010-04-25 18:03:40 +0000 |
commit | 3108d9aef70c6316acc9258200b195c87a736c5d (patch) | |
tree | 99fe02e5cc61f736fc35e7a4be1acbcc7c140049 | |
parent | 44880922792616474fbf1fda5b9f32d242ce99ed (diff) | |
download | org.eclipse.e4.databinding-3108d9aef70c6316acc9258200b195c87a736c5d.tar.gz org.eclipse.e4.databinding-3108d9aef70c6316acc9258200b195c87a736c5d.tar.xz org.eclipse.e4.databinding-3108d9aef70c6316acc9258200b195c87a736c5d.zip |
REOPENED - bug 301774: [DataBinding] <List|Set|Map>Diff.simulateOn(List|Set|Map)v20100517v20100427I20100527-0800I20100526-1400I20100520-0800aI20100520-0800I20100517-1500I20100513-0800bisI20100513-0800I20100513-0500I20100512-1930I20100512-1500I20100511-0800I20100509-0800I20100428-1300I20100426-0800I20100425-1800
https://bugs.eclipse.org/bugs/show_bug.cgi?id=301774
6 files changed, 89 insertions, 4 deletions
diff --git a/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/list/SimpleListProperty.java b/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/list/SimpleListProperty.java index 9b3b88b1..d3731aa7 100644 --- a/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/list/SimpleListProperty.java +++ b/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/list/SimpleListProperty.java @@ -8,10 +8,12 @@ * Contributors: * Matthew Hall - initial API and implementation (bug 194734) * Matthew Hall - bugs 195222, 247997, 265561 + * Ovidio Mallo - bug 301774 ******************************************************************************/ package org.eclipse.core.databinding.property.list; +import java.util.ArrayList; import java.util.List; import org.eclipse.core.databinding.observable.Diffs; @@ -87,7 +89,8 @@ public abstract class SimpleListProperty extends ListProperty { } protected void doUpdateList(Object source, ListDiff diff) { - List list = diff.simulateOn(doGetList(source)); + List list = new ArrayList(doGetList(source)); + diff.applyTo(list); doSetList(source, list, diff); } diff --git a/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/map/SimpleMapProperty.java b/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/map/SimpleMapProperty.java index 021ee914..6046537e 100644 --- a/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/map/SimpleMapProperty.java +++ b/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/map/SimpleMapProperty.java @@ -8,10 +8,12 @@ * Contributors: * Matthew Hall - initial API and implementation * Matthew Hall - bugs 195222, 247997, 265561 + * Ovidio Mallo - bug 301774 ******************************************************************************/ package org.eclipse.core.databinding.property.map; +import java.util.HashMap; import java.util.Map; import org.eclipse.core.databinding.observable.Diffs; @@ -87,7 +89,8 @@ public abstract class SimpleMapProperty extends MapProperty { } protected void doUpdateMap(Object source, MapDiff diff) { - Map map = diff.simulateOn(doGetMap(source)); + Map map = new HashMap(doGetMap(source)); + diff.applyTo(map); doSetMap(source, map, diff); } diff --git a/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/set/SimpleSetProperty.java b/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/set/SimpleSetProperty.java index 087a3175..7e316a05 100644 --- a/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/set/SimpleSetProperty.java +++ b/bundles/org.eclipse.core.databinding.property/src/org/eclipse/core/databinding/property/set/SimpleSetProperty.java @@ -8,10 +8,12 @@ * Contributors: * Matthew Hall - initial API and implementation * Matthew Hall - bugs 195222, 247997, 265561 + * Ovidio Mallo - bug 301774 ******************************************************************************/ package org.eclipse.core.databinding.property.set; +import java.util.HashSet; import java.util.Set; import org.eclipse.core.databinding.observable.Diffs; @@ -86,7 +88,8 @@ public abstract class SimpleSetProperty extends SetProperty { } protected void doUpdateSet(Object source, SetDiff diff) { - Set set = diff.simulateOn(doGetSet(source)); + Set set = new HashSet(doGetSet(source)); + diff.applyTo(set); doSetSet(source, set, diff); } diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableListTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableListTest.java index 2cd27581..fa96516c 100644 --- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableListTest.java +++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableListTest.java @@ -8,6 +8,7 @@ * Contributors: * Brad Reynolds - initial API and implementation * Matthew Hall - bugs 221351, 213145, 244098, 246103, 194734, 268688 + * Ovidio Mallo - bug 301774 ******************************************************************************/ package org.eclipse.core.tests.internal.databinding.beans; @@ -560,6 +561,30 @@ public class JavaBeanObservableListTest extends AbstractDefaultRealmTestCase { .singletonList("element")); } + /** + * Makes sure that the list set on the Bean model after changing the + * observable list is modifiable (see bugs 285307 and 301774). + */ + public void testUpdatedBeanListIsModifiable() { + Bean bean = new Bean(new ArrayList()); + IObservableList observable = BeansObservables.observeList(bean, "list"); + + observable.add(new Object()); + bean.getList().clear(); + } + + /** + * Makes sure that the list set on the Pojo model after changing the + * observable list is modifiable (see bugs 285307 and 301774). + */ + public void testUpdatedPojoListIsModifiable() { + Bean bean = new Bean(new ArrayList()); + IObservableList observable = PojoObservables.observeList(bean, "list"); + + observable.add(new Object()); + bean.getList().clear(); + } + private static void assertDiff(ListDiff diff, List oldList, List newList) { oldList = new ArrayList(oldList); // defensive copy in case arg is // unmodifiable diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableSetTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableSetTest.java index 128672fa..60ab20df 100644 --- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableSetTest.java +++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanObservableSetTest.java @@ -8,12 +8,13 @@ * Contributors: * Brad Reynolds - initial API and implementation * Matthew Hall - bugs 221351, 213145, 244098, 246103, 194734, 268688 - * Ovidio Mallo - bug 247741 + * Ovidio Mallo - bugs 247741, 301774 ******************************************************************************/ package org.eclipse.core.tests.internal.databinding.beans; import java.beans.PropertyDescriptor; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -175,6 +176,30 @@ public class JavaBeanObservableSetTest extends AbstractDefaultRealmTestCase { .singleton("element")); } + /** + * Makes sure that the set set on the Bean model after changing the + * observable set is modifiable (see bugs 285307 and 301774). + */ + public void testUpdatedBeanSetIsModifiable() { + Bean bean = new Bean(new ArrayList()); + IObservableSet observable = BeansObservables.observeSet(bean, "set"); + + observable.add(new Object()); + bean.getSet().clear(); + } + + /** + * Makes sure that the set set on the Pojo model after changing the + * observable set is modifiable (see bugs 285307 and 301774). + */ + public void testUpdatedPojoSetIsModifiable() { + Bean bean = new Bean(new ArrayList()); + IObservableSet observable = PojoObservables.observeSet(bean, "set"); + + observable.add(new Object()); + bean.getSet().clear(); + } + private static void assertDiff(SetDiff diff, Set oldSet, Set newSet) { oldSet = new HashSet(oldSet); // defensive copy in case arg is // unmodifiable diff --git a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanPropertyObservableMapTest.java b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanPropertyObservableMapTest.java index bcd98996..6fffceb8 100644 --- a/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanPropertyObservableMapTest.java +++ b/tests/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/internal/databinding/beans/JavaBeanPropertyObservableMapTest.java @@ -7,13 +7,16 @@ * * Contributors: * Matthew Hall - initial API and implementation (bug 246103) + * Ovidio Mallo - bug 301774 ******************************************************************************/ package org.eclipse.core.tests.internal.databinding.beans; +import java.util.ArrayList; import java.util.Collections; import org.eclipse.core.databinding.beans.BeansObservables; +import org.eclipse.core.databinding.beans.PojoObservables; import org.eclipse.core.databinding.observable.map.IObservableMap; import org.eclipse.jface.databinding.conformance.util.CurrentRealm; import org.eclipse.jface.databinding.conformance.util.MapChangeEventTracker; @@ -53,4 +56,27 @@ public class JavaBeanPropertyObservableMapTest extends assertEquals("new", tracker.event.diff.getNewValue("key")); } + /** + * Makes sure that the map set on the Bean model after changing the + * observable map is modifiable (see bugs 285307 and 301774). + */ + public void testUpdatedBeanMapIsModifiable() { + Bean bean = new Bean(new ArrayList()); + IObservableMap observable = BeansObservables.observeMap(bean, "map"); + + observable.put(new Object(), new Object()); + bean.getMap().clear(); + } + + /** + * Makes sure that the map set on the Pojo model after changing the + * observable map is modifiable (see bugs 285307 and 301774). + */ + public void testUpdatedPojoMapIsModifiable() { + Bean bean = new Bean(new ArrayList()); + IObservableMap observable = PojoObservables.observeMap(bean, "map"); + + observable.put(new Object(), new Object()); + bean.getMap().clear(); + } } |