]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - explorer/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
.jcr
.ui
.explorer
.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
;
38 protected final static String
[] validAuthType
= { Privilege
.JCR_READ
,
39 Privilege
.JCR_WRITE
, Privilege
.JCR_ALL
};
41 public ChooseRightsPage(String path
) {
43 setTitle("Add privilege to " + path
);
46 public void createControl(Composite parent
) {
48 Composite composite
= new Composite(parent
, SWT
.NONE
);
49 composite
.setLayout(new GridLayout(2, false));
50 Label lbl
= new Label(composite
, SWT
.LEAD
);
51 lbl
.setText("Group or user name (no blank, no special chars)");
52 lbl
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, false, false));
53 groupNameTxt
= new Text(composite
, SWT
.LEAD
| SWT
.BORDER
);
54 groupNameTxt
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true,
56 if (groupNameTxt
!= null)
57 groupNameTxt
.addModifyListener(this);
60 new Label(composite
, SWT
.NONE
).setText("Choose corresponding rights");
61 authorizationCmb
= new Combo(composite
, SWT
.BORDER
| SWT
.V_SCROLL
);
62 authorizationCmb
.setItems(validAuthType
);
63 GridData gd
= new GridData(GridData
.FILL_HORIZONTAL
);
64 authorizationCmb
.setLayoutData(gd
);
66 authorizationCmb
.select(0);
69 setControl(composite
);
72 protected String
getGroupName() {
73 return groupNameTxt
.getText();
76 protected String
getAuthTypeStr() {
77 return authorizationCmb
.getItem(authorizationCmb
.getSelectionIndex());
80 public void modifyText(ModifyEvent event
) {
81 String message
= checkComplete();
83 setMessage(message
, WizardPage
.ERROR
);
85 setMessage("Complete", WizardPage
.INFORMATION
);
86 setPageComplete(true);
90 /** @return error message or null if complete */
91 protected String
checkComplete() {
92 String groupStr
= groupNameTxt
.getText();
93 if (groupStr
== null || "".equals(groupStr
))
94 return "Please enter the name of the corresponding group.";
95 // Remove regexp check for the time being.
96 // else if (!match(groupStr))
98 // "Please use only alphanumerical chars for the short technical name.";