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