X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Futil%2FStyleSheetResourceLoader.java;h=1df98d484963d7fad233283aff31a4e4972fc5e9;hb=c811008ac91053f068c26f48427617de9bb7b79c;hp=a7e3b6e846ef6a93e85114aae26ee62f316205f8;hpb=e299bf6123fb27d14176d2a164a85971be40fa2a;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.ui/src/org/argeo/cms/util/StyleSheetResourceLoader.java b/org.argeo.cms.ui/src/org/argeo/cms/util/StyleSheetResourceLoader.java index a7e3b6e84..1df98d484 100644 --- a/org.argeo.cms.ui/src/org/argeo/cms/util/StyleSheetResourceLoader.java +++ b/org.argeo.cms.ui/src/org/argeo/cms/util/StyleSheetResourceLoader.java @@ -12,24 +12,21 @@ import org.apache.commons.io.IOUtils; import org.argeo.cms.CmsException; import org.eclipse.rap.rwt.service.ResourceLoader; import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; /** {@link ResourceLoader} caching stylesheets. */ -public class StyleSheetResourceLoader implements ResourceLoader { - private final BundleContext bundleContext; - +class StyleSheetResourceLoader implements ResourceLoader { + private Bundle themeBundle; private Map stylesheets = new LinkedHashMap(); - public StyleSheetResourceLoader(BundleContext bundleContext) { - this.bundleContext = bundleContext; + public StyleSheetResourceLoader(Bundle themeBundle) { + this.themeBundle = themeBundle; } @Override - public InputStream getResourceAsStream(String resourceName) - throws IOException { + public InputStream getResourceAsStream(String resourceName) throws IOException { if (!stylesheets.containsKey(resourceName)) { // TODO deal with other bundles - Bundle bundle = bundleContext.getBundle(); + // Bundle bundle = bundleContext.getBundle(); // String location = // bundle.getLocation().substring("initial@reference:".length()); // if (location.startsWith("file:")) { @@ -45,10 +42,11 @@ public class StyleSheetResourceLoader implements ResourceLoader { // return Files.newInputStream(resourcePath); // } // } - URL res = bundle.getResource(resourceName); + + URL res = themeBundle.getResource(resourceName); if (res == null) - throw new CmsException("Resource " + resourceName - + " not found in bundle " + bundle.getSymbolicName()); + throw new CmsException( + "Resource " + resourceName + " not found in bundle " + themeBundle.getSymbolicName()); ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(res.openStream(), out); stylesheets.put(resourceName, new StyleSheet(out.toByteArray()));