2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.cms
.ui
.workbench
.useradmin
;
18 import java
.util
.TreeSet
;
20 import org
.argeo
.cms
.auth
.CurrentUser
;
21 import org
.argeo
.cms
.ui
.workbench
.WorkbenchUiPlugin
;
22 import org
.argeo
.eclipse
.ui
.EclipseUiUtils
;
23 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
24 import org
.eclipse
.jface
.viewers
.LabelProvider
;
25 import org
.eclipse
.jface
.viewers
.TableViewer
;
26 import org
.eclipse
.jface
.viewers
.Viewer
;
27 import org
.eclipse
.swt
.SWT
;
28 import org
.eclipse
.swt
.layout
.GridData
;
29 import org
.eclipse
.swt
.layout
.GridLayout
;
30 import org
.eclipse
.swt
.widgets
.Composite
;
31 import org
.eclipse
.swt
.widgets
.Table
;
32 import org
.eclipse
.ui
.part
.ViewPart
;
34 /** Information about the currently logged in user */
35 public class UserProfile
extends ViewPart
{
36 public static String ID
= WorkbenchUiPlugin
.PLUGIN_ID
+ ".userProfile";
38 private TableViewer viewer
;
41 public void createPartControl(Composite parent
) {
42 parent
.setLayout(new GridLayout(2, false));
44 // Authentication authentication = CurrentUser.getAuthentication();
45 // EclipseUiUtils.createGridLL(parent, "Name", authentication
46 // .getPrincipal().toString());
47 EclipseUiUtils
.createGridLL(parent
, "User ID",
48 CurrentUser
.getUsername());
51 Table table
= new Table(parent
, SWT
.V_SCROLL
| SWT
.BORDER
);
52 table
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 2, 1));
53 table
.setLinesVisible(false);
54 table
.setHeaderVisible(false);
55 viewer
= new TableViewer(table
);
56 viewer
.setContentProvider(new RolesContentProvider());
57 viewer
.setLabelProvider(new LabelProvider());
58 getViewSite().setSelectionProvider(viewer
);
59 viewer
.setInput(getViewSite());
63 public void setFocus() {
67 private class RolesContentProvider
implements IStructuredContentProvider
{
68 private static final long serialVersionUID
= -4576917440167866233L;
70 public Object
[] getElements(Object inputElement
) {
71 return new TreeSet
<String
>(CurrentUser
.roles()).toArray();
74 public void dispose() {
77 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {