1 package org
.argeo
.cms
.util
;
4 import java
.util
.Enumeration
;
6 import org
.apache
.commons
.logging
.Log
;
7 import org
.apache
.commons
.logging
.LogFactory
;
8 import org
.eclipse
.rap
.rwt
.application
.Application
;
9 import org
.osgi
.framework
.Bundle
;
10 import org
.osgi
.framework
.BundleContext
;
12 public class ThemeUtils
{
13 final static Log log
= LogFactory
.getLog(ThemeUtils
.class);
15 public static Bundle
findThemeBundle(BundleContext bundleContext
, String themeId
) {
19 // TODO deal with multiple versions
20 Bundle themeBundle
= null;
21 if (themeId
!= null) {
22 for (Bundle bundle
: bundleContext
.getBundles())
23 if (themeId
.equals(bundle
.getSymbolicName())) {
31 public static void addThemeResources(Application application
, Bundle themeBundle
, BundleResourceLoader themeBRL
,
33 Enumeration
<URL
> themeResources
= themeBundle
.findEntries("/", pattern
, true);
34 if (themeResources
== null)
36 while (themeResources
.hasMoreElements()) {
37 String resource
= themeResources
.nextElement().getPath();
38 // remove first '/' so that RWT registers it
39 resource
= resource
.substring(1);
40 if (!resource
.endsWith("/")) {
41 application
.addResource(resource
, themeBRL
);
42 if (log
.isTraceEnabled())
43 log
.trace("Registered " + resource
+ " from theme " + themeBundle
);