]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/jcr/internal/parts/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
.eclipse
.ui
.workbench
.jcr
.internal
.parts
;
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
{
32 private static final long serialVersionUID
= 8084431378762283920L;
35 private Text groupNameTxt
;
36 private Combo authorizationCmb
;
39 protected final static String
[] validAuthType
= { Privilege
.JCR_READ
,
40 Privilege
.JCR_WRITE
, Privilege
.JCR_ALL
};
42 public ChooseRightsPage(String path
) {
44 setTitle("Add privilege to " + path
);
47 public void createControl(Composite parent
) {
49 Composite composite
= new Composite(parent
, SWT
.NONE
);
50 composite
.setLayout(new GridLayout(2, false));
51 Label lbl
= new Label(composite
, SWT
.LEAD
);
52 lbl
.setText("Group or user name (no blank, no special chars)");
53 lbl
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, false, false));
54 groupNameTxt
= new Text(composite
, SWT
.LEAD
| SWT
.BORDER
);
55 groupNameTxt
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true,
57 if (groupNameTxt
!= null)
58 groupNameTxt
.addModifyListener(this);
61 new Label(composite
, SWT
.NONE
).setText("Choose corresponding rights");
62 authorizationCmb
= new Combo(composite
, SWT
.BORDER
| SWT
.V_SCROLL
);
63 authorizationCmb
.setItems(validAuthType
);
64 GridData gd
= new GridData(GridData
.FILL_HORIZONTAL
);
65 authorizationCmb
.setLayoutData(gd
);
67 authorizationCmb
.select(0);
70 setControl(composite
);
73 protected String
getGroupName() {
74 return groupNameTxt
.getText();
77 protected String
getAuthTypeStr() {
78 return authorizationCmb
.getItem(authorizationCmb
.getSelectionIndex());
81 public void modifyText(ModifyEvent event
) {
82 String message
= checkComplete();
84 setMessage(message
, WizardPage
.ERROR
);
86 setMessage("Complete", WizardPage
.INFORMATION
);
87 setPageComplete(true);
91 /** @return error message or null if complete */
92 protected String
checkComplete() {
93 String groupStr
= groupNameTxt
.getText();
94 if (groupStr
== null || "".equals(groupStr
))
95 return "Please enter the name of the corresponding group.";
96 // Remove regexp check for the time being.
97 // else if (!match(groupStr))
99 // "Please use only alphanumerical chars for the short technical name.";