private LoginContext loginContext;
@PostContextCreate
- boolean login(Display d) {
+ boolean login(Display d) {// , IEclipseContext eclipseContext) {
+ // RepositoryFactory repositoryFactory =
+ // eclipseContext.get(RepositoryFactory.class);
+ // Map<String, String> params = new HashMap<>();
+ // params.put("cn", "home");
+ // Repository homeRepository;
+ // try {
+ // homeRepository = repositoryFactory.getRepository(params);
+ // } catch (RepositoryException e1) {
+ // throw new CmsException("Cannot get home repository", e1);
+ // }
+ // eclipseContext.set("(cn=home)", homeRepository);
+
Subject subject = Subject.getSubject(AccessController.getContext());
Display display = Display.getCurrent();
CmsLoginShell loginShell = new CmsLoginShell(this);
if (loginContext == null)
throw new CmsException("Login context cannot be null");
// logout previous login context
-// if (this.loginContext != null)
-// try {
-// this.loginContext.logout();
-// } catch (LoginException e1) {
-// System.err.println("Could not log out: " + e1);
-// }
+ // if (this.loginContext != null)
+ // try {
+ // this.loginContext.logout();
+ // } catch (LoginException e1) {
+ // System.err.println("Could not log out: " + e1);
+ // }
this.loginContext = loginContext;
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="Home Repository">
+ <implementation class="org.argeo.cms.e4.contexts.OsgiFilterContextFunction"/>
+ <property name="service.context.key" type="String" value="(cn=home)"/>
+ <service>
+ <provide interface="org.eclipse.e4.core.contexts.IContextFunction"/>
+ </service>
+</scr:component>
+Service-Component: OSGI-INF/homeRepository.xml
+Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.swt,\
org.eclipse.e4.ui.model.application.ui,\
org.eclipse.e4.ui.model.application,\
-source.. = src/\r
-output.. = bin/\r
-bin.includes = META-INF/,\\r
- OSGI-INF/,\\r
- .\r
+output.. = bin/
+bin.includes = META-INF/,\
+ OSGI-INF/,\
+ .,\
+ OSGI-INF/homeRepository.xml
+source.. = src/
--- /dev/null
+package org.argeo.cms.e4.contexts;
+
+import org.argeo.cms.CmsException;
+import org.eclipse.e4.core.contexts.ContextFunction;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.IInjector;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+@SuppressWarnings("restriction")
+public class OsgiFilterContextFunction extends ContextFunction {
+
+ private BundleContext bc = FrameworkUtil.getBundle(OsgiFilterContextFunction.class).getBundleContext();
+
+ @Override
+ public Object compute(IEclipseContext context, String contextKey) {
+ ServiceReference<?>[] srs;
+ try {
+ srs = bc.getServiceReferences((String) null, contextKey);
+ } catch (InvalidSyntaxException e) {
+ throw new CmsException("Context key " + contextKey + " must be a valid osgi filter", e);
+ }
+ if (srs == null || srs.length == 0) {
+ return IInjector.NOT_A_VALUE;
+ } else {
+ // return the first one
+ return bc.getService(srs[0]);
+ }
+ }
+
+}
toolkit = new FormToolkit(parent.getDisplay());
ownsToolkit = true;
form = toolkit.createScrolledForm(parent);
+
}
/**