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=c293f1ab02524b4516a5f9ca00c9935aeef6b9eb;hb=08c2efb392a969f02008073f55d310c95bddade9;hp=3c37c1cb1f45c5b9f789e7027ad969a135cb95bd;hpb=b73edb765859b2193c67380c33fbc6c694468fe4;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 3c37c1cb1..c293f1ab0 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 @@ -11,12 +11,14 @@ import org.eclipse.rap.rwt.application.ApplicationConfiguration; import org.eclipse.rap.rwt.application.ExceptionHandler; import org.eclipse.rap.rwt.client.WebClient; +/** Base class for CMS RAP applications. */ public abstract class AbstractRapE4App implements ApplicationConfiguration { - private String pageTitle; private String e4Xmi; private String path; private String lifeCycleUri = "bundleclass://org.argeo.cms.e4.rap/org.argeo.cms.e4.rap.CmsLoginLifecycle"; + Map baseProperties = new HashMap(); + public void configure(Application application) { application.setExceptionHandler(new ExceptionHandler() { @@ -26,26 +28,67 @@ public abstract class AbstractRapE4App implements ApplicationConfiguration { } }); - Map properties = new HashMap(); - properties.put(WebClient.PAGE_TITLE, pageTitle); - E4ApplicationConfig config = new E4ApplicationConfig(e4Xmi, lifeCycleUri, null, false, true, true); - addEntryPoint(application, config, properties); + if (e4Xmi != null) {// backward compatibility + addE4EntryPoint(application, path, e4Xmi, getBaseProperties()); + } else { + addEntryPoints(application); + } + } + + /** + * 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 void addEntryPoint(Application application, E4ApplicationConfig config, Map properties) { + protected Map getBaseProperties() { + return baseProperties; + } + +// protected void addEntryPoint(Application application, E4ApplicationConfig config, Map properties) { +// CmsE4EntryPointFactory entryPointFactory = new CmsE4EntryPointFactory(config); +// application.addEntryPoint(path, entryPointFactory, properties); +// application.setOperationMode(OperationMode.SWT_COMPATIBILITY); +// } + + protected void addE4EntryPoint(Application application, String path, String e4Xmi, Map properties) { + 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) { - this.pageTitle = 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; } @@ -54,4 +97,15 @@ public abstract class AbstractRapE4App implements ApplicationConfiguration { this.lifeCycleUri = lifeCycleUri; } + public void init(Map properties) { + for (String key : properties.keySet()) { + Object value = properties.get(key); + if (value != null) + baseProperties.put(key, value.toString()); + } + } + + public void destroy(Map properties) { + + } }