]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - MainUserInfoWizardPage.java
cf11f8517740685a7e021e4a47fcf2de79124e5e
1 package org
.argeo
.security
.ui
.admin
.wizards
;
3 import org
.argeo
.eclipse
.ui
.EclipseUiUtils
;
4 import org
.argeo
.security
.UserAdminService
;
5 import org
.eclipse
.jface
.wizard
.WizardPage
;
6 import org
.eclipse
.swt
.SWT
;
7 import org
.eclipse
.swt
.events
.ModifyEvent
;
8 import org
.eclipse
.swt
.events
.ModifyListener
;
9 import org
.eclipse
.swt
.layout
.FillLayout
;
10 import org
.eclipse
.swt
.layout
.GridLayout
;
11 import org
.eclipse
.swt
.widgets
.Composite
;
12 import org
.eclipse
.swt
.widgets
.Text
;
14 public class MainUserInfoWizardPage
extends WizardPage
implements
16 private Text username
, firstName
, lastName
, primaryEmail
;
18 public MainUserInfoWizardPage() {
20 setTitle("Required Information");
24 public void createControl(Composite parent
) {
25 parent
.setLayout(new FillLayout());
26 Composite composite
= new Composite(parent
, SWT
.NONE
);
27 composite
.setLayout(new GridLayout(2, false));
28 username
= EclipseUiUtils
.createGridLT(composite
, "Username", this);
29 primaryEmail
= EclipseUiUtils
.createGridLT(composite
, "Email", this);
30 firstName
= EclipseUiUtils
.createGridLT(composite
, "First name", this);
31 lastName
= EclipseUiUtils
.createGridLT(composite
, "Last name", this);
32 setControl(composite
);
36 public void modifyText(ModifyEvent event
) {
37 String message
= checkComplete();
39 setMessage(message
, WizardPage
.ERROR
);
41 setMessage("Complete", WizardPage
.INFORMATION
);
42 setPageComplete(true);
46 /** @return error message or null if complete */
47 protected String
checkComplete() {
48 if (!username
.getText().matches(UserAdminService
.USERNAME_PATTERN
))
49 return "Wrong user name format, should be lower case, between 3 and 15 characters with only '_' as acceptable special character.";
50 if (!primaryEmail
.getText().matches(UserAdminService
.EMAIL_PATTERN
))
51 return "Not a valid email address";
52 if (firstName
.getText().trim().equals(""))
53 return "Specify a first name";
54 if (lastName
.getText().trim().equals(""))
55 return "Specify a last name";
60 public boolean canFlipToNextPage() {
61 // TODO Auto-generated method stub
62 return super.canFlipToNextPage();
66 public boolean isPageComplete() {
67 // TODO Auto-generated method stub
68 return super.isPageComplete();