changeset 6502:96ca9d80b159

RT-24086: disallow uni-directional bind on currentPageIndex
author David Grieve<david.grieve@oracle.com>
date Wed, 19 Mar 2014 16:19:50 -0400
parents 4dc1ba8b86ee
children 9940be2f94f3
files modules/controls/src/main/java/javafx/scene/control/Pagination.java modules/controls/src/test/java/javafx/scene/control/PaginationTest.java
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/javafx/scene/control/Pagination.java	Wed Mar 19 16:19:50 2014 -0400
+++ b/modules/controls/src/main/java/javafx/scene/control/Pagination.java	Wed Mar 19 16:19:50 2014 -0400
@@ -33,6 +33,7 @@
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleIntegerProperty;
 import javafx.beans.property.SimpleObjectProperty;
+import javafx.beans.value.ObservableValue;
 import javafx.css.CssMetaData;
 import javafx.css.StyleableIntegerProperty;
 import javafx.css.Styleable;
@@ -255,6 +256,11 @@
                 accSendNotification(Attribute.SELECTED_PAGE);
             }
         }
+
+        @Override
+        public void bind(ObservableValue<? extends Number> rawObservable) {
+            throw new UnsupportedOperationException("currentPageIndex supports only bidirectional binding");
+        }
     };
 
     /**
@@ -274,6 +280,12 @@
      * will be the current page if the value is greater than the {@link #pageCount}
      *
      * The default is 0 for the first page.
+     * <p>
+     * Because the page indicators set the current page index, the currentPageIndex property permits only
+     * bidirectional binding.
+     * The {@link javafx.beans.property.IntegerProperty#bind(javafx.beans.value.ObservableValue) bind} method
+     * throws an UnsupportedOperationException.
+     * </p>
      */
     public final IntegerProperty currentPageIndexProperty() { return currentPageIndex; }
 
--- a/modules/controls/src/test/java/javafx/scene/control/PaginationTest.java	Wed Mar 19 16:19:50 2014 -0400
+++ b/modules/controls/src/test/java/javafx/scene/control/PaginationTest.java	Wed Mar 19 16:19:50 2014 -0400
@@ -115,12 +115,9 @@
         assertEquals("number of visible pages cannot be bound", pagination.maxPageIndicatorCountProperty().getValue(), 105, 0);
     }
 
-    @Test public void checkPageIndexPropertyBind() {
+    @Test(expected = java.lang.UnsupportedOperationException.class) public void checkPageIndexPropertyBind() {
         IntegerProperty intPr = new SimpleIntegerProperty(10);
         pagination.currentPageIndexProperty().bind(intPr);
-        assertEquals("page index cannot be bound", pagination.currentPageIndexProperty().getValue(), 10, 0);
-        intPr.setValue(20);
-        assertEquals("page index cannot be bound", pagination.currentPageIndexProperty().getValue(), 20, 0);
     }
 
     @Test public void checkPageFactoryPropertyBind() {