]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixed #238
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Mon, 29 Jan 2007 13:19:19 +0000 (13:19 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Mon, 29 Jan 2007 13:19:19 +0000 (13:19 +0000)
svn changeset:346/svn branch:toolkit

src/com/itmill/toolkit/terminal/web/ThemeFunctionLibrary.java

index 136bbe3cd4c5249d0ed251974ecc2d9850982de2..41b6e63d389f5288621411e8be653232bd911a2d 100644 (file)
@@ -40,6 +40,7 @@ import java.util.GregorianCalendar;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Set;
+import java.util.Vector;
 
 import javax.servlet.http.HttpSession;
 
@@ -440,16 +441,30 @@ public class ThemeFunctionLibrary {
        static public String getCssLinksForHead() {
                ApplicationServlet as = (ApplicationServlet) ((Object[]) state.get())[WEBADAPTERSERVLET];
                Theme t = as.getThemeSource().getThemeByName(theme());
-               Collection allFiles = t.getFileNames(browser(), Theme.MODE_HTML);
+
+               // Also iterate parent themes
+               Vector themes = new Vector();
+               themes.add(t);
+               while (t.getParent() != null) {
+                       String parentName = t.getParent();
+                       t = as.getThemeSource().getThemeByName(parentName);
+                       themes.add(t);
+               }
+
+               // Generate links
                StringBuffer links = new StringBuffer();
-               for (Iterator i = allFiles.iterator(); i.hasNext();) {
-                       String file = (String) i.next();
-                       if (file.endsWith(".css")) {
-                               links
-                                               .append("<LINK REL=\"STYLESHEET\" TYPE=\"text/css\" HREF=\""
-                                                               + resource(file) + "\"/>\n");
+               for (int k = themes.size() - 1; k >= 0; k--) {
+                       Collection allFiles = ((Theme)themes.get(k)).getFileNames(browser(), Theme.MODE_HTML);
+                       for (Iterator i = allFiles.iterator(); i.hasNext();) {
+                               String file = (String) i.next();
+                               if (file.endsWith(".css")) {
+                                       links
+                                                       .append("<LINK REL=\"STYLESHEET\" TYPE=\"text/css\" HREF=\""
+                                                                       + resource(file) + "\"/>\n");
+                               }
                        }
                }
+
                return links.toString();
        }
 
@@ -457,15 +472,30 @@ public class ThemeFunctionLibrary {
        static public String getJavaScriptLinksForHead() {
                ApplicationServlet as = (ApplicationServlet) ((Object[]) state.get())[WEBADAPTERSERVLET];
                Theme t = as.getThemeSource().getThemeByName(theme());
-               Collection allFiles = t.getFileNames(browser(), Theme.MODE_HTML);
+
+               // Also iterate parent themes
+               Vector themes = new Vector();
+               themes.add(t);
+               while (t.getParent() != null) {
+                       String parentName = t.getParent();
+                       t = as.getThemeSource().getThemeByName(parentName);
+                       themes.add(t);
+               }
+
+               // Generate links
                StringBuffer links = new StringBuffer();
-               for (Iterator i = allFiles.iterator(); i.hasNext();) {
-                       String file = (String) i.next();
-                       if (file.endsWith(".js")) {
-                               links.append("<SCRIPT LANGUAGE=\"Javascript\" SRC=\""
-                                               + resource(file) + "\"></SCRIPT>\n");
+               for (int k = themes.size() - 1; k >= 0; k--) {
+                       Collection allFiles = ((Theme) themes.get(k)).getFileNames(
+                                       browser(), Theme.MODE_HTML);
+                       for (Iterator i = allFiles.iterator(); i.hasNext();) {
+                               String file = (String) i.next();
+                               if (file.endsWith(".js")) {
+                                       links.append("<SCRIPT LANGUAGE=\"Javascript\" SRC=\""
+                                                       + resource(file) + "\"></SCRIPT>\n");
+                               }
                        }
                }
+
                return links.toString();
        }