]> git.argeo.org Git - gpl/argeo-jcr.git/blob - parts/EgoDashboard.java
Prepare next development cycle
[gpl/argeo-jcr.git] / parts / EgoDashboard.java
1 package org.argeo.cms.e4.parts;
2
3 import java.time.ZonedDateTime;
4
5 import javax.annotation.PostConstruct;
6
7 import org.argeo.api.cms.CmsSession;
8 import org.argeo.cms.auth.CurrentUser;
9 import org.argeo.cms.swt.CmsSwtUtils;
10 import org.eclipse.swt.layout.GridLayout;
11 import org.eclipse.swt.widgets.Composite;
12
13 /** A canonical view of the logged in user. */
14 public class EgoDashboard {
15 // private BundleContext bc = FrameworkUtil.getBundle(EgoDashboard.class).getBundleContext();
16
17 @PostConstruct
18 public void createPartControl(Composite p) {
19 p.setLayout(new GridLayout());
20 String username = CurrentUser.getUsername();
21
22 CmsSwtUtils.lbl(p, "<strong>" + CurrentUser.getDisplayName() + "</strong>");
23 CmsSwtUtils.txt(p, username);
24 CmsSwtUtils.lbl(p, "Roles:");
25 roles: for (String role : CurrentUser.roles()) {
26 if (username.equals(role))
27 continue roles;
28 CmsSwtUtils.txt(p, role);
29 }
30
31 // Subject subject = Subject.getSubject(AccessController.getContext());
32 // if (subject != null) {
33 CmsSession cmsSession = CurrentUser.getCmsSession();
34 ZonedDateTime loggedIndSince = cmsSession.getCreationTime();
35 CmsSwtUtils.lbl(p, "Session:");
36 CmsSwtUtils.txt(p, cmsSession.getUuid().toString());
37 CmsSwtUtils.lbl(p, "Logged in since:");
38 CmsSwtUtils.txt(p, loggedIndSince.toString());
39 // }
40 }
41 }