|
@@ -1,13 +1,8 @@ |
1 |
1 |
|
package org.litesoft.GWT.client.view; |
2 |
2 |
|
|
3 |
|
- |
import org.litesoft.GWT.client.*; |
4 |
|
- |
import org.litesoft.GWT.client.context.*; |
5 |
3 |
|
import org.litesoft.GWT.client.widgets.*; |
6 |
|
- |
import org.litesoft.GWT.forms.client.*; |
7 |
|
- |
import org.litesoft.GWT.forms.client.components.*; |
8 |
4 |
|
import org.litesoft.bo.views.*; |
9 |
5 |
|
import org.litesoft.commonfoundation.base.*; |
10 |
|
- |
import org.litesoft.core.*; |
11 |
6 |
|
import org.litesoft.security.*; |
12 |
7 |
|
|
13 |
8 |
|
import com.google.gwt.core.client.*; |
|
@@ -23,54 +18,34 @@ |
23 |
18 |
|
} |
24 |
19 |
|
|
25 |
20 |
|
private static class LoginDialog<T extends SecurityUserView<T>> extends AbstractSecurityDialogView<T> implements SecurityUserViewNames { |
26 |
|
- |
private FormBinder<T> mFormBinder; |
27 |
|
- |
private ButtonBase mSubmitButton; |
28 |
|
- |
|
29 |
|
- |
private boolean mCancelable; |
30 |
|
- |
private Command mOnSuccess; |
|
21 |
+ |
private final Command mOnSuccess; |
31 |
22 |
|
|
32 |
23 |
|
public LoginDialog( boolean pCancelable, Command pOnSuccess ) { |
33 |
|
- |
super( title( "Login" ), Opaqueness.Full ); |
34 |
|
- |
mCancelable = pCancelable; |
35 |
|
- |
Confirm.isNotNull( "OnSuccess", mOnSuccess = pOnSuccess ); |
36 |
|
- |
|
37 |
|
- |
ClientContext zContext = ClientContext.get(); |
38 |
|
- |
|
39 |
|
- |
WidgetCtrlMap zWidgetCtrlMap = new WidgetCtrlMap( VISIBLE_AND_ACTIVE_ENABLED ); |
40 |
|
- |
|
41 |
|
- |
zWidgetCtrlMap.add( EDIT_ONLY.required(), aLogonEmail, aCurrentPassword ); |
42 |
|
- |
|
43 |
|
- |
mFE = new FormEngine( zWidgetCtrlMap, FormEngine.Mode.EditRegular, null ) { |
44 |
|
- |
@Override |
45 |
|
- |
protected void changeOccurredOn( String pName, IFormComponent pComponent, boolean pChanged ) { |
46 |
|
- |
super.changeOccurredOn( pName, pComponent, pChanged ); |
47 |
|
- |
setDialogErrorMessage( null ); |
48 |
|
- |
} |
49 |
|
- |
|
50 |
|
- |
@Override |
51 |
|
- |
protected void enterPressedOn( String pName, IFormComponent pComponent, KeyboardKeyModifier pModifiers ) { |
52 |
|
- |
if ( pName.equals( aLogonEmail ) ) { |
53 |
|
- |
getNamedComponent( aCurrentPassword ).setFocus(); |
54 |
|
- |
} else if ( pName.equals( aCurrentPassword ) && (mSubmitButton != null) && mSubmitButton.isEnabled() ) { |
55 |
|
- |
submitRequested(); |
56 |
|
- |
} else { |
57 |
|
- |
super.enterPressedOn( pName, pComponent, pModifiers ); |
58 |
|
- |
} |
59 |
|
- |
} |
60 |
|
- |
}; |
61 |
|
- |
mFormBinder = new FormBinder<T>( mFE, mUserViewMetaData ); |
|
24 |
+ |
super( title( "Login" ), Opaqueness.Full, pCancelable ); |
|
25 |
+ |
mOnSuccess = Confirm.isNotNull( "OnSuccess", pOnSuccess ); |
|
26 |
+ |
|
|
27 |
+ |
centerContent(); |
62 |
28 |
|
|
63 |
|
- |
mContent.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER ); |
|
29 |
+ |
initializeFormInfrastructure( null ) |
|
30 |
+ |
.add( EDIT_ONLY.required(), aLogonEmail, aCurrentPassword ); |
64 |
31 |
|
|
65 |
32 |
|
add( createLogonAndCurrentPassword() ); |
66 |
33 |
|
add( new SizeableSpacer( 5 ).stretchable() ); |
67 |
34 |
|
|
68 |
|
- |
mFormBinder.setExistingObject( mDataProvider.createNew(), FormEngine.Mode.EditRegular ); |
|
35 |
+ |
setEditUser( mDataProvider.createNew() ); |
69 |
36 |
|
} |
70 |
37 |
|
|
71 |
38 |
|
@Override |
72 |
|
- |
public boolean isCancelable() { |
73 |
|
- |
return mCancelable; |
|
39 |
+ |
protected boolean processEnterPressedOn( String pName ) { |
|
40 |
+ |
if ( pName.equals( aLogonEmail ) ) { |
|
41 |
+ |
mFE.getNamedComponent( aCurrentPassword ).setFocus(); |
|
42 |
+ |
return false; |
|
43 |
+ |
} |
|
44 |
+ |
if ( pName.equals( aCurrentPassword ) && (mSubmitButton != null) && mSubmitButton.isEnabled() ) { |
|
45 |
+ |
submitRequested(); |
|
46 |
+ |
return false; |
|
47 |
+ |
} |
|
48 |
+ |
return true; |
74 |
49 |
|
} |
75 |
50 |
|
|
76 |
51 |
|
private Widget createLogonAndCurrentPassword() { |
|
@@ -81,28 +56,6 @@ |
81 |
56 |
|
} |
82 |
57 |
|
|
83 |
58 |
|
@Override |
84 |
|
- |
public Widget getBottomBar() { |
85 |
|
- |
LeftCenterRightHorizontalPanel zActionPanel = new LeftCenterRightHorizontalPanel(); |
86 |
|
- |
if ( mCancelable ) { |
87 |
|
- |
zActionPanel.addLeft( createCancelButton() ); |
88 |
|
- |
} |
89 |
|
- |
zActionPanel.addRight( mFE.addEditSubmitButton( mSubmitButton = createSubmitButton() ) ); |
90 |
|
- |
return zActionPanel; |
91 |
|
- |
} |
92 |
|
- |
|
93 |
|
- |
@Override |
94 |
|
- |
public void aboutToShow() { |
95 |
|
- |
super.aboutToShow(); |
96 |
|
- |
mFE.initialize(); |
97 |
|
- |
} |
98 |
|
- |
|
99 |
|
- |
@Override |
100 |
|
- |
protected void justLoaded() { |
101 |
|
- |
super.justLoaded(); |
102 |
|
- |
mFE.setFocus(); |
103 |
|
- |
} |
104 |
|
- |
|
105 |
|
- |
@Override |
106 |
59 |
|
protected void submitRequested() { |
107 |
60 |
|
mFormBinder.commitForm(); |
108 |
61 |
|
final T zUserView = mFormBinder.getObject(); |