changeset 1385:2d7d2be9cdb7

RT-22928: ClassCastException in TilePane while using the CSS style -fx-pref-columns
author Kinsley Wong
date Thu, 28 Jun 2012 14:45:48 -0700
parents 29a0e209d81f
children feb33f9ce89b
files javafx-ui-common/src/javafx/scene/layout/TilePane.java javafx-ui-common/test/unit/javafx/scene/layout/TilePaneTest.java
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/layout/TilePane.java	Fri Jun 29 09:43:49 2012 +1200
+++ b/javafx-ui-common/src/javafx/scene/layout/TilePane.java	Thu Jun 28 14:45:48 2012 -0700
@@ -918,6 +918,10 @@
              new StyleableProperty<TilePane,Number>("-fx-pref-columns",
                  SizeConverter.getInstance(), 5.0) {
 
+            @Override public void set(TilePane node, Number value, Origin origin) {
+                super.set(node, value.intValue(), origin);
+            }
+            
             @Override
             public boolean isSettable(TilePane node) {
                 return node.prefColumns == null ||
--- a/javafx-ui-common/test/unit/javafx/scene/layout/TilePaneTest.java	Fri Jun 29 09:43:49 2012 +1200
+++ b/javafx-ui-common/test/unit/javafx/scene/layout/TilePaneTest.java	Thu Jun 28 14:45:48 2012 -0700
@@ -950,4 +950,22 @@
             Assert.fail(e.toString());
         }
     }    
+    
+      
+    @Test public void testCSSsetPrefColumns_RT22929() {        
+        Scene scene = new Scene(tilepane);
+        Stage stage = new Stage();
+        stage.setScene(scene);                
+        stage.show();
+        
+        ParsedValue pv = CSSParser.getInstance().parseExpr("-fx-pref-columns","2");
+        Object val = pv.convert(null);        
+        StyleableProperty prop = StyleableProperty.getStyleableProperty(tilepane.prefColumnsProperty());
+        try {
+            prop.set(tilepane, val, null);
+            assertEquals(2, tilepane.getPrefColumns(), 0.00001);
+        } catch (Exception e) {
+            Assert.fail(e.toString());
+        }
+    }      
 }