]>
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
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
.slc
.client
.ui
.dist
.wizards
;
18 import java
.util
.regex
.Pattern
;
20 import javax
.jcr
.security
.Privilege
;
22 import org
.eclipse
.jface
.wizard
.WizardPage
;
23 import org
.eclipse
.swt
.SWT
;
24 import org
.eclipse
.swt
.events
.ModifyEvent
;
25 import org
.eclipse
.swt
.events
.ModifyListener
;
26 import org
.eclipse
.swt
.layout
.GridData
;
27 import org
.eclipse
.swt
.layout
.GridLayout
;
28 import org
.eclipse
.swt
.widgets
.Combo
;
29 import org
.eclipse
.swt
.widgets
.Composite
;
30 import org
.eclipse
.swt
.widgets
.Label
;
31 import org
.eclipse
.swt
.widgets
.Text
;
33 public class ChooseRightsPage
extends WizardPage
implements ModifyListener
{
36 private Text groupNameTxt
;
37 private Combo authorizationCmb
;
39 // Define acceptable chars for the technical name
40 private static Pattern p
= Pattern
.compile("^[A-Za-z0-9]+$");
43 protected final static String
[] validAuthType
= { Privilege
.JCR_READ
,
44 Privilege
.JCR_WRITE
, Privilege
.JCR_ALL
};
46 public ChooseRightsPage() {
48 setTitle("Manange authorizations on the current workspace");
51 public void createControl(Composite parent
) {
53 Composite composite
= new Composite(parent
, SWT
.NONE
);
54 composite
.setLayout(new GridLayout(2, false));
55 Label lbl
= new Label(composite
, SWT
.LEAD
);
56 lbl
.setText("Group or user name (no blank, no special chars)");
57 lbl
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, false, false));
58 groupNameTxt
= new Text(composite
, SWT
.LEAD
| SWT
.BORDER
);
59 groupNameTxt
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true,
61 if (groupNameTxt
!= null)
62 groupNameTxt
.addModifyListener(this);
65 new Label(composite
, SWT
.NONE
).setText("Choose corresponding rights");
66 authorizationCmb
= new Combo(composite
, SWT
.BORDER
| SWT
.V_SCROLL
);
67 authorizationCmb
.setItems(validAuthType
);
68 GridData gd
= new GridData(GridData
.FILL_HORIZONTAL
);
69 authorizationCmb
.setLayoutData(gd
);
71 authorizationCmb
.select(0);
74 setControl(composite
);
77 protected String
getGroupName() {
78 return groupNameTxt
.getText();
81 protected String
getAuthTypeStr() {
82 return authorizationCmb
.getItem(authorizationCmb
.getSelectionIndex());
85 private static boolean match(String s
) {
86 return p
.matcher(s
).matches();
89 public void modifyText(ModifyEvent event
) {
90 String message
= checkComplete();
92 setMessage(message
, WizardPage
.ERROR
);
94 setMessage("Complete", WizardPage
.INFORMATION
);
95 setPageComplete(true);
99 /** @return error message or null if complete */
100 protected String
checkComplete() {
101 String groupStr
= groupNameTxt
.getText();
102 if (groupStr
== null || "".equals(groupStr
))
103 return "Please enter the name of the corresponding group.";
104 // Remove regexp check for the time being.
105 // else if (!match(groupStr))
107 // "Please use only alphanumerical chars for the short technical name.";