changeset 6218:16dde7ae7840

RT-34832: check for null parameters in formatExceptionMessage
author David Grieve<david.grieve@oracle.com>
date Thu, 30 Jan 2014 16:31:31 -0500
parents beba988d1c25
children 214fddde54f6
files modules/controls/src/main/java/javafx/scene/control/Labeled.java modules/graphics/src/main/java/javafx/scene/CssStyleHelper.java modules/graphics/src/test/java/com/sun/javafx/css/Node_cssStyleMap_Test.java
diffstat 3 files changed, 41 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/javafx/scene/control/Labeled.java	Thu Jan 30 16:31:01 2014 -0500
+++ b/modules/controls/src/main/java/javafx/scene/control/Labeled.java	Thu Jan 30 16:31:31 2014 -0500
@@ -130,7 +130,7 @@
      */
     public Labeled(String text, Node graphic) {
         setText(text);
-        setGraphic(graphic);
+        ((StyleableProperty<Node>)graphicProperty()).applyStyle(null, graphic);
     }
 
     /***************************************************************************
@@ -471,11 +471,22 @@
                 protected void invalidated() {
 
                     // need to call super.get() here since get() is overridden to return the graphicProperty's value
-                    String url = super.get();
+                    final String url = super.get();
 
                     if (url == null) {
                         ((StyleableProperty)graphicProperty()).applyStyle(origin, null);
                     } else {
+                        // RT-34466 - if graphic's url is the same as this property's value, then don't overwrite.
+                        final Node graphicNode = Labeled.this.getGraphic();
+                        if (graphicNode instanceof ImageView) {
+                            final ImageView imageView = (ImageView)graphicNode;
+                            final Image image = imageView.getImage();
+                            if (image != null) {
+                                final String imageViewUrl = image.impl_getUrl();
+                                if (url.equals(imageViewUrl)) return;
+                            }
+
+                        }
 
                         final Image img = StyleManager.getInstance().getCachedImage(url);
 
--- a/modules/graphics/src/main/java/javafx/scene/CssStyleHelper.java	Thu Jan 30 16:31:01 2014 -0500
+++ b/modules/graphics/src/main/java/javafx/scene/CssStyleHelper.java	Thu Jan 30 16:31:31 2014 -0500
@@ -1316,22 +1316,33 @@
 
         StringBuilder sbuf = new StringBuilder();
         sbuf.append("Caught ")
-            .append(e.toString())
-            .append("'")
-            .append(" while calculating value for '")
-            .append(cssMetaData.getProperty())
-            .append("'");
+            .append(String.valueOf(e));
 
-        final Rule rule = style != null ? style.getDeclaration().getRule(): null;
-        final Stylesheet stylesheet = rule != null ? rule.getStylesheet() : null;
-        final String url = stylesheet != null ? stylesheet.getUrl() : null;
-        if (url != null) {
-            sbuf.append(" from rule '")
-                .append(style.getSelector())
-                .append("' in stylesheet ").append(url);
-        } else if (stylesheet != null && StyleOrigin.INLINE == stylesheet.getOrigin()) {
-            sbuf.append(" from inline style on " )
-                .append(styleable.toString());
+        if (cssMetaData != null) {
+            sbuf.append("'")
+                .append(" while calculating value for '")
+                .append(cssMetaData.getProperty())
+                .append("'");
+        }
+
+        if (style != null) {
+
+            final Rule rule = style.getDeclaration().getRule();
+            final Stylesheet stylesheet = rule != null ? rule.getStylesheet() : null;
+            final String url = stylesheet != null ? stylesheet.getUrl() : null;
+
+            if (url != null) {
+                sbuf.append(" from rule '")
+                        .append(style.getSelector())
+                        .append("' in stylesheet ").append(url);
+            } else if (styleable != null && stylesheet != null && StyleOrigin.INLINE == stylesheet.getOrigin()) {
+                sbuf.append(" from inline style on " )
+                        .append(styleable.toString());
+            } else {
+                sbuf.append(" from style '")
+                    .append(String.valueOf(style))
+                    .append("'");
+            }
         }
 
         return sbuf.toString();
--- a/modules/graphics/src/test/java/com/sun/javafx/css/Node_cssStyleMap_Test.java	Thu Jan 30 16:31:01 2014 -0500
+++ b/modules/graphics/src/test/java/com/sun/javafx/css/Node_cssStyleMap_Test.java	Thu Jan 30 16:31:31 2014 -0500
@@ -99,7 +99,7 @@
         return smap;
     }
     
-    @Test @Ignore ("Pending RT-34463")
+    @Test //@Ignore ("Pending RT-34463")
     public void testStyleMapTracksChanges() {
                 
         final List<Declaration> declsNoState = new ArrayList<Declaration>();
@@ -204,7 +204,7 @@
         
     }
     
-    @Test @Ignore ("Pending RT-34463")
+    @Test //@Ignore ("Pending RT-34463")
     public void testRT_21212() {
 
         final List<Declaration> rootDecls = new ArrayList<Declaration>();