]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/osgi/BundleCmsTheme.java
Make CMS running without data area, and remove unnecessary dependencies.
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / osgi / BundleCmsTheme.java
index 6c195d45f48c742e377f92dcaf874073e843b368..de7eec8c2a39e19ea93faa507a8b1ef6fc2aa4b8 100644 (file)
@@ -7,7 +7,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
-import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashSet;
@@ -17,8 +16,8 @@ import java.util.Set;
 import java.util.TreeSet;
 import java.util.stream.Collectors;
 
-import org.apache.commons.io.IOUtils;
-import org.argeo.api.cms.CmsTheme;
+import org.argeo.api.cms.ux.CmsTheme;
+import org.argeo.util.StreamUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 
@@ -64,7 +63,8 @@ public class BundleCmsTheme implements CmsTheme {
 //     private String swtCssPath;
        private Bundle themeBundle;
 
-       private Integer defaultIconSize = 16;
+       private Integer smallIconSize = 16;
+       private Integer bigIconSize = 32;
 
        public BundleCmsTheme() {
 
@@ -212,7 +212,7 @@ public class BundleCmsTheme implements CmsTheme {
 
        void loadBodyHtml(URL url) {
                try (BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), UTF_8))) {
-                       bodyHtml = IOUtils.toString(url, StandardCharsets.UTF_8);
+                       bodyHtml = StreamUtils.toString(in);
                } catch (IOException e) {
                        throw new IllegalArgumentException("Cannot load URL " + url, e);
                }
@@ -320,17 +320,27 @@ public class BundleCmsTheme implements CmsTheme {
        }
 
        @Override
-       public Integer getDefaultIconSize() {
-               return defaultIconSize;
+       public int getSmallIconSize() {
+               return smallIconSize;
+       }
+
+       @Override
+       public int getBigIconSize() {
+               return bigIconSize;
        }
 
        @Override
        public InputStream loadPath(String path) throws IOException {
                URL url = themeBundle.getResource(path);
-               if (url == null)
-                       throw new IllegalArgumentException(
-                                       "Path " + path + " not found in bundle " + themeBundle.getSymbolicName());
-               return url.openStream();
+               if (url == null) {
+                       if (parentTheme != null)
+                               return parentTheme.loadPath(path);
+                       else
+                               throw new IllegalArgumentException(
+                                               "Path " + path + " not found in bundle " + themeBundle.getSymbolicName());
+               } else {
+                       return url.openStream();
+               }
        }
 
        private static Bundle findThemeBundle(BundleContext bundleContext, String themeId) {