X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.e4.rap%2Fsrc%2Forg%2Fargeo%2Fcms%2Fe4%2Frap%2FAbstractRapE4App.java;h=8c43a8089fcbabcb7a136ddab53e68ee3ff32742;hb=3f9d3be94e90a97c85f44922ded06e73d57eeaa0;hp=1d70044b3e5d4edb800721dc311ad811aa1cec7f;hpb=21171ced2bce875e64db47d95bf4a00a0e141a9a;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/AbstractRapE4App.java b/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/AbstractRapE4App.java index 1d70044b3..8c43a8089 100644 --- a/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/AbstractRapE4App.java +++ b/org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/AbstractRapE4App.java @@ -10,6 +10,7 @@ import org.eclipse.rap.rwt.application.Application.OperationMode; import org.eclipse.rap.rwt.application.ApplicationConfiguration; import org.eclipse.rap.rwt.application.ExceptionHandler; import org.eclipse.rap.rwt.client.WebClient; +import org.osgi.framework.BundleContext; /** Base class for CMS RAP applications. */ public abstract class AbstractRapE4App implements ApplicationConfiguration { @@ -17,7 +18,18 @@ public abstract class AbstractRapE4App implements ApplicationConfiguration { private String path; private String lifeCycleUri = "bundleclass://org.argeo.cms.e4.rap/org.argeo.cms.e4.rap.CmsLoginLifecycle"; - Map baseProperties = new HashMap(); + private Map baseProperties = new HashMap(); + + private BundleContext bundleContext; + public final static String CONTEXT_NAME_PROPERTY = "contextName"; + private String contextName; + + /** + * To be overridden in order to add multiple entry points, directly or using + * {@link #addE4EntryPoint(Application, String, String, Map)}. + */ + protected void addEntryPoints(Application application) { + } public void configure(Application application) { application.setExceptionHandler(new ExceptionHandler() { @@ -35,14 +47,6 @@ public abstract class AbstractRapE4App implements ApplicationConfiguration { } } - /** - * To be overridden in order to add multiple entry points, directly or using - * {@link #addE4EntryPoint(Application, String, String, Map)}. - */ - protected void addEntryPoints(Application application) { - - } - protected Map getBaseProperties() { return baseProperties; } @@ -54,21 +58,41 @@ public abstract class AbstractRapE4App implements ApplicationConfiguration { // } protected void addE4EntryPoint(Application application, String path, String e4Xmi, Map properties) { - E4ApplicationConfig config = new E4ApplicationConfig(e4Xmi, lifeCycleUri, null, null, false, true, true); + E4ApplicationConfig config = createE4ApplicationConfig(e4Xmi); CmsE4EntryPointFactory entryPointFactory = new CmsE4EntryPointFactory(config); application.addEntryPoint(path, entryPointFactory, properties); application.setOperationMode(OperationMode.SWT_COMPATIBILITY); } + /** + * To be overridden for further configuration. + * + * @see E4ApplicationConfig + */ + protected E4ApplicationConfig createE4ApplicationConfig(String e4Xmi) { + return new E4ApplicationConfig(e4Xmi, lifeCycleUri, null, null, false, true, true); + } + + @Deprecated public void setPageTitle(String pageTitle) { if (pageTitle != null) baseProperties.put(WebClient.PAGE_TITLE, pageTitle); } + /** Returns a new map used to customise and entry point. */ + public Map customise(String pageTitle) { + Map custom = new HashMap<>(getBaseProperties()); + if (pageTitle != null) + custom.put(WebClient.PAGE_TITLE, pageTitle); + return custom; + } + + @Deprecated public void setE4Xmi(String e4Xmi) { this.e4Xmi = e4Xmi; } + @Deprecated public void setPath(String path) { this.path = path; } @@ -77,11 +101,39 @@ public abstract class AbstractRapE4App implements ApplicationConfiguration { this.lifeCycleUri = lifeCycleUri; } - public void init(Map properties) { + protected BundleContext getBundleContext() { + return bundleContext; + } + + protected void setBundleContext(BundleContext bundleContext) { + this.bundleContext = bundleContext; + } + + public String getContextName() { + return contextName; + } + + public void setContextName(String contextName) { + this.contextName = contextName; + } + + public void init(BundleContext bundleContext, Map properties) { + this.bundleContext = bundleContext; for (String key : properties.keySet()) { Object value = properties.get(key); if (value != null) baseProperties.put(key, value.toString()); } + + if (properties.containsKey(CONTEXT_NAME_PROPERTY)) { + assert properties.get(CONTEXT_NAME_PROPERTY) != null; + contextName = properties.get(CONTEXT_NAME_PROPERTY).toString(); + } else { + contextName = ""; + } + } + + public void destroy(Map properties) { + } }