litesoft
@ 487
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 |
package org.litesoft.GWT.client.view; import org.litesoft.GWT.client.*; 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.security.*; import com.google.gwt.user.client.ui.*; public class NewUserEmailDialog<T extends SecurityUserView<T>> extends AbstractNewUserDialog<T> implements NewUserPhoneConfirmationDialog.CallBack { public interface CallBack<T extends SecurityUserView<T>> extends DialogCloseCallBack { public void succeeded( String pLogonEmail, T pUserView ); } private CallBack mCallBack; public NewUserEmailDialog( String pLogonEmail, String pPhoneNumber, CallBack pCallBack, QBEinputPanelAccessorFactory<T> pUserFieldsPanelFactory ) { super( title( "New User" ), pLogonEmail, pPhoneNumber, null, pUserFieldsPanelFactory ); UtilsCommon.assertNotNull( "CallBack", mCallBack = pCallBack ); add( new SizeableSpacer( 5 ).stretchable() ); add( createLogonEmail() ); add( new SizeableSpacer( 5 ).stretchable() ); } @Override public void aboutToShow() { super.aboutToShow(); mFE.initialize(); mFE.setNamedComponentValueAsUser( SecurityUserViewNames.aLogonEmail, mLogonEmail ); } private Widget createLogonEmail() { FormBinder<T> zFormBinder = new FormBinder<T>( mFE, mUserViewMetaData ); return zFormBinder.add( SecurityUserViewNames.aLogonEmail ); } @Override protected void submitRequested() { String zLogonEmail = UtilsCommon.noEmpty( (String) mFE.getNamedComponentValue( SecurityUserViewNames.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( SecurityUserViewNames.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( SecurityUserViewNames.aLogonEmail ), pRow ); return; } mUserView = (T) pRow; new DialogViewDialog( new NewUserPhoneConfirmationDialog( mLogonEmail, mPhoneNumber, mUserView, NewUserEmailDialog.this, mUserFieldsPanelFactory ) ).show(); } } ); } } @Override public void succeeded() { close(); mCallBack.succeeded( (String) mFE.getNamedComponentValue( SecurityUserViewNames.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(); } } } |