changeset 4063:8df61a4fc74c

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/scrum/controls/jfx/rt
author jgiles
date Mon, 24 Jun 2013 08:30:06 +1200
parents 8ac799e47aae 1925630fc297
children e0434ac66df4
files
diffstat 2 files changed, 11 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/javafx/scene/control/Control.java	Fri Jun 21 13:45:53 2013 -0400
+++ b/javafx-ui-controls/src/javafx/scene/control/Control.java	Mon Jun 24 08:30:06 2013 +1200
@@ -648,7 +648,7 @@
 
                     if (get() != null) {
                         if (!get().equals(currentSkinClassName)) {
-                            loadSkinClass();
+                            loadSkinClass(Control.this, skinClassName.get());
                         }
                         // Note: CSS should not set skin to null
                     }
@@ -674,12 +674,10 @@
         return skinClassName;
     }
 
-    private void loadSkinClass() {
-        if (skinClassName == null
-                || skinClassName.get() == null
-                || skinClassName.get().isEmpty()) {
+    static void loadSkinClass(final Skinnable control, final String skinClassName) {
+        if (skinClassName == null || skinClassName.isEmpty()) {
             final String msg =
-                "Empty -fx-skin property specified for control " + this;
+                "Empty -fx-skin property specified for control " + control;
             final List<CssError> errors = StyleManager.getErrors();
             if (errors != null) {
                 CssError error = new CssError(msg);
@@ -690,7 +688,7 @@
         }
 
         try {
-            final Class<?> skinClass = Control.loadClass(skinClassName.get(), this);
+            final Class<?> skinClass = Control.loadClass(skinClassName, control);
             Constructor<?>[] constructors = skinClass.getConstructors();
             Constructor<?> skinConstructor = null;
             for (Constructor<?> c : constructors) {
@@ -703,7 +701,7 @@
 
             if (skinConstructor == null) {
                 final String msg =
-                    "No valid constructor defined in '" + skinClassName + "' for control " + this +
+                    "No valid constructor defined in '" + skinClassName + "' for control " + control +
                         ".\r\nYou must provide a constructor that accepts a single "
                         + "Control parameter in " + skinClassName + ".";
                 final List<CssError> errors = StyleManager.getErrors();
@@ -713,14 +711,14 @@
                 }
                 Logging.getControlsLogger().severe(msg);
             } else {
-                Skin<?> skinInstance = (Skin<?>) skinConstructor.newInstance(this);
+                Skin<?> skinInstance = (Skin<?>) skinConstructor.newInstance(control);
                 // Do not call setSkin here since it has the side effect of
                 // also setting the skinClassName!
-                skinProperty().set(skinInstance);
+                control.skinProperty().set(skinInstance);
             }
         } catch (InvocationTargetException e) {
             final String msg =
-                "Failed to load skin '" + skinClassName + "' for control " + this;
+                "Failed to load skin '" + skinClassName + "' for control " + control;
             final List<CssError> errors = StyleManager.getErrors();
             if (errors != null) {
                 CssError error = new CssError(msg + " :" + e.getLocalizedMessage());
@@ -729,7 +727,7 @@
             Logging.getControlsLogger().severe(msg, e.getCause());
         } catch (Exception e) {
             final String msg =
-                "Failed to load skin '" + skinClassName + "' for control " + this;
+                "Failed to load skin '" + skinClassName + "' for control " + control;
             final List<CssError> errors = StyleManager.getErrors();
             if (errors != null) {
                 CssError error = new CssError(msg + " :" + e.getLocalizedMessage());
--- a/javafx-ui-controls/src/javafx/scene/control/PopupControl.java	Fri Jun 21 13:45:53 2013 -0400
+++ b/javafx-ui-controls/src/javafx/scene/control/PopupControl.java	Mon Jun 24 08:30:06 2013 +1200
@@ -25,8 +25,6 @@
 
 package javafx.scene.control;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -1165,7 +1163,7 @@
                         //
                         if (get() != null) {
                             if (!get().equals(currentSkinClassName)) {
-                                loadSkinClass();
+                                Control.loadSkinClass(PopupControl.this, skinClassName.get());
                             }
                         // CSS should not set skin to null
     //                    } else {
@@ -1197,76 +1195,6 @@
             skinClassNameProperty().set(skinClassName);
         }
 
-        private void loadSkinClass() {
-            if (skinClassName == null
-                || skinClassName.get() == null
-                || skinClassName.get().isEmpty()) {
-                final String msg =
-                    "Empty -fx-skin property specified for popup control " + this;
-                final List<CssError> errors = StyleManager.getErrors();
-                if (errors != null) {
-                    CssError error = new CssError(msg);
-                    errors.add(error); // RT-19884
-                }
-                Logging.getControlsLogger().severe(msg);
-                return;
-            }
-
-            try {
-                final Class<?> skinClass = Control.loadClass(skinClassName.get(), this);
-                Constructor<?>[] constructors = skinClass.getConstructors();
-                Constructor<?> skinConstructor = null;
-                for (Constructor<?> c : constructors) {
-                    Class<?>[] parameterTypes = c.getParameterTypes();
-                    if (parameterTypes.length == 1 && PopupControl.class.isAssignableFrom(parameterTypes[0])) {
-                        skinConstructor = c;
-                        break;
-                    }
-                }
-
-                if (skinConstructor == null) {
-                    final String msg =
-                        "No valid constructor defined in '" + skinClassName
-                        + "' for popup control " + this
-                        + ".\r\nYou must provide a constructor that accepts a single "
-                        + "PopupControl parameter in " + skinClassName + ".";
-                    final List<CssError> errors = StyleManager.getErrors();
-                    if (errors != null) {
-                        CssError error = new CssError(msg);
-                        errors.add(error); // RT-19884
-                    }
-                    Logging.getControlsLogger().severe(msg);
-                    return;
-                } else {
-                    Skin<?> skinInstance = (Skin<?>) skinConstructor.newInstance(PopupControl.this);
-                    // Do not call setSkin here since it has the side effect of
-                    // also setting the skinClassName!
-                    skinProperty().set(skinInstance);
-                }
-
-            } catch (InvocationTargetException e) {
-                final String msg =
-                    "Failed to load skin '" + skinClassName
-                    + "' for popup control " + this;
-                final List<CssError> errors = StyleManager.getErrors();
-                if (errors != null) {
-                    CssError error = new CssError(msg + " :" + e.getLocalizedMessage());
-                    errors.add(error); // RT-19884
-                }
-                Logging.getControlsLogger().severe(msg, e.getCause());
-            } catch (Exception e) {
-                final String msg =
-                    "Failed to load skin '" + skinClassName
-                    + "' for popup control " + this;
-                final List<CssError> errors = StyleManager.getErrors();
-                if (errors != null) {
-                    CssError error = new CssError(msg + " :" + e.getLocalizedMessage());
-                    errors.add(error); // RT-19884
-                }
-                Logging.getControlsLogger().severe(msg, e.getCause());
-            }
-        }
-
         /**
          * @treatAsPrivate implementation detail
          * @deprecated This is an internal API that is not intended for use and will be removed in the next version