X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=server%2Fplugins%2Forg.argeo.jcr.ui.explorer%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fjcr%2Fui%2Fexplorer%2Fwizards%2FChooseRightsPage.java;fp=server%2Fplugins%2Forg.argeo.jcr.ui.explorer%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fjcr%2Fui%2Fexplorer%2Fwizards%2FChooseRightsPage.java;h=69948ce83ef78b55768f98cc2246877e6874a9f7;hb=fc4c9f53197bc7c0a9a30bc6c55cfd1c162ebd9a;hp=0000000000000000000000000000000000000000;hpb=ffbf3eaee8f314760414c948ad2c2a901855ee81;p=lgpl%2Fargeo-commons.git diff --git a/server/plugins/org.argeo.jcr.ui.explorer/src/main/java/org/argeo/jcr/ui/explorer/wizards/ChooseRightsPage.java b/server/plugins/org.argeo.jcr.ui.explorer/src/main/java/org/argeo/jcr/ui/explorer/wizards/ChooseRightsPage.java new file mode 100644 index 000000000..69948ce83 --- /dev/null +++ b/server/plugins/org.argeo.jcr.ui.explorer/src/main/java/org/argeo/jcr/ui/explorer/wizards/ChooseRightsPage.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.argeo.jcr.ui.explorer.wizards; + +import javax.jcr.security.Privilege; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class ChooseRightsPage extends WizardPage implements ModifyListener { + + // This page widget + private Text groupNameTxt; + private Combo authorizationCmb; + + // USABLE SHORTCUTS + protected final static String[] validAuthType = { Privilege.JCR_READ, + Privilege.JCR_WRITE, Privilege.JCR_ALL }; + + public ChooseRightsPage(String path) { + super("Main"); + setTitle("Add privilege to " + path); + } + + public void createControl(Composite parent) { + // specify subject + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout(2, false)); + Label lbl = new Label(composite, SWT.LEAD); + lbl.setText("Group or user name (no blank, no special chars)"); + lbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); + groupNameTxt = new Text(composite, SWT.LEAD | SWT.BORDER); + groupNameTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, + false)); + if (groupNameTxt != null) + groupNameTxt.addModifyListener(this); + + // Choose rigths + new Label(composite, SWT.NONE).setText("Choose corresponding rights"); + authorizationCmb = new Combo(composite, SWT.BORDER | SWT.V_SCROLL); + authorizationCmb.setItems(validAuthType); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + authorizationCmb.setLayoutData(gd); + + authorizationCmb.select(0); + + // Compulsory + setControl(composite); + } + + protected String getGroupName() { + return groupNameTxt.getText(); + } + + protected String getAuthTypeStr() { + return authorizationCmb.getItem(authorizationCmb.getSelectionIndex()); + } + + public void modifyText(ModifyEvent event) { + String message = checkComplete(); + if (message != null) + setMessage(message, WizardPage.ERROR); + else { + setMessage("Complete", WizardPage.INFORMATION); + setPageComplete(true); + } + } + + /** @return error message or null if complete */ + protected String checkComplete() { + String groupStr = groupNameTxt.getText(); + if (groupStr == null || "".equals(groupStr)) + return "Please enter the name of the corresponding group."; + // Remove regexp check for the time being. + // else if (!match(groupStr)) + // return + // "Please use only alphanumerical chars for the short technical name."; + return null; + } +}