You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/10/12 16:09:22 UTC

svn commit: r824344 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java

Author: tvolkert
Date: Mon Oct 12 14:09:22 2009
New Revision: 824344

URL: http://svn.apache.org/viewvc?rev=824344&view=rev
Log:
Added Theme.get(), Theme.set()

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java?rev=824344&r1=824343&r2=824344&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Theme.java Mon Oct 12 14:09:22 2009
@@ -61,6 +61,10 @@
     public static final String BOLD_KEY = "bold";
     public static final String ITALIC_KEY = "italic";
 
+    /**
+     * The service provider name with which the current theme will be determined
+     * (see {@link Service#getProvider(String) Service.getProvider()}).
+     */
     public static final String PROVIDER_NAME = "org.apache.pivot.wtk.Theme";
 
     static {
@@ -99,6 +103,54 @@
     public abstract Image getMessageIcon(MessageType messageType);
     public abstract Image getSmallMessageIcon(MessageType messageType);
 
+    /**
+     * Returns the skin class responsible for skinning the specified component
+     * class.
+     *
+     * @param componentClass
+     * The component class.
+     *
+     * @return
+     * The skin class, or <tt>null</tt> if no skin mapping exists for the
+     * component class.
+     */
+    public Class<? extends Skin> get(Class<? extends Component> componentClass) {
+        if (componentClass == null) {
+            throw new IllegalArgumentException("Component class is null.");
+        }
+
+        return componentSkinMap.get(componentClass);
+    }
+
+    /**
+     * Sets the skin class responsible for skinning the specified component
+     * class.
+     *
+     * @param componentClass
+     * The component class.
+     *
+     * @param skinClass
+     * The skin class.
+     */
+    public void set(Class<? extends Component> componentClass, Class<? extends Skin> skinClass) {
+        if (componentClass == null) {
+            throw new IllegalArgumentException("Component class is null.");
+        }
+
+        if (skinClass == null) {
+            throw new IllegalArgumentException("Skin class is null.");
+        }
+
+        componentSkinMap.put(componentClass, skinClass);
+    }
+
+    /**
+     * Gets the current theme, as determined by the {@linkplain #PROVIDER_NAME
+     * theme provider}.
+     *
+     * @throws IllegalStateException
+     * If a theme has not been installed.
+     */
     public static Theme getTheme() {
         if (theme == null) {
             throw new IllegalStateException("No installed theme.");