changeset 6431:8cc4b8c100f7

RT-36105 [Charts] PieChart.Data NodeProperty Reviewed by: kcr, snorthov
author Martin Sladecek <martin.sladecek@oracle.com>
date Thu, 06 Mar 2014 09:13:21 +0100
parents 964e022be8dc
children a92f0e3fb4d1
files modules/controls/src/main/java/javafx/scene/chart/PieChart.java modules/controls/src/test/java/javafx/scene/chart/PieChartTest.java
diffstat 2 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/javafx/scene/chart/PieChart.java	Thu Mar 06 08:12:36 2014 +0100
+++ b/modules/controls/src/main/java/javafx/scene/chart/PieChart.java	Thu Mar 06 09:13:21 2014 +0100
@@ -932,7 +932,7 @@
         /**
          * Readonly access to the node that represents the pie slice. You can use this to add mouse event listeners etc.
          */
-        private ObjectProperty<Node> node = new SimpleObjectProperty<Node>(this, "node");
+        private ReadOnlyObjectWrapper<Node> node = new ReadOnlyObjectWrapper<>(this, "node");
 
         /**
          * Returns the node that represents the pie slice. You can use this to
@@ -946,8 +946,8 @@
             node.setValue(value);
         }
 
-        private ObjectProperty<Node> nodeProperty() {
-            return node;
+        public ReadOnlyObjectProperty<Node> nodeProperty() {
+            return node.getReadOnlyProperty();
         }
 
         // -------------- CONSTRUCTOR -------------------------------------------------
--- a/modules/controls/src/test/java/javafx/scene/chart/PieChartTest.java	Thu Mar 06 08:12:36 2014 +0100
+++ b/modules/controls/src/test/java/javafx/scene/chart/PieChartTest.java	Thu Mar 06 09:13:21 2014 +0100
@@ -25,6 +25,7 @@
 
 package javafx.scene.chart;
 
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javafx.collections.FXCollections;
@@ -32,7 +33,7 @@
 import javafx.scene.Node;
 import javafx.scene.text.Text;
 import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  *
@@ -99,5 +100,17 @@
         pc.getData().remove(0);
         assertEquals(4, pc.getData().size());
     }
+
+
+    @Test
+    public void testDataNodeChangeReported() {
+        AtomicBoolean called = new AtomicBoolean();
+
+        PieChart.Data data = new PieChart.Data("ABC", 40);
+        data.nodeProperty().addListener((o) -> called.set(true));
+        pc.getData().add(data);
+
+        assertTrue(called.get());
+    }
     
 }