View Javadoc
1   package org.argeo.suite.e4.rap.settings;
2   
3   import java.util.Enumeration;
4   
5   import org.apache.commons.io.FilenameUtils;
6   import org.apache.commons.logging.Log;
7   import org.apache.commons.logging.LogFactory;
8   import org.argeo.cms.e4.rap.AbstractRapE4App;
9   import org.argeo.cms.util.CmsTheme;
10  import org.eclipse.rap.rwt.application.Application;
11  import org.eclipse.rap.rwt.client.WebClient;
12  import org.osgi.framework.Bundle;
13  
14  /** Argeo RAP app. */
15  public class ArgeoRapApp extends AbstractRapE4App {
16  	private final static Log log = LogFactory.getLog(ArgeoRapApp.class);
17  
18  	private Bundle bundle;
19  	private CmsTheme cmsTheme;
20  	private String baseE4xmi = "/e4xmi";
21  
22  	public ArgeoRapApp(Bundle bundle, CmsTheme cmsTheme) {
23  		this.bundle = bundle;
24  		this.cmsTheme = cmsTheme;
25  		setLifeCycleUri("bundleclass://org.argeo.suite.e4.rap/org.argeo.suite.e4.rap.ArgeoSuiteLoginLifecycle");
26  		String contextName = "argeo/" + FilenameUtils.getExtension(bundle.getSymbolicName());
27  		setContextName(contextName);
28  	}
29  
30  	@Override
31  	protected void addEntryPoints(Application application) {
32  		if (cmsTheme != null)
33  			cmsTheme.apply(application);
34  
35  		String font = "<link rel='stylesheet' href='http://fonts.googleapis.com/css?family=Source+Sans+Pro'/>";
36  		getBaseProperties().put(WebClient.HEAD_HTML, font);
37  
38  		Enumeration<String> paths = bundle.getEntryPaths(baseE4xmi);
39  		while (paths.hasMoreElements()) {
40  			String p = paths.nextElement();
41  			if (p.endsWith(".e4xmi")) {
42  				String e4xmiPath = bundle.getSymbolicName() + '/' + p;
43  				String name = '/' + FilenameUtils.removeExtension(FilenameUtils.getName(p));
44  				addE4EntryPoint(application, name, e4xmiPath, getBaseProperties());
45  				if (log.isDebugEnabled())
46  					log.debug("Registered " + e4xmiPath + " as " + getContextName() + name);
47  			}
48  		}
49  	}
50  }