]>
git.argeo.org Git - gpl/argeo-slc.git/blob - 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 javax
.jcr
.security
.Privilege
;
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
;
31 public class ChooseRightsPage
extends WizardPage
implements ModifyListener
{
34 private Text groupNameTxt
;
35 private Combo authorizationCmb
;
37 // Define acceptable chars for the technical name
38 // private static Pattern p = Pattern.compile("^[A-Za-z0-9]+$");
41 protected final static String
[] validAuthType
= { Privilege
.JCR_READ
,
42 Privilege
.JCR_WRITE
, Privilege
.JCR_ALL
};
44 public ChooseRightsPage() {
46 setTitle("Manage authorizations on the current workspace");
49 public void createControl(Composite parent
) {
51 Composite composite
= new Composite(parent
, SWT
.NONE
);
52 composite
.setLayout(new GridLayout(2, false));
53 Label lbl
= new Label(composite
, SWT
.LEAD
);
54 lbl
.setText("Group or user name (no blank, no special chars)");
55 lbl
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, false, false));
56 groupNameTxt
= new Text(composite
, SWT
.LEAD
| SWT
.BORDER
);
57 groupNameTxt
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true,
59 if (groupNameTxt
!= null)
60 groupNameTxt
.addModifyListener(this);
63 new Label(composite
, SWT
.NONE
).setText("Choose corresponding rights");
64 authorizationCmb
= new Combo(composite
, SWT
.BORDER
| SWT
.V_SCROLL
);
65 authorizationCmb
.setItems(validAuthType
);
66 GridData gd
= new GridData(GridData
.FILL_HORIZONTAL
);
67 authorizationCmb
.setLayoutData(gd
);
69 authorizationCmb
.select(0);
72 setControl(composite
);
75 protected String
getGroupName() {
76 return groupNameTxt
.getText();
79 protected String
getAuthTypeStr() {
80 return authorizationCmb
.getItem(authorizationCmb
.getSelectionIndex());
83 // private static boolean match(String s) {
84 // return p.matcher(s).matches();
87 public void modifyText(ModifyEvent event
) {
88 String message
= checkComplete();
90 setMessage(message
, WizardPage
.ERROR
);
92 setMessage("Complete", WizardPage
.INFORMATION
);
93 setPageComplete(true);
97 /** @return error message or null if complete */
98 protected String
checkComplete() {
99 String groupStr
= groupNameTxt
.getText();
100 if (groupStr
== null || "".equals(groupStr
))
101 return "Please enter the name of the corresponding group.";
102 // Remove regexp check for the time being.
103 // else if (!match(groupStr))
105 // "Please use only alphanumerical chars for the short technical name.";