projects
/
lgpl
/
argeo-commons.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve CMS web app lifecycle.
[lgpl/argeo-commons.git]
/
org.argeo.cms.ui.rap
/
src
/
org
/
argeo
/
cms
/
web
/
CmsWebApp.java
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 25b30c9b3c6ef6d0ec10674668eb7126640775f6..66333858dd933f1bb415167eba0d1eabe9f8005e 100644
(file)
--- 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
@@
-15,9
+15,11
@@
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.application.Application;
import org.eclipse.rap.rwt.application.ApplicationConfiguration;
import org.eclipse.rap.rwt.application.ExceptionHandler;
import org.eclipse.rap.rwt.application.Application;
import org.eclipse.rap.rwt.application.ApplicationConfiguration;
import org.eclipse.rap.rwt.application.ExceptionHandler;
+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.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;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.event.EventAdmin;
@@
-27,6
+29,7
@@
public class CmsWebApp implements ApplicationConfiguration, ExceptionHandler, Cm
private BundleContext bundleContext;
private CmsApp cmsApp;
private BundleContext bundleContext;
private CmsApp cmsApp;
+ private String cmsAppId;
private EventAdmin eventAdmin;
private ServiceRegistration<ApplicationConfiguration> rwtAppReg;
private EventAdmin eventAdmin;
private ServiceRegistration<ApplicationConfiguration> rwtAppReg;
@@
-37,17
+40,26
@@
public class CmsWebApp implements ApplicationConfiguration, ExceptionHandler, Cm
public void init(BundleContext bundleContext, Map<String, String> properties) {
this.bundleContext = bundleContext;
contextName = properties.get(CONTEXT_NAME);
public void init(BundleContext bundleContext, Map<String, String> 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<String, String> properties) {
}
public void destroy(BundleContext bundleContext, Map<String, String> properties) {
- if (cmsApp != null)
+ if (cmsApp != null)
{
cmsApp.removeCmsAppListener(this);
cmsApp.removeCmsAppListener(this);
+ cmsApp = null;
+ }
}
@Override
public void configure(Application application) {
}
@Override
public void configure(Application application) {
+ // TODO make it configurable?
+ // SWT compatibility is required for:
+ // - Browser.execute()
+ // - blocking dialogs
+ application.setOperationMode(OperationMode.SWT_COMPATIBILITY);
for (String uiName : cmsApp.getUiNames()) {
CmsTheme theme = cmsApp.getTheme(uiName);
if (theme != null)
for (String uiName : cmsApp.getUiNames()) {
CmsTheme theme = cmsApp.getTheme(uiName);
if (theme != null)
@@
-90,8
+102,8
@@
public class CmsWebApp implements ApplicationConfiguration, ExceptionHandler, Cm
if (log.isDebugEnabled())
log.info("Added web entry point " + (contextName != null ? "/" + contextName : "") + entryPointName);
}
if (log.isDebugEnabled())
log.info("Added web entry point " + (contextName != null ? "/" + contextName : "") + entryPointName);
}
-
if (log.isDebugEnabled())
-
log.debug("Published CMS web app /" + (contextName != null ? contextName : ""));
+
//
if (log.isDebugEnabled())
+
//
log.debug("Published CMS web app /" + (contextName != null ? contextName : ""));
}
CmsApp getCmsApp() {
}
CmsApp getCmsApp() {
@@
-104,10
+116,17
@@
public class CmsWebApp implements ApplicationConfiguration, ExceptionHandler, Cm
public void setCmsApp(CmsApp cmsApp, Map<String, String> properties) {
this.cmsApp = cmsApp;
public void setCmsApp(CmsApp cmsApp, Map<String, String> properties) {
this.cmsApp = cmsApp;
+ this.cmsAppId = properties.get(Constants.SERVICE_PID);
this.cmsApp.addCmsAppListener(this);
}
public void unsetCmsApp(CmsApp cmsApp, Map<String, String> properties) {
this.cmsApp.addCmsAppListener(this);
}
public void unsetCmsApp(CmsApp cmsApp, Map<String, String> 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;
if (rwtAppReg != null)
rwtAppReg.unregister();
this.cmsApp = null;
@@
-115,6
+134,11
@@
public class CmsWebApp implements ApplicationConfiguration, ExceptionHandler, Cm
@Override
public void themingUpdated() {
@Override
public void themingUpdated() {
+ if (cmsApp != null && cmsApp.allThemesAvailable())
+ publishWebApp();
+ }
+
+ protected void publishWebApp() {
Dictionary<String, Object> regProps = LangUtils.dict(CONTEXT_NAME, contextName);
if (rwtAppReg != null)
rwtAppReg.unregister();
Dictionary<String, Object> regProps = LangUtils.dict(CONTEXT_NAME, contextName);
if (rwtAppReg != null)
rwtAppReg.unregister();