1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.client.ui.dist.wizards;
17
18 import javax.jcr.security.Privilege;
19
20 import org.eclipse.jface.wizard.WizardPage;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.events.ModifyEvent;
23 import org.eclipse.swt.events.ModifyListener;
24 import org.eclipse.swt.layout.GridData;
25 import org.eclipse.swt.layout.GridLayout;
26 import org.eclipse.swt.widgets.Combo;
27 import org.eclipse.swt.widgets.Composite;
28 import org.eclipse.swt.widgets.Label;
29 import org.eclipse.swt.widgets.Text;
30
31 public class ChooseRightsPage extends WizardPage implements ModifyListener {
32 private static final long serialVersionUID = 3016024222014878781L;
33
34
35 private Text groupNameTxt;
36 private Combo authorizationCmb;
37
38
39
40
41
42 protected final static String[] validAuthType = { Privilege.JCR_READ,
43 Privilege.JCR_WRITE, Privilege.JCR_ALL };
44
45 public ChooseRightsPage() {
46 super("Main");
47 setTitle("Manage authorizations on the current workspace");
48 }
49
50 public void createControl(Composite parent) {
51
52 Composite composite = new Composite(parent, SWT.NONE);
53 composite.setLayout(new GridLayout(2, false));
54 Label lbl = new Label(composite, SWT.LEAD);
55 lbl.setText("Group or user name (no blank, no special chars)");
56 lbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
57 groupNameTxt = new Text(composite, SWT.LEAD | SWT.BORDER);
58 groupNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
59 false));
60 if (groupNameTxt != null)
61 groupNameTxt.addModifyListener(this);
62
63
64 new Label(composite, SWT.NONE).setText("Choose corresponding rights");
65 authorizationCmb = new Combo(composite, SWT.BORDER | SWT.V_SCROLL);
66 authorizationCmb.setItems(validAuthType);
67 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
68 authorizationCmb.setLayoutData(gd);
69
70 authorizationCmb.select(0);
71
72
73 setControl(composite);
74 }
75
76 protected String getGroupName() {
77 return groupNameTxt.getText();
78 }
79
80 protected String getAuthTypeStr() {
81 return authorizationCmb.getItem(authorizationCmb.getSelectionIndex());
82 }
83
84
85
86
87
88 public void modifyText(ModifyEvent event) {
89 String message = checkComplete();
90 if (message != null)
91 setMessage(message, WizardPage.ERROR);
92 else {
93 setMessage("Complete", WizardPage.INFORMATION);
94 setPageComplete(true);
95 }
96 }
97
98
99 protected String checkComplete() {
100 String groupStr = groupNameTxt.getText();
101 if (groupStr == null || "".equals(groupStr))
102 return "Please enter the name of the corresponding group.";
103
104
105
106
107 return null;
108 }
109 }