]> git.argeo.org Git - lgpl/argeo-commons.git/blob - swt/rap/org.argeo.cms.swt.rap/src/org/argeo/cms/web/MinimalWebApp.java
Merge remote-tracking branch 'origin/unstable' into testing
[lgpl/argeo-commons.git] / swt / rap / org.argeo.cms.swt.rap / src / org / argeo / cms / web / MinimalWebApp.java
1 package org.argeo.cms.web;
2
3 import static org.argeo.cms.osgi.BundleCmsTheme.CMS_THEME_BUNDLE_PROPERTY;
4
5 import java.util.HashMap;
6 import java.util.Map;
7
8 import org.argeo.cms.osgi.BundleCmsTheme;
9 import org.eclipse.rap.rwt.RWT;
10 import org.eclipse.rap.rwt.application.Application;
11 import org.eclipse.rap.rwt.application.ApplicationConfiguration;
12 import org.eclipse.rap.rwt.client.WebClient;
13 import org.osgi.framework.BundleContext;
14
15 /** Lightweight web app using only RWT and not the whole Eclipse platform. */
16 public class MinimalWebApp implements ApplicationConfiguration {
17
18 private BundleCmsTheme theme;
19
20 public void init(BundleContext bundleContext, Map<String, Object> properties) {
21 if (properties.containsKey(CMS_THEME_BUNDLE_PROPERTY)) {
22 String cmsThemeBundle = properties.get(CMS_THEME_BUNDLE_PROPERTY).toString();
23 theme = new BundleCmsTheme(bundleContext, cmsThemeBundle);
24 }
25 }
26
27 public void destroy() {
28
29 }
30
31 /** To be overridden. Does nothing by default. */
32 protected void addEntryPoints(Application application, Map<String, String> properties) {
33
34 }
35
36 @Override
37 public void configure(Application application) {
38 if (theme != null)
39 WebThemeUtils.apply(application, theme);
40
41 Map<String, String> properties = new HashMap<>();
42 if (theme != null) {
43 properties.put(WebClient.THEME_ID, theme.getThemeId());
44 properties.put(WebClient.HEAD_HTML, theme.getHtmlHeaders());
45 } else {
46 properties.put(WebClient.THEME_ID, RWT.DEFAULT_THEME_ID);
47 }
48 addEntryPoints(application, properties);
49
50 }
51
52 public void setTheme(BundleCmsTheme theme) {
53 this.theme = theme;
54 }
55
56 }