litesoft
@ 480
litesoft / trunk / GWT_Sandbox / Prioritizer / src / org / litesoft / prioritizer / client / ui / views / NewUserEmailDialog.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
package org.litesoft.prioritizer.client.ui.views; import org.litesoft.GWT.client.*; import org.litesoft.GWT.client.view.*; import org.litesoft.GWT.client.widgets.*; import org.litesoft.GWT.forms.client.*; import org.litesoft.bo.views.*; import org.litesoft.core.util.*; import org.litesoft.prioritizer.client.boviews.*; import org.litesoft.security.*; import com.google.gwt.user.client.ui.*; public class NewUserEmailDialog extends AbstractNewUserDialog implements NewUserPhoneConfirmationDialog.CallBack { public interface CallBack extends DialogCloseCallBack { public void succeeded( String pLogonEmail, UserView pUserView ); } private CallBack mCallBack; public NewUserEmailDialog( String pLogonEmail, String pPhoneNumber, CallBack pCallBack ) { super( pLogonEmail, pPhoneNumber, null ); UtilsCommon.assertNotNull( "CallBack", mCallBack = pCallBack ); setViewTitle( "New User" ); add( new SizeableSpacer( 5 ).stretchable() ); add( createLogonEmail() ); add( new SizeableSpacer( 5 ).stretchable() ); } @Override public void aboutToShow() { super.aboutToShow(); mFE.initialize(); mFE.setNamedComponentValueAsUser( UserViewNames.aLogonEmail, mLogonEmail ); } private Widget createLogonEmail() { FormBinder<UserView> zFormBinder = new FormBinder<UserView>( mFE, UserViewMetaData.getInstance() ); return zFormBinder.add( UserViewNames.aLogonEmail ); } @Override protected void submitRequested() { String zLogonEmail = UtilsCommon.noEmpty( (String) mFE.getNamedComponentValue( UserView.aLogonEmail ) ); if ( zLogonEmail != null ) { mDataProvider.validateLogonEmailAvailable( zLogonEmail, new FetchRowDataProviderCallBack<SecurityUserView>() { @Override public void error( String pError ) { setDialogErrorMessage( pError ); } @Override public void success( SecurityUserView pRow ) { if ( pRow == null ) // No row found, Go on to Add User { close(); mCallBack.succeeded( (String) mFE.getNamedComponentValue( UserViewNames.aLogonEmail ), null ); return; } if ( mPhoneNumber.equals( pRow.getPhoneNumber() ) ) // User found with same Logon & same entered PhoneNumber: Go on to Add User { close(); mCallBack.succeeded( (String) mFE.getNamedComponentValue( UserViewNames.aLogonEmail ), (UserView)pRow ); return; } mUserView = (UserView)pRow; new DialogViewDialog( new NewUserPhoneConfirmationDialog( mLogonEmail, mPhoneNumber, (UserView)pRow, NewUserEmailDialog.this ) ).show(); } } ); } } @Override public void succeeded() { close(); mCallBack.succeeded( (String) mFE.getNamedComponentValue( UserViewNames.aLogonEmail ), mUserView ); } @Override public void cancel() { super.cancel(); mCallBack.dialogClosed(); } protected static String cursoryEmailCheck( String pEmail, String pWhat ) { try { new EmailAddress( pEmail ); return null; } catch ( IllegalArgumentException e ) { return DeCamelizer.resolve( pWhat ) + " is unacceptable: " + e.getMessage(); } } } |