1 package org
.argeo
.security
.ui
.views
;
3 import java
.util
.TreeSet
;
5 import org
.argeo
.eclipse
.ui
.EclipseUiUtils
;
6 import org
.argeo
.security
.ui
.SecurityUiPlugin
;
7 import org
.argeo
.security
.ui
.internal
.CurrentUser
;
8 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
9 import org
.eclipse
.jface
.viewers
.LabelProvider
;
10 import org
.eclipse
.jface
.viewers
.TableViewer
;
11 import org
.eclipse
.jface
.viewers
.Viewer
;
12 import org
.eclipse
.swt
.SWT
;
13 import org
.eclipse
.swt
.layout
.GridData
;
14 import org
.eclipse
.swt
.layout
.GridLayout
;
15 import org
.eclipse
.swt
.widgets
.Composite
;
16 import org
.eclipse
.swt
.widgets
.Table
;
17 import org
.eclipse
.swt
.widgets
.Text
;
18 import org
.eclipse
.ui
.part
.ViewPart
;
19 import org
.springframework
.security
.Authentication
;
21 /** Information about the currently logged in user */
22 public class UserProfile
extends ViewPart
{
23 public static String ID
= SecurityUiPlugin
.PLUGIN_ID
+ ".userProfile";
25 private TableViewer viewer
;
28 public void createPartControl(Composite parent
) {
29 parent
.setLayout(new GridLayout(2, false));
31 Authentication authentication
= CurrentUser
.getAuthentication();
32 EclipseUiUtils
.createGridLL(parent
, "Name", authentication
33 .getPrincipal().toString());
34 EclipseUiUtils
.createGridLL(parent
, "User ID",
35 CurrentUser
.getUsername());
38 Table table
= new Table(parent
, SWT
.V_SCROLL
| SWT
.BORDER
);
39 table
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 2, 1));
40 table
.setLinesVisible(false);
41 table
.setHeaderVisible(false);
42 viewer
= new TableViewer(table
);
43 viewer
.setContentProvider(new RolesContentProvider());
44 viewer
.setLabelProvider(new LabelProvider());
45 getViewSite().setSelectionProvider(viewer
);
46 viewer
.setInput(getViewSite());
50 public void setFocus() {
54 private class RolesContentProvider
implements IStructuredContentProvider
{
55 public Object
[] getElements(Object inputElement
) {
56 return new TreeSet
<String
>(CurrentUser
.roles()).toArray();
59 public void dispose() {
62 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {