]>
git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/wizards/ChooseRightsPage.java
251ea6126c3615ffdff8b0c8a37deb277dedc1a0
1 package org
.argeo
.slc
.client
.ui
.dist
.wizards
;
3 import java
.util
.regex
.Pattern
;
5 import javax
.jcr
.security
.Privilege
;
7 import org
.eclipse
.jface
.wizard
.WizardPage
;
8 import org
.eclipse
.swt
.SWT
;
9 import org
.eclipse
.swt
.events
.ModifyEvent
;
10 import org
.eclipse
.swt
.events
.ModifyListener
;
11 import org
.eclipse
.swt
.layout
.GridData
;
12 import org
.eclipse
.swt
.layout
.GridLayout
;
13 import org
.eclipse
.swt
.widgets
.Combo
;
14 import org
.eclipse
.swt
.widgets
.Composite
;
15 import org
.eclipse
.swt
.widgets
.Label
;
16 import org
.eclipse
.swt
.widgets
.Text
;
18 public class ChooseRightsPage
extends WizardPage
implements ModifyListener
{
21 private Text groupNameTxt
;
22 private Combo authorizationCmb
;
24 // Define acceptable chars for the technical name
25 private static Pattern p
= Pattern
.compile("^[A-Za-z0-9]+$");
28 protected final static String
[] validAuthType
= { Privilege
.JCR_READ
,
29 Privilege
.JCR_WRITE
, Privilege
.JCR_ALL
};
31 public ChooseRightsPage() {
33 setTitle("Manange authorizations on the current workspace");
36 public void createControl(Composite parent
) {
38 Composite composite
= new Composite(parent
, SWT
.NONE
);
39 composite
.setLayout(new GridLayout(2, false));
40 Label lbl
= new Label(composite
, SWT
.LEAD
);
41 lbl
.setText("Group or user name (no blank, no special chars)");
42 lbl
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, false, false));
43 groupNameTxt
= new Text(composite
, SWT
.LEAD
| SWT
.BORDER
);
44 groupNameTxt
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true,
46 if (groupNameTxt
!= null)
47 groupNameTxt
.addModifyListener(this);
50 new Label(composite
, SWT
.NONE
).setText("Choose corresponding rights");
51 authorizationCmb
= new Combo(composite
, SWT
.BORDER
| SWT
.V_SCROLL
);
52 authorizationCmb
.setItems(validAuthType
);
53 GridData gd
= new GridData(GridData
.FILL_HORIZONTAL
);
54 authorizationCmb
.setLayoutData(gd
);
56 authorizationCmb
.select(0);
59 setControl(composite
);
62 protected String
getGroupName() {
63 return groupNameTxt
.getText();
66 protected String
getAuthTypeStr() {
67 return authorizationCmb
.getItem(authorizationCmb
.getSelectionIndex());
70 private static boolean match(String s
) {
71 return p
.matcher(s
).matches();
74 public void modifyText(ModifyEvent event
) {
75 String message
= checkComplete();
77 setMessage(message
, WizardPage
.ERROR
);
79 setMessage("Complete", WizardPage
.INFORMATION
);
80 setPageComplete(true);
84 /** @return error message or null if complete */
85 protected String
checkComplete() {
86 String groupStr
= groupNameTxt
.getText();
87 if (groupStr
== null || "".equals(groupStr
))
88 return "Please enter the name of the corresponding group.";
89 // Remove regexp check for the time being.
90 // else if (!match(groupStr))
92 // "Please use only alphanumerical chars for the short technical name.";