37 import javafx.beans.property.ObjectProperty;
38 import javafx.beans.property.ObjectPropertyBase;
39 import javafx.beans.property.SimpleObjectProperty;
40 import javafx.beans.property.StringProperty;
41 import javafx.beans.value.WritableValue;
42 import javafx.collections.ObservableList;
43 import javafx.css.CssParser;
44 import javafx.event.EventHandler;
45 import javafx.scene.AccessibleAction;
46 import javafx.scene.AccessibleAttribute;
47 import javafx.scene.Node;
48 import javafx.scene.input.ContextMenuEvent;
49 import javafx.scene.layout.Region;
50 import com.sun.javafx.application.PlatformImpl;
51 import javafx.css.CssMetaData;
52 import com.sun.javafx.css.StyleManager;
53 import javafx.css.StyleableObjectProperty;
54 import javafx.css.StyleableStringProperty;
55 import javafx.css.converter.StringConverter;
56 import com.sun.javafx.scene.control.Logging;
57 import com.sun.javafx.scene.control.ModuleHelper;
58 import javafx.css.Styleable;
59 import javafx.css.StyleableProperty;
60 import sun.util.logging.PlatformLogger;
61 import sun.util.logging.PlatformLogger.Level;
62
63
64 /**
65 * Base class for all user interface controls. A "Control" is a node in the
66 * scene graph which can be manipulated by the user. Controls provide
67 * additional variables and behaviors beyond those of Node to support
68 * common user interactions in a manner which is consistent and predictable
69 * for the user.
70 * <p>
71 * Additionally, controls support explicit skinning to make it easy to
72 * leverage the functionality of a control while customizing its appearance.
73 * <p>
74 * See specific Control subclasses for information on how to use individual
75 * types of controls.
76 * <p> Most controls have their focusTraversable property set to true by default, however
77 * read-only controls such as {@link Label} and {@link ProgressIndicator}, and some
685 };
686 }
687 return skinClassName;
688 }
689
690 static void loadSkinClass(final Skinnable control, final String skinClassName) {
691 if (skinClassName == null || skinClassName.isEmpty()) {
692 final String msg =
693 "Empty -fx-skin property specified for control " + control;
694 final List<CssParser.ParseError> errors = StyleManager.getErrors();
695 if (errors != null) {
696 CssParser.ParseError error = new CssParser.ParseError(msg);
697 errors.add(error); // RT-19884
698 }
699 Logging.getControlsLogger().severe(msg);
700 return;
701 }
702
703 try {
704 final Class<?> skinClass = Control.loadClass(skinClassName, control);
705 Object skinModule = ModuleHelper.getModule(skinClass);
706 Object thisModule = ModuleHelper.getModule(Control.class);
707 if (skinModule != thisModule) {
708 ModuleHelper.addReads(thisModule, skinModule);
709 }
710 Constructor<?>[] constructors = skinClass.getConstructors();
711 Constructor<?> skinConstructor = null;
712 for (Constructor<?> c : constructors) {
713 Class<?>[] parameterTypes = c.getParameterTypes();
714 if (parameterTypes.length == 1 && Skinnable.class.isAssignableFrom(parameterTypes[0])) {
715 skinConstructor = c;
716 break;
717 }
718 }
719
720 if (skinConstructor == null) {
721 final String msg =
722 "No valid constructor defined in '" + skinClassName + "' for control " + control +
723 ".\r\nYou must provide a constructor that accepts a single "
724 + "Skinnable (e.g. Control or PopupControl) parameter in " + skinClassName + ".";
725 final List<CssParser.ParseError> errors = StyleManager.getErrors();
726 if (errors != null) {
727 CssParser.ParseError error = new CssParser.ParseError(msg);
728 errors.add(error); // RT-19884
729 }
|
37 import javafx.beans.property.ObjectProperty;
38 import javafx.beans.property.ObjectPropertyBase;
39 import javafx.beans.property.SimpleObjectProperty;
40 import javafx.beans.property.StringProperty;
41 import javafx.beans.value.WritableValue;
42 import javafx.collections.ObservableList;
43 import javafx.css.CssParser;
44 import javafx.event.EventHandler;
45 import javafx.scene.AccessibleAction;
46 import javafx.scene.AccessibleAttribute;
47 import javafx.scene.Node;
48 import javafx.scene.input.ContextMenuEvent;
49 import javafx.scene.layout.Region;
50 import com.sun.javafx.application.PlatformImpl;
51 import javafx.css.CssMetaData;
52 import com.sun.javafx.css.StyleManager;
53 import javafx.css.StyleableObjectProperty;
54 import javafx.css.StyleableStringProperty;
55 import javafx.css.converter.StringConverter;
56 import com.sun.javafx.scene.control.Logging;
57 import javafx.css.Styleable;
58 import javafx.css.StyleableProperty;
59 import sun.util.logging.PlatformLogger;
60 import sun.util.logging.PlatformLogger.Level;
61
62
63 /**
64 * Base class for all user interface controls. A "Control" is a node in the
65 * scene graph which can be manipulated by the user. Controls provide
66 * additional variables and behaviors beyond those of Node to support
67 * common user interactions in a manner which is consistent and predictable
68 * for the user.
69 * <p>
70 * Additionally, controls support explicit skinning to make it easy to
71 * leverage the functionality of a control while customizing its appearance.
72 * <p>
73 * See specific Control subclasses for information on how to use individual
74 * types of controls.
75 * <p> Most controls have their focusTraversable property set to true by default, however
76 * read-only controls such as {@link Label} and {@link ProgressIndicator}, and some
684 };
685 }
686 return skinClassName;
687 }
688
689 static void loadSkinClass(final Skinnable control, final String skinClassName) {
690 if (skinClassName == null || skinClassName.isEmpty()) {
691 final String msg =
692 "Empty -fx-skin property specified for control " + control;
693 final List<CssParser.ParseError> errors = StyleManager.getErrors();
694 if (errors != null) {
695 CssParser.ParseError error = new CssParser.ParseError(msg);
696 errors.add(error); // RT-19884
697 }
698 Logging.getControlsLogger().severe(msg);
699 return;
700 }
701
702 try {
703 final Class<?> skinClass = Control.loadClass(skinClassName, control);
704 Constructor<?>[] constructors = skinClass.getConstructors();
705 Constructor<?> skinConstructor = null;
706 for (Constructor<?> c : constructors) {
707 Class<?>[] parameterTypes = c.getParameterTypes();
708 if (parameterTypes.length == 1 && Skinnable.class.isAssignableFrom(parameterTypes[0])) {
709 skinConstructor = c;
710 break;
711 }
712 }
713
714 if (skinConstructor == null) {
715 final String msg =
716 "No valid constructor defined in '" + skinClassName + "' for control " + control +
717 ".\r\nYou must provide a constructor that accepts a single "
718 + "Skinnable (e.g. Control or PopupControl) parameter in " + skinClassName + ".";
719 final List<CssParser.ParseError> errors = StyleManager.getErrors();
720 if (errors != null) {
721 CssParser.ParseError error = new CssParser.ParseError(msg);
722 errors.add(error); // RT-19884
723 }
|