1 package org
.argeo
.cms
.e4
.rap
;
3 import java
.util
.HashMap
;
6 import org
.argeo
.cms
.ui
.dialogs
.CmsFeedback
;
7 import org
.eclipse
.rap
.e4
.E4ApplicationConfig
;
8 import org
.eclipse
.rap
.rwt
.application
.Application
;
9 import org
.eclipse
.rap
.rwt
.application
.Application
.OperationMode
;
10 import org
.eclipse
.rap
.rwt
.application
.ApplicationConfiguration
;
11 import org
.eclipse
.rap
.rwt
.application
.ExceptionHandler
;
12 import org
.eclipse
.rap
.rwt
.client
.WebClient
;
14 /** Base class for CMS RAP applications. */
15 public abstract class AbstractRapE4App
implements ApplicationConfiguration
{
18 private String lifeCycleUri
= "bundleclass://org.argeo.cms.e4.rap/org.argeo.cms.e4.rap.CmsLoginLifecycle";
20 Map
<String
, String
> baseProperties
= new HashMap
<String
, String
>();
22 public void configure(Application application
) {
23 application
.setExceptionHandler(new ExceptionHandler() {
26 public void handleException(Throwable throwable
) {
27 CmsFeedback
.show("Unexpected RWT exception", throwable
);
31 if (e4Xmi
!= null) {// backward compatibility
32 addE4EntryPoint(application
, path
, e4Xmi
, getBaseProperties());
34 addEntryPoints(application
);
39 * To be overridden in order to add multiple entry points, directly or using
40 * {@link #addE4EntryPoint(Application, String, String, Map)}.
42 protected void addEntryPoints(Application application
) {
46 protected Map
<String
, String
> getBaseProperties() {
47 return baseProperties
;
50 // protected void addEntryPoint(Application application, E4ApplicationConfig config, Map<String, String> properties) {
51 // CmsE4EntryPointFactory entryPointFactory = new CmsE4EntryPointFactory(config);
52 // application.addEntryPoint(path, entryPointFactory, properties);
53 // application.setOperationMode(OperationMode.SWT_COMPATIBILITY);
56 protected void addE4EntryPoint(Application application
, String path
, String e4Xmi
, Map
<String
, String
> properties
) {
57 E4ApplicationConfig config
= createE4ApplicationConfig(e4Xmi
);
58 CmsE4EntryPointFactory entryPointFactory
= new CmsE4EntryPointFactory(config
);
59 application
.addEntryPoint(path
, entryPointFactory
, properties
);
60 application
.setOperationMode(OperationMode
.SWT_COMPATIBILITY
);
64 * To be overridden for further configuration.
66 * @see E4ApplicationConfig
68 protected E4ApplicationConfig
createE4ApplicationConfig(String e4Xmi
) {
69 return new E4ApplicationConfig(e4Xmi
, lifeCycleUri
, null, null, false, true, true);
73 public void setPageTitle(String pageTitle
) {
74 if (pageTitle
!= null)
75 baseProperties
.put(WebClient
.PAGE_TITLE
, pageTitle
);
78 /** Returns a new map used to customise and entry point. */
79 public Map
<String
, String
> customise(String pageTitle
) {
80 Map
<String
, String
> custom
= new HashMap
<>(getBaseProperties());
81 if (pageTitle
!= null)
82 custom
.put(WebClient
.PAGE_TITLE
, pageTitle
);
87 public void setE4Xmi(String e4Xmi
) {
92 public void setPath(String path
) {
96 public void setLifeCycleUri(String lifeCycleUri
) {
97 this.lifeCycleUri
= lifeCycleUri
;
100 public void init(Map
<String
, Object
> properties
) {
101 for (String key
: properties
.keySet()) {
102 Object value
= properties
.get(key
);
104 baseProperties
.put(key
, value
.toString());
108 public void destroy(Map
<String
, Object
> properties
) {