X-Git-Url: https://git.argeo.org/?p=lgpl%2Fargeo-commons.git;a=blobdiff_plain;f=org.argeo.cms.ui.rap%2Fsrc%2Forg%2Fargeo%2Fcms%2Fweb%2FCmsWebApp.java;h=66333858dd933f1bb415167eba0d1eabe9f8005e;hp=dda02646d973763af7619482a3a94266ea03b4f9;hb=c5d120d226b31b3d930fc3006c56ac9e4d29ed2a;hpb=98ff62f2df01366777fda9b4dbe7586b0cd45252 diff --git a/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebApp.java b/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebApp.java index dda02646d..66333858d 100644 --- a/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebApp.java +++ b/org.argeo.cms.ui.rap/src/org/argeo/cms/web/CmsWebApp.java @@ -19,6 +19,7 @@ import org.eclipse.rap.rwt.application.Application.OperationMode; import org.eclipse.rap.rwt.client.WebClient; import org.eclipse.swt.widgets.Display; import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; import org.osgi.framework.ServiceRegistration; import org.osgi.service.event.EventAdmin; @@ -28,6 +29,7 @@ public class CmsWebApp implements ApplicationConfiguration, ExceptionHandler, Cm private BundleContext bundleContext; private CmsApp cmsApp; + private String cmsAppId; private EventAdmin eventAdmin; private ServiceRegistration rwtAppReg; @@ -38,13 +40,17 @@ public class CmsWebApp implements ApplicationConfiguration, ExceptionHandler, Cm public void init(BundleContext bundleContext, Map properties) { this.bundleContext = bundleContext; contextName = properties.get(CONTEXT_NAME); - if (cmsApp != null) - themingUpdated(); + if (cmsApp != null) { + if (cmsApp.allThemesAvailable()) + publishWebApp(); + } } public void destroy(BundleContext bundleContext, Map properties) { - if (cmsApp != null) + if (cmsApp != null) { cmsApp.removeCmsAppListener(this); + cmsApp = null; + } } @Override @@ -110,10 +116,17 @@ public class CmsWebApp implements ApplicationConfiguration, ExceptionHandler, Cm public void setCmsApp(CmsApp cmsApp, Map properties) { this.cmsApp = cmsApp; + this.cmsAppId = properties.get(Constants.SERVICE_PID); this.cmsApp.addCmsAppListener(this); } public void unsetCmsApp(CmsApp cmsApp, Map properties) { + String cmsAppId = properties.get(Constants.SERVICE_PID); + if (!cmsAppId.equals(this.cmsAppId)) + return; + if (this.cmsApp != null) { + this.cmsApp.removeCmsAppListener(this); + } if (rwtAppReg != null) rwtAppReg.unregister(); this.cmsApp = null; @@ -121,6 +134,11 @@ public class CmsWebApp implements ApplicationConfiguration, ExceptionHandler, Cm @Override public void themingUpdated() { + if (cmsApp != null && cmsApp.allThemesAvailable()) + publishWebApp(); + } + + protected void publishWebApp() { Dictionary regProps = LangUtils.dict(CONTEXT_NAME, contextName); if (rwtAppReg != null) rwtAppReg.unregister();