]> git.argeo.org Git - gpl/argeo-suite.git/blob - org.argeo.suite.e4.rap/src/org/argeo/suite/e4/rap/settings/ArgeoRapApp.java
Use tabbed area.
[gpl/argeo-suite.git] / org.argeo.suite.e4.rap / src / org / argeo / suite / e4 / rap / settings / ArgeoRapApp.java
1 package org.argeo.suite.e4.rap.settings;
2
3 import java.util.Enumeration;
4 import java.util.Map;
5
6 import org.apache.commons.io.FilenameUtils;
7 import org.apache.commons.logging.Log;
8 import org.apache.commons.logging.LogFactory;
9 import org.argeo.cms.e4.rap.AbstractRapE4App;
10 import org.argeo.cms.ui.CmsTheme;
11 import org.eclipse.rap.rwt.application.Application;
12 import org.eclipse.rap.rwt.client.WebClient;
13 import org.osgi.framework.Bundle;
14 import org.osgi.framework.BundleContext;
15
16 /** Argeo RAP app. */
17 public class ArgeoRapApp extends AbstractRapE4App {
18 private final static Log log = LogFactory.getLog(ArgeoRapApp.class);
19
20 private CmsTheme cmsTheme;
21 private String baseE4xmi = "/e4xmi";
22 private Bundle bundle;
23
24 public ArgeoRapApp(BundleContext bundleContext, Bundle bundle, CmsTheme cmsTheme) {
25 setBundleContext(bundleContext);
26 this.cmsTheme = cmsTheme;
27 this.bundle = bundle;
28 setLifeCycleUri("bundleclass://org.argeo.suite.e4.rap/org.argeo.suite.e4.rap.ArgeoSuiteLoginLifecycle");
29 String contextName = "apps/" + FilenameUtils.getExtension(bundle.getSymbolicName());
30 setContextName(contextName);
31 }
32
33 public ArgeoRapApp() {
34 setLifeCycleUri("bundleclass://org.argeo.suite.e4.rap/org.argeo.suite.e4.rap.ArgeoSuiteLoginLifecycle");
35 }
36
37 @Override
38 public void init(BundleContext bundleContext, Map<String, Object> properties) {
39 super.init(bundleContext, properties);
40 // super must be first
41 // if (getBaseProperties().containsKey(CmsTheme.CMS_THEME_BUNDLE_PROPERTY)) {
42 // String cmsThemeBundle = getBaseProperties().get(CmsTheme.CMS_THEME_BUNDLE_PROPERTY);
43 // cmsTheme = new CmsTheme(getBundleContext(), cmsThemeBundle);
44 // } else {
45 // cmsTheme = new CmsTheme(getBundleContext(), CmsTheme.DEFAULT_CMS_THEME_BUNDLE);
46 // }
47 bundle = bundleContext.getBundle();
48 }
49
50 @Override
51 protected void addEntryPoints(Application application) {
52 // if (cmsTheme != null)
53 // cmsTheme.apply(application);
54
55 String font = "<link rel='stylesheet' href='http://fonts.googleapis.com/css?family=Source+Sans+Pro'/>";
56 getBaseProperties().put(WebClient.HEAD_HTML, font);
57
58 Enumeration<String> paths = bundle.getEntryPaths(baseE4xmi);
59 while (paths.hasMoreElements()) {
60 String p = paths.nextElement();
61 if (p.endsWith(".e4xmi")) {
62 String e4xmiPath = bundle.getSymbolicName() + '/' + p;
63 String name = '/' + FilenameUtils.removeExtension(FilenameUtils.getName(p));
64 addE4EntryPoint(application, name, e4xmiPath, getBaseProperties());
65 if (log.isDebugEnabled())
66 log.debug("Registered " + e4xmiPath + " as " + getContextName() + name);
67 }
68 }
69 }
70 }