changeset 1678:067f7a7ea26e

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/scrum/controls/jfx/rt
author jgiles
date Wed, 22 Aug 2012 12:31:43 +1200
parents b5f7b25bbc50 1ab808f50c5b
children b44a67205213
files
diffstat 14 files changed, 573 insertions(+), 87 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/com/sun/javafx/css/CompoundSelector.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/CompoundSelector.java	Wed Aug 22 12:31:43 2012 +1200
@@ -341,5 +341,61 @@
         }
         return new CompoundSelector(selectors, relationships);
     }
+    
+    @Override public String writeJava() {
+        final String NEW_LINE = Rule.NEW_LINE;
+        final String INDENT = Rule.INDENT;
+        final String TWO_INDENT = Rule.TWO_INDENT;
+        final String FIVE_INDENT = TWO_INDENT + TWO_INDENT + INDENT;
+        
+        StringBuilder sb = new StringBuilder();
+        sb.append(NEW_LINE);
+        sb.append(TWO_INDENT);
+        sb.append(TWO_INDENT);
+        sb.append("new CompoundSelector(");
+        sb.append(NEW_LINE);
+        
+        sb.append(FIVE_INDENT);
+        sb.append("Arrays.<SimpleSelector>asList(");
+        sb.append(NEW_LINE);
+        
+        for (int i = 0; i < selectors.size(); i++) {
+            Selector sel = selectors.get(i);
+            
+            sb.append(INDENT);
+            sb.append(FIVE_INDENT);
+            sb.append(sel.writeJava());
+            
+            if (i < (selectors.size() - 1)) {
+                sb.append(", ");
+                sb.append(NEW_LINE);
+            }
+        }
+        
+        sb.append("), ");
+        
+        sb.append(NEW_LINE);
+        sb.append(FIVE_INDENT);
+        sb.append("Arrays.<Combinator>asList(");
+        sb.append(NEW_LINE);
+        
+        for (int i = 0; i < relationships.size(); i++) {
+            Combinator com = relationships.get(i);
+            
+            sb.append(INDENT);
+            sb.append(FIVE_INDENT);
+            sb.append("Combinator.");
+            sb.append(com.name());
+            
+            if (i < (relationships.size() - 1)) {
+                sb.append(", ");
+                sb.append(NEW_LINE);
+            }
+        }
+        
+        sb.append("))");
+        
+        return sb.toString();
+    }
 }
 
--- a/javafx-ui-common/src/com/sun/javafx/css/Declaration.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/Declaration.java	Wed Aug 22 12:31:43 2012 +1200
@@ -124,5 +124,18 @@
         final boolean important = is.readBoolean();
         return new Declaration(propertyName, parsedValue, important);
     }
+    
+    public String writeJava() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("new Declaration(\"");
+        sb.append(getProperty());
+        sb.append("\", ");
+        sb.append(getParsedValue().writeJava());
+        sb.append(", ");
+        sb.append(isImportant());
+        sb.append(")"); 
+        
+        return sb.toString();
+    }
 }
 
--- a/javafx-ui-common/src/com/sun/javafx/css/ParentStyleManager.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/ParentStyleManager.java	Wed Aug 22 12:31:43 2012 +1200
@@ -121,8 +121,8 @@
                 // If an exception occurred while loading one of the stylesheets
                 // then we will simply print warning into system.err and skip the
                 // stylesheet, allowing other stylesheets to attempt to load
-                if (LOGGER.isLoggable(PlatformLogger.WARNING)) {
-                    LOGGER.warning("Cannot add stylesheet. %s\n", e.getLocalizedMessage());
+                if (getLogger().isLoggable(PlatformLogger.WARNING)) {
+                    getLogger().warning("Cannot add stylesheet. %s\n", e.getLocalizedMessage());
                 }
 
             }
--- a/javafx-ui-common/src/com/sun/javafx/css/ParsedValue.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/ParsedValue.java	Wed Aug 22 12:31:43 2012 +1200
@@ -698,4 +698,117 @@
         }
     }
 
+    public String writeJava() {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append("new ParsedValue("); 
+
+        // ---- Value
+        if (value instanceof ParsedValue) {
+            sb.append(((ParsedValue)value).writeJava());
+        } else if (value instanceof ParsedValue[]) {
+            final ParsedValue[] values = (ParsedValue[])value;
+            sb.append("new ParsedValue[] {");
+            
+            for (int v=0; v<values.length; v++) {
+                if (values[v] != null) {
+                    sb.append(((ParsedValue)values[v]).writeJava());
+                } else {
+                    sb.append("null");
+                }
+                
+                if (v < (values.length - 1)) {
+                    sb.append(", ");
+                }
+            }
+            
+            sb.append("}");
+        } else if (value instanceof ParsedValue[][]) {
+            final ParsedValue[][] layers = (ParsedValue[][])value;
+            sb.append("new ParsedValue[][] {");
+            
+            for (int l=0; l<layers.length; l++) {
+                final ParsedValue[] values = layers[l];
+                sb.append("new ParsedValue[] {");
+                
+                for (int v=0; v<values.length; v++) {
+                    if (values[v] != null) {
+                        sb.append(((ParsedValue)values[v]).writeJava());
+                    } else {
+                        sb.append("null");
+                    }
+                    
+                    if (v < (values.length - 1)) {
+                        sb.append(", ");
+                    }
+                }
+                
+                sb.append("}");
+            }
+            
+            sb.append("}");
+        } else if (value instanceof Color) {
+            final Color c = (Color)value;
+            sb.append("new Color(");
+            sb.append(c.getRed());
+            sb.append(", ");
+            sb.append(c.getGreen());
+            sb.append(", ");
+            sb.append(c.getBlue());
+            sb.append(", ");
+            sb.append(c.getOpacity());
+            sb.append(")");
+        } else if (value instanceof Enum) {
+            final Enum e = (Enum)value;
+            sb.append(e.getClass().getName());
+            sb.append(".");
+            sb.append(e);
+        } else if (value instanceof Boolean) {
+            final Boolean b = (Boolean)value;
+            sb.append(b);
+        } else if (value instanceof Size) {
+            final Size size = (Size)value;
+            final double sz = size.getValue();
+            sb.append("new Size(");
+            sb.append(sz);
+            sb.append(", SizeUnits.");
+            sb.append(size.getUnits().name());
+            sb.append(")");
+        } else if (value instanceof String) {
+            String str = (String)value;
+            if (! str.startsWith("\"")) sb.append("\"");
+            sb.append(str);
+            if (! str.endsWith("\"")) sb.append("\"");
+        } else if (value instanceof URL) {
+            URL url = (URL)value;
+            String urlString = url.toString();
+            
+            // convert all escaped slashes (\\) into \, and then convert all
+            // backslashes into escaped versions.
+            urlString = urlString.replace("\\\\", "\\");
+            urlString = urlString.replace("\\", "\\\\");
+            
+            sb.append("\"");
+            sb.append(urlString);
+            sb.append("\"");
+        } else if (value == null) {
+            sb.append("null");
+        } else {
+            throw new InternalError("cannot writeJava " + this);
+        }
+        
+        // --- Style Converter
+        sb.append(", ");
+        String styleConverterString = getConverter() == null ? "null" : getConverter().writeJava();
+        sb.append(styleConverterString);
+        
+        // --- IsLookup
+        sb.append(", ");
+        sb.append(isLookup());
+        
+        // close ParsedValue constructor
+        sb.append(")"); 
+        
+        return sb.toString();
+    }
 }
--- a/javafx-ui-common/src/com/sun/javafx/css/Rule.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/Rule.java	Wed Aug 22 12:31:43 2012 +1200
@@ -29,6 +29,7 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import javafx.collections.ListChangeListener.Change;
 import javafx.collections.ObservableList;
@@ -53,11 +54,17 @@
         protected void onChanged(Change<Declaration> c) {
             while (c.next()) {
                 if (c.wasAdded()) {
-                    for(Declaration decl : c.getAddedSubList()) {
+                    List<Declaration> added = c.getAddedSubList();
+                    for(int i = 0, max = added.size(); i < max; i++) {
+                        Declaration decl = added.get(i);
                         decl.rule = Rule.this;
                     }
-                } else if (c.wasRemoved()) {
-                    for(Declaration decl : c.getRemoved()) {
+                }
+                
+                if (c.wasRemoved()) {
+                    List<Declaration> removed = c.getRemoved();
+                    for(int i = 0, max = removed.size(); i < max; i++) {
+                        Declaration decl = removed.get(i);
                         if (decl.rule == Rule.this) decl.rule = null;
                     }
                 }
@@ -193,4 +200,48 @@
         return new Rule(selectors, declarations);
     }
 
+    public static final String NEW_LINE = "\r\n";
+    public static final String INDENT = "    ";
+    public static final String TWO_INDENT = "        ";
+    
+    String writeJava() throws IOException {
+        final String THREE_INDENT = INDENT + TWO_INDENT;
+        final String FOUR_INDENT = TWO_INDENT + TWO_INDENT;
+        
+        StringBuilder sb = new StringBuilder();
+        sb.append("new Rule(");
+        sb.append(NEW_LINE);
+        
+        // selectors
+        sb.append(THREE_INDENT);
+        sb.append("Arrays.<Selector>asList(");
+        for (int i = 0; i < selectors.size(); i++) {
+            Selector sel = selectors.get(i);
+            sb.append(sel.writeJava());
+            
+            if (i < (selectors.size() - 1)) {
+                sb.append(", ");
+            }
+        }
+        sb.append("), ");
+        
+        // declarations
+        sb.append(NEW_LINE);
+        sb.append(THREE_INDENT);
+        sb.append("Arrays.<Declaration>asList(");
+        for (int i = 0; i < declarations.size(); i++) {
+            Declaration decl = declarations.get(i);
+            
+            sb.append(NEW_LINE);
+            sb.append(FOUR_INDENT);
+            sb.append(decl.writeJava());
+            
+            if (i < (declarations.size() - 1)) {
+                sb.append(", ");
+            }
+        }
+        sb.append("))");
+        
+        return sb.toString();
+    }
 }
--- a/javafx-ui-common/src/com/sun/javafx/css/SceneStyleManager.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/SceneStyleManager.java	Wed Aug 22 12:31:43 2012 +1200
@@ -228,8 +228,8 @@
                     // If an exception occurred while loading one of the stylesheets
                     // then we will simply print warning into system.err and skip the
                     // stylesheet, allowing other stylesheets to attempt to load
-                    if (LOGGER.isLoggable(PlatformLogger.WARNING)) {
-                        LOGGER.warning("Cannot add stylesheet. %s\n", e.getLocalizedMessage());
+                    if (getLogger().isLoggable(PlatformLogger.WARNING)) {
+                        getLogger().warning("Cannot add stylesheet. %s\n", e.getLocalizedMessage());
                     }
                     // no telling what condition stylesheet is in. make it null
                     stylesheet = null;
--- a/javafx-ui-common/src/com/sun/javafx/css/Selector.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/Selector.java	Wed Aug 22 12:31:43 2012 +1200
@@ -93,6 +93,8 @@
         else
             return CompoundSelector.readBinary(is,strings);
     }
+    
+    protected abstract String writeJava();
 
     public static Selector createSelector(final String cssSelector) {
         if (cssSelector == null || cssSelector.length() == 0) {
--- a/javafx-ui-common/src/com/sun/javafx/css/SimpleSelector.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/SimpleSelector.java	Wed Aug 22 12:31:43 2012 +1200
@@ -362,4 +362,53 @@
         }
         return new SimpleSelector(name, styleClasses, pseudoclasses, id);
     }
+
+    @Override public String writeJava() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("new SimpleSelector(\"");
+        sb.append(getName());
+        sb.append("\", ");
+        
+        // styleclasses
+        if (getStyleClasses().isEmpty()) {
+            sb.append("null");
+        } else {
+            sb.append("Arrays.<String>asList(");
+            for (int i = 0, max = getStyleClasses().size(); i < max; i++) {
+                sb.append("\"");
+                sb.append(getStyleClasses().get(i));
+                sb.append("\"");
+
+                if (i < (max - 1)) {
+                    sb.append(", ");
+                }
+            }
+            sb.append(")");
+        }
+        
+        sb.append(", ");
+        
+        // pseudoclasses
+        if (getPseudoclasses().isEmpty()) {
+            sb.append("null");
+        } else {
+            sb.append("Arrays.<String>asList(");
+            for (int i = 0, max = getPseudoclasses().size(); i < max; i++) {
+                sb.append("\"");
+                sb.append(getPseudoclasses().get(i));
+                sb.append("\"");
+
+                if (i < (max - 1)) {
+                    sb.append(", ");
+                }
+            }
+            sb.append(")");
+        }
+        
+        sb.append(", \"");
+        sb.append(getId());
+        sb.append("\")");
+        
+        return sb.toString();
+    }
 }
--- a/javafx-ui-common/src/com/sun/javafx/css/StyleConverter.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/StyleConverter.java	Wed Aug 22 12:31:43 2012 +1200
@@ -122,124 +122,128 @@
         }
         return tmap.get(cname);
     }
+    
+    public String writeJava() {
+        return getClass().getCanonicalName() + ".getInstance()";
+    }
 
 
     // package for unit test purposes
-    static StyleConverter getInstance(final Class converterClass) {
+    public static StyleConverter getInstance(final Class converterClass) {
 
         StyleConverter styleConverter = null;
         // TODO: giant if-then-else block
-        if (com.sun.javafx.css.StyleConverter.class.equals(converterClass)) {
+        if (com.sun.javafx.css.StyleConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.StyleConverter.getInstance();
 
-        } else if (com.sun.javafx.css.converters.BooleanConverter.class.equals(converterClass)) {
+        } else if (com.sun.javafx.css.converters.BooleanConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.BooleanConverter.getInstance();
 
-        } else if (com.sun.javafx.css.converters.ColorConverter.class.equals(converterClass)) {
+        } else if (com.sun.javafx.css.converters.ColorConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.ColorConverter.getInstance();
 
-        } else if (com.sun.javafx.css.converters.CursorConverter.class.equals(converterClass)) {
+        } else if (com.sun.javafx.css.converters.CursorConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.CursorConverter.getInstance();
 
-        } else if (com.sun.javafx.css.converters.EffectConverter.class.equals(converterClass)) {
+        } else if (com.sun.javafx.css.converters.EffectConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.EffectConverter.getInstance();
-        } else if (com.sun.javafx.css.converters.EffectConverter.DropShadowConverter.class.equals(converterClass)) {
+        } else if (com.sun.javafx.css.converters.EffectConverter.DropShadowConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.EffectConverter.DropShadowConverter.getInstance();
-        } else if (com.sun.javafx.css.converters.EffectConverter.InnerShadowConverter.class.equals(converterClass)) {
+        } else if (com.sun.javafx.css.converters.EffectConverter.InnerShadowConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.EffectConverter.InnerShadowConverter.getInstance();
 
         // enum is handled differently
 
-        } else if (com.sun.javafx.css.converters.FontConverter.class.equals(converterClass)) {
+        } else if (com.sun.javafx.css.converters.FontConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.FontConverter.getInstance();
-        } else if (com.sun.javafx.css.converters.FontConverter.StyleConverter.class.equals(converterClass)) {
+        } else if (com.sun.javafx.css.converters.FontConverter.StyleConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.FontConverter.StyleConverter.getInstance();
-        } else if (com.sun.javafx.css.converters.FontConverter.WeightConverter.class.equals(converterClass)) {
+        } else if (com.sun.javafx.css.converters.FontConverter.WeightConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.FontConverter.WeightConverter.getInstance();
-        } else if (com.sun.javafx.css.converters.FontConverter.SizeConverter.class.equals(converterClass)) {
+        } else if (com.sun.javafx.css.converters.FontConverter.SizeConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.FontConverter.SizeConverter.getInstance();
 
-        }  else if (com.sun.javafx.css.converters.InsetsConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.InsetsConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.InsetsConverter.getInstance();
-        }  else if (com.sun.javafx.css.converters.InsetsConverter.SequenceConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.InsetsConverter.SequenceConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.InsetsConverter.SequenceConverter.getInstance();
 
-        }  else if (com.sun.javafx.css.converters.PaintConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.PaintConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.PaintConverter.getInstance();
-        }  else if (com.sun.javafx.css.converters.PaintConverter.SequenceConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.PaintConverter.SequenceConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.PaintConverter.SequenceConverter.getInstance();
-        }  else if (com.sun.javafx.css.converters.PaintConverter.LinearGradientConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.PaintConverter.LinearGradientConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.PaintConverter.LinearGradientConverter.getInstance();
-        }  else if (com.sun.javafx.css.converters.PaintConverter.RadialGradientConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.PaintConverter.RadialGradientConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.PaintConverter.RadialGradientConverter.getInstance();
 
-        }  else if (com.sun.javafx.css.converters.SizeConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.SizeConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.SizeConverter.getInstance();
-        }  else if (com.sun.javafx.css.converters.SizeConverter.SequenceConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.SizeConverter.SequenceConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.SizeConverter.SequenceConverter.getInstance();
 
-        }  else if (com.sun.javafx.css.converters.StringConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.StringConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.StringConverter.getInstance();
-        }  else if (com.sun.javafx.css.converters.StringConverter.SequenceConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.StringConverter.SequenceConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.StringConverter.SequenceConverter.getInstance();
 
-        }  else if (com.sun.javafx.css.converters.URLConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.URLConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.URLConverter.getInstance();
-        }  else if (com.sun.javafx.css.converters.URLConverter.SequenceConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.converters.URLConverter.SequenceConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.converters.URLConverter.SequenceConverter.getInstance();
 
         // Region stuff
-        }  else if (com.sun.javafx.scene.layout.region.BackgroundFillConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.BackgroundFillConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.BackgroundFillConverter.getInstance();
 
-        }  else if (com.sun.javafx.scene.layout.region.BackgroundImageConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.BackgroundImageConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.BackgroundImageConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.BackgroundImage.BackgroundPositionConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.BackgroundImage.BackgroundPositionConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.BackgroundImage.BackgroundPositionConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.BackgroundImage.BackgroundRepeatConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.BackgroundImage.BackgroundRepeatConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.BackgroundImage.BackgroundRepeatConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.BackgroundImage.BackgroundSizeConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.BackgroundImage.BackgroundSizeConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.BackgroundImage.BackgroundSizeConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.BackgroundImage.LayeredBackgroundPositionConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.BackgroundImage.LayeredBackgroundPositionConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.BackgroundImage.LayeredBackgroundPositionConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.BackgroundImage.LayeredBackgroundSizeConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.BackgroundImage.LayeredBackgroundSizeConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.BackgroundImage.LayeredBackgroundSizeConverter.getInstance();
 
-        }  else if (com.sun.javafx.scene.layout.region.BorderImageConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.BorderImageConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.BorderImageConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.BorderImage.RepeatConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.BorderImage.RepeatConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.BorderImage.RepeatConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.BorderImage.SliceConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.BorderImage.SliceConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.BorderImage.SliceConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.BorderImage.SliceSequenceConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.BorderImage.SliceSequenceConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.BorderImage.SliceSequenceConverter.getInstance();
 
-        }  else if (com.sun.javafx.scene.layout.region.StrokeBorderConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.StrokeBorderConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.StrokeBorderConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.StrokeBorder.BorderPaintConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.StrokeBorder.BorderPaintConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.StrokeBorder.BorderPaintConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.StrokeBorder.BorderStyleConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.StrokeBorder.BorderStyleConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.StrokeBorder.BorderStyleConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.StrokeBorder.BorderStyleSequenceConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.StrokeBorder.BorderStyleSequenceConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.StrokeBorder.BorderStyleSequenceConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.StrokeBorder.LayeredBorderPaintConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.StrokeBorder.LayeredBorderPaintConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.StrokeBorder.LayeredBorderPaintConverter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.StrokeBorder.LayeredBorderStyleConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.StrokeBorder.LayeredBorderStyleConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.StrokeBorder.LayeredBorderStyleConverter.getInstance();
 
-        }  else if (com.sun.javafx.scene.layout.region.Margins.Converter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.Margins.Converter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.Margins.Converter.getInstance();
-        }  else if (com.sun.javafx.scene.layout.region.Margins.SequenceConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.scene.layout.region.Margins.SequenceConverter.class == converterClass) {
             styleConverter = com.sun.javafx.scene.layout.region.Margins.SequenceConverter.getInstance();
 
         // parser stuff
-        }  else if (com.sun.javafx.css.parser.DeriveColorConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.parser.DeriveColorConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.parser.DeriveColorConverter.getInstance();
-        }  else if (com.sun.javafx.css.parser.DeriveSizeConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.parser.DeriveSizeConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.parser.DeriveSizeConverter.getInstance();
-        }  else if (com.sun.javafx.css.parser.LadderConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.parser.LadderConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.parser.LadderConverter.getInstance();
-        }  else if (com.sun.javafx.css.parser.StopConverter.class.equals(converterClass)) {
+        }  else if (com.sun.javafx.css.parser.StopConverter.class == converterClass) {
             styleConverter = com.sun.javafx.css.parser.StopConverter.getInstance();
         }
 
--- a/javafx-ui-common/src/com/sun/javafx/css/StyleManager.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/StyleManager.java	Wed Aug 22 12:31:43 2012 +1200
@@ -106,7 +106,13 @@
 
 abstract public class StyleManager<T> {
 
-    protected final static PlatformLogger LOGGER = com.sun.javafx.Logging.getCSSLogger();
+    private static PlatformLogger LOGGER;
+    protected static PlatformLogger getLogger() {
+        if (LOGGER == null) {
+            LOGGER = com.sun.javafx.Logging.getCSSLogger();
+        }
+        return LOGGER;
+    }
 
     /**
      * Return the StyleManager for the given Scene, or null if the scene
@@ -339,8 +345,8 @@
         try {
             return loadStylesheetUnPrivileged(fname);
         } catch (java.security.AccessControlException ace) {
-            if (LOGGER.isLoggable(PlatformLogger.INFO)) {
-                LOGGER.info("Could not load the stylesheet, trying with FilePermissions : " + fname);
+            if (getLogger().isLoggable(PlatformLogger.INFO)) {
+                getLogger().info("Could not load the stylesheet, trying with FilePermissions : " + fname);
             }
 
             /*
@@ -522,8 +528,8 @@
                         );
                     errors.add(error);
                 }
-                if (LOGGER.isLoggable(PlatformLogger.WARNING)) {
-                    LOGGER.warning(
+                if (getLogger().isLoggable(PlatformLogger.WARNING)) {
+                    getLogger().warning(
                         String.format("Resource \"%s\" not found.", fname)
                     );
                 }
@@ -538,8 +544,8 @@
                     );
                 errors.add(error);
             }
-            if (LOGGER.isLoggable(PlatformLogger.INFO)) {
-                LOGGER.info("Could not find stylesheet: " + fname);//, fnfe);
+            if (getLogger().isLoggable(PlatformLogger.INFO)) {
+                getLogger().info("Could not find stylesheet: " + fname);//, fnfe);
             }
         } catch (IOException ioe) {
                 if (errors != null) {
@@ -549,8 +555,8 @@
                         );
                     errors.add(error);
                 }
-            if (LOGGER.isLoggable(PlatformLogger.INFO)) {
-                LOGGER.info("Could not load stylesheet: " + fname);//, ioe);
+            if (getLogger().isLoggable(PlatformLogger.INFO)) {
+                getLogger().info("Could not load stylesheet: " + fname);//, ioe);
             }
         }
         return null;
--- a/javafx-ui-common/src/com/sun/javafx/css/Stylesheet.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-common/src/com/sun/javafx/css/Stylesheet.java	Wed Aug 22 12:31:43 2012 +1200
@@ -26,12 +26,7 @@
 package com.sun.javafx.css;
 
 import com.sun.javafx.collections.TrackableObservableList;
-import java.io.BufferedInputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
@@ -53,7 +48,7 @@
  * {@link #reapply}.
  *
  */
-final public class Stylesheet {
+public class Stylesheet {
 
     public enum Origin {
         USER_AGENT,
@@ -189,7 +184,7 @@
         os.writeShort(rules.size());
         for (Rule r : rules) r.writeBinary(os,stringStore);
     }
-
+    
     // protected for unit testing 
     /** @treatAsPrivate public to allow unit testing */
     public void readBinary(DataInputStream is, String[] strings)
@@ -255,7 +250,93 @@
         // return stylesheet
         return stylesheet;
     }
+    
+    public void writeJava(final PrintWriter writer, String className) throws IOException {
+        final String NEW_LINE = Rule.NEW_LINE;
+        final String INDENT = Rule.INDENT;
+        final String TWO_INDENT = Rule.TWO_INDENT;
+        
+        final int RULES_PER_METHOD = 50;
+        final int NUMBER_OF_METHODS = (rules.size() / RULES_PER_METHOD);
+
+        writer.write("import com.sun.javafx.css.*;" + NEW_LINE);
+        writer.write("import com.sun.javafx.css.parser.*;" + NEW_LINE);
+        writer.write("import java.util.*;" + NEW_LINE);
+        writer.write("import javafx.scene.paint.*;" + NEW_LINE);
+        
+        writer.write(NEW_LINE);
+        writer.write("public class " + className + " extends Stylesheet {");
+        writer.write(NEW_LINE);
+        writer.write(NEW_LINE);
+        
+        writer.write(INDENT);
+        writer.write("public ");
+        writer.write(className);
+        writer.write("() {");
+        writer.write(NEW_LINE);
+        
+        writer.write(TWO_INDENT);
+        writer.write("final List<Rule> rules = getRules();");
+        writer.write(NEW_LINE);
+        
+        for (int i = 0, max = NUMBER_OF_METHODS; i <= max; i++) {
+            writer.write(TWO_INDENT);
+            writer.write("loadRules");
+            writer.write(i+"");
+            writer.write("(rules);");
+            writer.write(NEW_LINE);
+        }
+        
+        // close the constructor
+        writer.write(INDENT);
+        writer.write("}");
+        writer.write(NEW_LINE);
+        writer.write(NEW_LINE);
+        
+        // get all the rules strings
+        String[] rulesStrings = new String[rules.size()];
+        for (int j = 0; j < rules.size(); j++) {
+            Rule r = rules.get(j);
+            rulesStrings[j] = r.writeJava();
+        }
+        
+        // write out methods
+        for (int i = 0; i <= NUMBER_OF_METHODS; i++) {
+            writer.write(INDENT);
+            writer.write("private final void loadRules");
+            writer.write(i+"");
+            writer.write("(final List<Rule> rules) {");
+            writer.write(NEW_LINE);
+            
+            writer.write(TWO_INDENT);
+            writer.write("Collections.addAll(rules, ");
+            writer.write(NEW_LINE);
+            
+            for (int j = 0; j < RULES_PER_METHOD; j++) {
+                int pos = i * RULES_PER_METHOD + j;
+                if (pos == rulesStrings.length) break;
+                
+                writer.write(TWO_INDENT);
+                writer.write(rulesStrings[pos]);
+                
+                if ((j < RULES_PER_METHOD - 1) && (pos < (rulesStrings.length - 1))) {
+                    writer.write(", ");
+                    writer.write(NEW_LINE);
+                }
+            }
+            
+            writer.write(NEW_LINE);
+            writer.write(TWO_INDENT);
+            writer.write(");");
+            
+            writer.write(NEW_LINE);
+            writer.write(INDENT);
+            writer.write("}");
+            writer.write(NEW_LINE);
+            writer.write(NEW_LINE);
+        }
+        
+        // close class
+        writer.write("}");
+    }
 }
-
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/javafx-ui-common/src/com/sun/javafx/css/parser/Css2Java.java	Wed Aug 22 12:31:43 2012 +1200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.javafx.css.parser;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import com.sun.javafx.css.Stylesheet;
+import java.io.*;
+
+/** Css2Java <input file> [<package name> <output file name>]
+ * java -classpath <sdk desktop lib path>/javafx-ui-common.jar com.sun.javafx.css.parser.Css2Java input.css full.package.name output.java
+ *  If no output file is given, then the input file name is used with an extension of 'java'
+ */
+public class Css2Java {
+    public static void main(String args[]) throws Exception {
+        
+        if ( args.length < 1) throw new IllegalArgumentException("expected <input file> [<package name> <output file name>] as arguments");
+
+        try {
+            String ifname = args[0];
+            String packageName = (args.length > 1 ? args[1] : null);
+            String ofname = (args.length > 2) ?
+                args[2] : ifname.substring(0, ifname.lastIndexOf('.')+1).concat("java");
+            
+            convertToJava(ifname, ofname, packageName);
+        } catch (Exception e) {
+            System.err.println(e.toString());
+            e.printStackTrace(System.err);
+            System.exit(-1);
+        } 
+    }
+
+    public static void convertToJava(String ifname, String ofname, String packageName) throws IOException {
+        final URL urlIn = new java.net.URL("file", null, ifname);
+
+        CSSParser.EXIT_ON_ERROR = true;
+        Stylesheet stylesheet = CSSParser.getInstance().parse(urlIn);
+
+        File outFile = new File(ofname);
+        PrintWriter writer = new PrintWriter(outFile);
+        
+        if (packageName != null && ! packageName.isEmpty()) {
+            writer.write("package ");
+            writer.write(packageName);
+            writer.write(";");
+            writer.write("\r\n\r\n");
+        }
+        
+        String className = outFile.getName();
+        className = className.substring(0, className.indexOf("."));
+        stylesheet.writeJava(writer, className);
+        writer.flush();
+        writer.close();
+    }
+}
--- a/javafx-ui-controls/build-common.xml	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-controls/build-common.xml	Wed Aug 22 12:31:43 2012 +1200
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project name="javafx-ui-controls-common" default="jar" basedir=".">
 
+    <!-- .css -> .bss -->
     <target name="check-binary-css">
         <uptodate property="binaryCssUpToDate" targetfile="${build.dir}/classes/com/sun/javafx/scene/control/skin/caspian/caspian.bss">
             <srcfiles dir="${src.dir}/com/sun/javafx/scene/control/skin/caspian" includes="caspian.css"/>
@@ -23,7 +24,33 @@
           <arg value="${build.dir}/classes/com/sun/javafx/scene/control/skin/caspian/caspian.bss"/>
         </java>
     </target>
-
+    
+    <!-- .css -> .java -->
+    <target name="check-java-css">
+        <uptodate property="javaCssUpToDate" targetfile="${build.dir}/classes/com/sun/javafx/scene/control/skin/caspian/caspian.java">
+            <srcfiles dir="${src.dir}/com/sun/javafx/scene/control/skin/caspian" includes="caspian.css"/>
+        </uptodate>
+    </target> 
+    
+    <target name="-pre-init" depends="check-java-css" unless="javaCssUpToDate">
+        <mkdir dir="${build.dir}/classes/com/sun/javafx/scene/control/skin/caspian"/>
+        <java classname="com.sun.javafx.css.parser.Css2Java" fork="true" failonerror="true">
+          <jvmarg value="-Djavafx.toolkit=com.sun.javafx.tk.DummyToolkit"/>
+          <classpath> 
+            <pathelement location="${rt.dist.root.dir}/javafx-ui-common/dist/javafx-ui-common.jar"/>
+            <pathelement location="${runtime.dist.root.dir}/javafx-beans/dist/javafx-beans.jar"/>
+            <pathelement location="${runtime.dist.root.dir}/javafx-anim/dist/javafx-anim.jar"/>
+            <pathelement location="${runtime.dist.root.dir}/javafx-common/dist/javafx-common.jar"/>
+            <pathelement location="${runtime.dist.root.dir}/javafx-logging/dist/javafx-logging.jar"/>
+            <pathelement location="${JFXRT_HOME}/jfxrt.jar"/>
+          </classpath> 
+          <arg value="${src.dir}/com/sun/javafx/scene/control/skin/caspian/caspian.css"/>
+          <arg value="com.sun.javafx.scene.control.skin.caspian"/>
+          <arg value="${build.dir}/classes/com/sun/javafx/scene/control/skin/caspian/Caspian.java"/>
+        </java>
+    </target>
+    
+    <!-- misc -->
     <target name="debug-test-file" depends="jar">
         <echo message="${run.test.classpath}" />
         <debug-selected-file-in-test/>
--- a/javafx-ui-controls/src/javafx/scene/control/UAStylesheetLoader.java	Tue Aug 21 13:49:53 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/UAStylesheetLoader.java	Wed Aug 22 12:31:43 2012 +1200
@@ -26,6 +26,7 @@
 
 import com.sun.javafx.css.StyleManager;
 import com.sun.javafx.scene.control.skin.LabelSkin;
+import com.sun.javafx.scene.control.skin.caspian.Caspian;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -58,20 +59,24 @@
             AccessController.doPrivileged(new PrivilegedAction() {
                 @Override
                 public Object run() {
-                        URL url = LabelSkin.class.getResource("caspian/caspian.css");
-                        StyleManager.setDefaultUserAgentStylesheet(url.toExternalForm());
+                    // Old approach:
+                    URL caspianUrl = LabelSkin.class.getResource("caspian/caspian.css");
+                    StyleManager.addUserAgentStylesheet(caspianUrl.toExternalForm());
+                    
+                    // New approach:
+//                    StyleManager.setDefaultUserAgentStylesheet(new Caspian());
                         
-                        if (com.sun.javafx.PlatformUtil.isEmbedded()) {
-                            url = LabelSkin.class.getResource("caspian/embedded.css");
-                            StyleManager.addUserAgentStylesheet(url.toExternalForm());
-                            
-                            if (com.sun.javafx.Utils.isQVGAScreen()) {
-                                url = LabelSkin.class.getResource("caspian/embedded-qvga.css");
-                                StyleManager.addUserAgentStylesheet(url.toExternalForm());
-                            }
+                    if (com.sun.javafx.PlatformUtil.isEmbedded()) {
+                        URL embeddedUrl = LabelSkin.class.getResource("caspian/embedded.css");
+                        StyleManager.addUserAgentStylesheet(embeddedUrl.toExternalForm());
+
+                        if (com.sun.javafx.Utils.isQVGAScreen()) {
+                            URL qvgaUrl = LabelSkin.class.getResource("caspian/embedded-qvga.css");
+                            StyleManager.addUserAgentStylesheet(qvgaUrl.toExternalForm());
                         }
-                        
-                        stylesheetLoaded = true;
+                    }
+
+                    stylesheetLoaded = true;
                     return null;
                 }
             });