Improve CMS App.
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 27 Oct 2020 08:13:22 +0000 (09:13 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 27 Oct 2020 08:13:22 +0000 (09:13 +0100)
org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebApp.java
org.argeo.cms.ui/src/org/argeo/cms/ui/AbstractCmsApp.java
org.argeo.cms.ui/src/org/argeo/cms/ui/util/BundleCmsTheme.java

index a4088eedccbb61188b6807ab6c8fcdf8b10cfd22..ca26c5830c7a0ad4bbf4a08928aa45a06bc53848 100644 (file)
@@ -86,15 +86,17 @@ public class CmsWebApp implements ApplicationConfiguration, ExceptionHandler, Cm
 //                             if (themeId != null)
 //                                     log.warn("Theme id " + themeId + " was specified but it was not found, using default RWT theme.");
                        }
-                       application.addEntryPoint("/" + uiName, () -> {
+                       String entryPointName = !uiName.equals("") ? "/" + uiName : "/";
+                       application.addEntryPoint(entryPointName, () -> {
                                CmsWebEntryPoint entryPoint = new CmsWebEntryPoint(this, uiName);
                                entryPoint.setEventAdmin(eventAdmin);
                                return entryPoint;
                        }, properties);
                        if (log.isDebugEnabled())
-                               log.info("Added web entry point /" + (contextName != null ? contextName : "") + "/" + uiName);
+                               log.info("Added web entry point " + (contextName != null ? "/" + contextName : "") + entryPointName);
                }
-               log.debug("Published CMS web app /" + (contextName != null ? contextName : ""));
+               if (log.isDebugEnabled())
+                       log.debug("Published CMS web app /" + (contextName != null ? contextName : ""));
        }
 
 //     private void registerIfAllThemesAvailable() {
index 98f9adfa0db822e3ea00ee4699ab211e2a7480c5..2ecc658413507860381d30f238e7019a1dd29350 100644 (file)
@@ -5,7 +5,6 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import javax.jcr.Repository;
 
@@ -19,12 +18,6 @@ public abstract class AbstractCmsApp implements CmsApp {
 
        private Repository repository;
 
-       @Override
-       public Set<String> getUiNames() {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
        protected abstract String getThemeId(String uiName);
 
        @Override
index a4749fbabe150f4624782f45ead79e274dc7fd1f..c86ba3601950022cd5367e172236dc7adb4728df 100644 (file)
@@ -135,28 +135,30 @@ public class BundleCmsTheme extends AbstractCmsTheme {
 
        Set<String> addCss(Bundle themeBundle, String path) {
                Set<String> paths = new TreeSet<>();
-               Enumeration<URL> themeResources = themeBundle.findEntries(path, "*.css", true);
-               if (themeResources == null)
-                       return paths;
-               while (themeResources.hasMoreElements()) {
-                       String resource = themeResources.nextElement().getPath();
-                       // remove first '/' so that RWT registers it
-                       resource = resource.substring(1);
-                       if (!resource.endsWith("/")) {
-                               paths.add(resource);
-                       }
-               }
 
                // common CSS
                Enumeration<URL> commonResources = themeBundle.findEntries(styleCssPath, "*.css", true);
-               if (commonResources == null)
-                       return paths;
-               while (commonResources.hasMoreElements()) {
-                       String resource = commonResources.nextElement().getPath();
-                       // remove first '/' so that RWT registers it
-                       resource = resource.substring(1);
-                       if (!resource.endsWith("/")) {
-                               paths.add(resource);
+               if (commonResources != null) {
+                       while (commonResources.hasMoreElements()) {
+                               String resource = commonResources.nextElement().getPath();
+                               // remove first '/' so that RWT registers it
+                               resource = resource.substring(1);
+                               if (!resource.endsWith("/")) {
+                                       paths.add(resource);
+                               }
+                       }
+               }
+
+               // specific CSS
+               Enumeration<URL> themeResources = themeBundle.findEntries(path, "*.css", true);
+               if (themeResources != null) {
+                       while (themeResources.hasMoreElements()) {
+                               String resource = themeResources.nextElement().getPath();
+                               // remove first '/' so that RWT registers it
+                               resource = resource.substring(1);
+                               if (!resource.endsWith("/")) {
+                                       paths.add(resource);
+                               }
                        }
                }
                return paths;
@@ -277,4 +279,14 @@ public class BundleCmsTheme extends AbstractCmsTheme {
                return themeBundle;
        }
 
+       @Override
+       public int hashCode() {
+               return themeId.hashCode();
+       }
+
+       @Override
+       public String toString() {
+               return "Bundle CMS Theme " + themeId;
+       }
+
 }