changeset 9238:bb57a6602f51

8134934: Bindings.bindContent doesn't reflect the value changes in the ObservableMap
author vadim
date Wed, 02 Sep 2015 14:05:48 +0300
parents 7ea96ef06a69
children 59e8512b0e83
files modules/base/src/main/java/com/sun/javafx/binding/ContentBinding.java modules/base/src/test/java/test/com/sun/javafx/binding/ContentBindingListTest.java modules/base/src/test/java/test/com/sun/javafx/binding/ContentBindingMapTest.java
diffstat 3 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/base/src/main/java/com/sun/javafx/binding/ContentBinding.java	Tue Sep 01 17:06:15 2015 -0700
+++ b/modules/base/src/main/java/com/sun/javafx/binding/ContentBinding.java	Wed Sep 02 14:05:48 2015 +0300
@@ -221,7 +221,8 @@
             } else {
                 if (change.wasRemoved()) {
                     map.remove(change.getKey());
-                } else {
+                }
+                if (change.wasAdded()) {
                     map.put(change.getKey(), change.getValueAdded());
                 }
             }
--- a/modules/base/src/test/java/test/com/sun/javafx/binding/ContentBindingListTest.java	Tue Sep 01 17:06:15 2015 -0700
+++ b/modules/base/src/test/java/test/com/sun/javafx/binding/ContentBindingListTest.java	Wed Sep 02 14:05:48 2015 +0300
@@ -220,4 +220,12 @@
         // reset the exception handler
         Thread.currentThread().setUncaughtExceptionHandler(exceptionHandler);
     }
+
+    @Test
+    public void testChangeValue() {
+        Bindings.bindContent(op1, op2);
+        assertEquals(2, op1.get(0).intValue());
+        op2.set(0, 1);
+        assertEquals(1, op1.get(0).intValue());
+    }
 }
--- a/modules/base/src/test/java/test/com/sun/javafx/binding/ContentBindingMapTest.java	Tue Sep 01 17:06:15 2015 -0700
+++ b/modules/base/src/test/java/test/com/sun/javafx/binding/ContentBindingMapTest.java	Wed Sep 02 14:05:48 2015 +0300
@@ -207,4 +207,12 @@
         assertTrue(binding1.equals(binding1));
         assertFalse(binding1.equals(binding2));
     }
+
+    @Test
+    public void testChangeValue() {
+        Bindings.bindContent(op1, op2);
+        assertEquals(2, op1.get(key2_1).intValue());
+        op2.put(key2_1, 1);
+        assertEquals(1, op1.get(key2_1).intValue());
+    }
 }