Introduce plain RWT RAP dependencies.
[lgpl/argeo-commons.git] / org.argeo.cms.ui / src / org / argeo / cms / web / CmsWebApp.java
index 4c55d4eabf11bd6ba837af4d00593b1458ff0494..03ac353df248ab5952daa0ad559747d477131532 100644 (file)
@@ -11,13 +11,12 @@ import org.argeo.cms.ui.CmsAppListener;
 import org.argeo.cms.ui.CmsTheme;
 import org.argeo.util.LangUtils;
 import org.eclipse.rap.rwt.RWT;
-import org.eclipse.rap.rwt.application.AbstractEntryPoint;
 import org.eclipse.rap.rwt.application.Application;
 import org.eclipse.rap.rwt.application.ApplicationConfiguration;
 import org.eclipse.rap.rwt.client.WebClient;
-import org.eclipse.swt.widgets.Composite;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.event.EventAdmin;
 
 /** An RWT web app integrating with a {@link CmsApp}. */
 public class CmsWebApp implements ApplicationConfiguration, CmsAppListener {
@@ -25,6 +24,7 @@ public class CmsWebApp implements ApplicationConfiguration, CmsAppListener {
 
        private BundleContext bundleContext;
        private CmsApp cmsApp;
+       private EventAdmin eventAdmin;
 
        private ServiceRegistration<ApplicationConfiguration> rwtAppReg;
 
@@ -34,11 +34,14 @@ public class CmsWebApp implements ApplicationConfiguration, CmsAppListener {
        public void init(BundleContext bundleContext, Map<String, String> properties) {
                this.bundleContext = bundleContext;
                contextName = properties.get(CONTEXT_NAME);
+               if (cmsApp != null)
+                       themingUpdated();
 //             registerIfAllThemesAvailable();
        }
 
        public void destroy(BundleContext bundleContext, Map<String, String> properties) {
-
+               if (cmsApp != null)
+                       cmsApp.removeCmsAppListener(this);
        }
 
        @Override
@@ -69,17 +72,14 @@ public class CmsWebApp implements ApplicationConfiguration, CmsAppListener {
 //                                     log.warn("Theme id " + themeId + " was specified but it was not found, using default RWT theme.");
                        }
                        application.addEntryPoint("/" + uiName, () -> {
-                               return new AbstractEntryPoint() {
-                                       private static final long serialVersionUID = -9153259126766694485L;
-
-                                       @Override
-                                       protected void createContents(Composite parent) {
-                                               cmsApp.initUi(uiName, parent);
-
-                                       }
-                               };
+                               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.debug("Published CMS web app /" + (contextName != null ? contextName : ""));
        }
 
 //     private void registerIfAllThemesAvailable() {
@@ -102,7 +102,7 @@ public class CmsWebApp implements ApplicationConfiguration, CmsAppListener {
 //             }
 //     }
 
-       public CmsApp getCmsApp() {
+       CmsApp getCmsApp() {
                return cmsApp;
        }
 
@@ -125,8 +125,13 @@ public class CmsWebApp implements ApplicationConfiguration, CmsAppListener {
                        rwtAppReg.unregister();
                if (bundleContext != null) {
                        rwtAppReg = bundleContext.registerService(ApplicationConfiguration.class, this, regProps);
-                       log.info("Published CMS web app /" + (contextName != null ? contextName : ""));
+                       if (log.isDebugEnabled())
+                               log.debug("Publishing CMS web app /" + (contextName != null ? contextName : "") + " ...");
                }
        }
 
+       public void setEventAdmin(EventAdmin eventAdmin) {
+               this.eventAdmin = eventAdmin;
+       }
+
 }