You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2010/08/12 03:08:52 UTC

svn commit: r984624 - /pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java

Author: smartini
Date: Thu Aug 12 01:08:52 2010
New Revision: 984624

URL: http://svn.apache.org/viewvc?rev=984624&view=rev
Log:
fixed custom colors loading, handling a relative case (for stock colors files), and absolute for others.
Also improved error reporting in case of file not found etc

Modified:
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java?rev=984624&r1=984623&r2=984624&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTheme.java Thu Aug 12 01:08:52 2010
@@ -178,7 +178,16 @@ public final class TerraTheme extends Th
             load(getClass().getResource("TerraTheme_default.json"));
         } else {
             ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-            load(classLoader.getResource(location.substring(1)));
+            String locationResource;
+            if (location.startsWith("/"))
+                locationResource = location.substring(1);
+            else
+                locationResource = packageName.replace('.', '/') + "/" + location;
+            URL locationURL = classLoader.getResource(locationResource);
+            if (locationURL == null) {
+                System.err.println("Unable to retrieve startup TerraTheme colors: \"" + locationResource + "\"");
+            }
+            load(locationURL);
         }
 
         // Install named styles
@@ -204,6 +213,10 @@ public final class TerraTheme extends Th
 
     @SuppressWarnings("unchecked")
     private void load(URL location) {
+        if (location == null) {
+            throw new IllegalArgumentException("location URL is null");
+        }
+
         try {
             InputStream inputStream = location.openStream();