import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
// favicon
if (properties.containsKey(WebClient.FAVICON)) {
String themeId = defaultBranding.get(WebClient.THEME_ID);
- Bundle themeBundle = findThemeBundle(themeId);
+ Bundle themeBundle = ThemeUtils.findThemeBundle(bundleContext, themeId);
String faviconRelPath = properties.get(WebClient.FAVICON);
application.addResource(faviconRelPath,
new BundleResourceLoader(themeBundle != null ? themeBundle : bundleContext.getBundle()));
// stylesheets and themes
Set<Bundle> themeBundles = new HashSet<>();
for (String themeId : styleSheets.keySet()) {
- Bundle themeBundle = findThemeBundle(themeId);
+ Bundle themeBundle = ThemeUtils.findThemeBundle(bundleContext, themeId);
StyleSheetResourceLoader styleSheetRL = new StyleSheetResourceLoader(
themeBundle != null ? themeBundle : bundleContext.getBundle());
if (themeBundle != null)
}
for (Bundle themeBundle : themeBundles) {
BundleResourceLoader themeBRL = new BundleResourceLoader(themeBundle);
- addThemeResources(application, themeBundle, themeBRL, "*.png");
- addThemeResources(application, themeBundle, themeBRL, "*.gif");
- addThemeResources(application, themeBundle, themeBRL, "*.jpg");
+ ThemeUtils.addThemeResources(application, themeBundle, themeBRL, "*.png");
+ ThemeUtils.addThemeResources(application, themeBundle, themeBRL, "*.gif");
+ ThemeUtils.addThemeResources(application, themeBundle, themeBRL, "*.jpg");
}
} catch (RuntimeException e) {
// Easier access to initialisation errors
}
}
- private Bundle findThemeBundle(String themeId) {
- if (themeId == null)
- return null;
- // TODO optimize
- // TODO deal with multiple versions
- Bundle themeBundle = null;
- if (themeId != null) {
- for (Bundle bundle : bundleContext.getBundles())
- if (themeId.equals(bundle.getSymbolicName())) {
- themeBundle = bundle;
- break;
- }
- }
- return themeBundle;
- }
-
- private void addThemeResources(Application application, Bundle themeBundle, BundleResourceLoader themeBRL,
- String pattern) {
- Enumeration<URL> themeResources = themeBundle.findEntries("/", pattern, true);
- if (themeResources == null)
- return;
- while (themeResources.hasMoreElements()) {
- String resource = themeResources.nextElement().getPath();
- // remove first '/' so that RWT registers it
- resource = resource.substring(1);
- if (!resource.endsWith("/")) {
- application.addResource(resource, themeBRL);
- if (log.isTraceEnabled())
- log.trace("Registered " + resource + " from theme " + themeBundle);
- }
-
- }
-
- }
-
public void init() throws RepositoryException {
Session session = null;
try {