|
@@ -1,13 +1,9 @@ |
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 |
4 |
|
import org.litesoft.GWT.forms.client.components.*; |
8 |
5 |
|
import org.litesoft.bo.views.*; |
9 |
6 |
|
import org.litesoft.commonfoundation.base.*; |
10 |
|
- |
import org.litesoft.core.*; |
11 |
7 |
|
import org.litesoft.security.*; |
12 |
8 |
|
import org.litesoft.uispecification.*; |
13 |
9 |
|
|
|
@@ -16,10 +12,6 @@ |
16 |
12 |
|
import static org.litesoft.uispecification.FormWidgetCtrl.*; |
17 |
13 |
|
|
18 |
14 |
|
public class ChangePassword<T extends SecurityUserView<T>> extends AbstractSecurityDialogView<T> implements SecurityUserViewNames { |
19 |
|
- |
private FormBinder<T> mFormBinder; |
20 |
|
- |
private ButtonBase mSubmitButton; |
21 |
|
- |
private boolean mAllowCancel; |
22 |
|
- |
|
23 |
15 |
|
public ChangePassword( String pSection, ViewDef pViewDef ) { |
24 |
16 |
|
this( title( pSection, pViewDef ), true ); |
25 |
17 |
|
} |
|
@@ -29,57 +21,44 @@ |
29 |
21 |
|
this( title( pTitle ), false ); |
30 |
22 |
|
} |
31 |
23 |
|
|
32 |
|
- |
private ChangePassword( CO pCO, boolean pAllowCancel ) { |
33 |
|
- |
super( pCO, Opaqueness.Semi ); |
34 |
|
- |
|
35 |
|
- |
mAllowCancel = pAllowCancel; |
|
24 |
+ |
private ChangePassword( CO pCO, boolean pCancelable ) { |
|
25 |
+ |
super( pCO, Opaqueness.Semi, pCancelable ); |
36 |
26 |
|
|
37 |
|
- |
ClientContext zContext = ClientContext.get(); |
|
27 |
+ |
centerContent(); |
38 |
28 |
|
|
39 |
|
- |
final T zUser = ((AbstractCurrentUserViewAccessor<T>) zContext.get( AbstractCurrentUserViewAccessor.class )).getUser(); |
|
29 |
+ |
initializeFormInfrastructure( new MyListenerFactory() ) |
|
30 |
+ |
.add( VISIBLE_BUT_DISABLED, aLogonEmail ) |
|
31 |
+ |
.add( EDIT_ONLY.required(), aCurrentPassword, aNewPassword, aConfirmPassword ); |
40 |
32 |
|
|
41 |
|
- |
WidgetCtrlMap zWidgetCtrlMap = new WidgetCtrlMap( VISIBLE_AND_ACTIVE_ENABLED ); |
|
33 |
+ |
T zUser = getUserView(); |
42 |
34 |
|
|
43 |
|
- |
zWidgetCtrlMap.add( VISIBLE_BUT_DISABLED, aLogonEmail ); |
44 |
|
- |
zWidgetCtrlMap.add( EDIT_ONLY.required(), aCurrentPassword, aNewPassword, aConfirmPassword ); |
45 |
|
- |
|
46 |
|
- |
mFE = new FormEngine( zWidgetCtrlMap, FormEngine.Mode.EditRegular, new MyListenerFactory() ) { |
47 |
|
- |
@Override |
48 |
|
- |
protected void changeOccurredOn( String pName, IFormComponent pComponent, boolean pChanged ) { |
49 |
|
- |
super.changeOccurredOn( pName, pComponent, pChanged ); |
50 |
|
- |
setDialogErrorMessage( null ); |
51 |
|
- |
} |
|
35 |
+ |
add( new OurLabel( zUser.getFullName() ).style( "ChangePasswordUserName" ) ); |
|
36 |
+ |
addLogonAndPasswords(); |
|
37 |
+ |
add( new SizeableSpacer( 5 ).stretchable() ); |
52 |
38 |
|
|
53 |
|
- |
@Override |
54 |
|
- |
protected void enterPressedOn( String pName, IFormComponent pComponent, KeyboardKeyModifier pModifiers ) { |
55 |
|
- |
if ( !focusFromTo( pName, aCurrentPassword, aNewPassword ) ) { |
56 |
|
- |
if ( !focusFromTo( pName, aNewPassword, aConfirmPassword ) ) { |
57 |
|
- |
if ( pName.equals( aConfirmPassword ) && (mSubmitButton != null) && mSubmitButton.isEnabled() ) { |
58 |
|
- |
submitRequested(); |
59 |
|
- |
} else { |
60 |
|
- |
super.enterPressedOn( pName, pComponent, pModifiers ); |
61 |
|
- |
} |
62 |
|
- |
} |
63 |
|
- |
} |
64 |
|
- |
} |
|
39 |
+ |
setEditUser( mDataProvider.copyIntoNewTS( zUser ).clearPasswordFields() ); |
|
40 |
+ |
} |
65 |
41 |
|
|
66 |
|
- |
private boolean focusFromTo( String pNameActual, String pFrom, String pTo ) { |
67 |
|
- |
if ( pFrom.equals( pNameActual ) ) { |
68 |
|
- |
getNamedComponent( pTo ).setFocus(); |
|
42 |
+ |
@Override |
|
43 |
+ |
protected boolean processEnterPressedOn( String pName ) { |
|
44 |
+ |
if ( !focusFromTo( pName, aCurrentPassword, aNewPassword ) ) { |
|
45 |
+ |
if ( !focusFromTo( pName, aNewPassword, aConfirmPassword ) ) { |
|
46 |
+ |
if ( pName.equals( aConfirmPassword ) && (mSubmitButton != null) && mSubmitButton.isEnabled() ) { |
|
47 |
+ |
submitRequested(); |
|
48 |
+ |
} else { |
69 |
49 |
|
return true; |
70 |
50 |
|
} |
71 |
|
- |
return false; |
72 |
51 |
|
} |
73 |
|
- |
}; |
74 |
|
- |
mFormBinder = new FormBinder<T>( mFE, mUserViewMetaData ); |
75 |
|
- |
|
76 |
|
- |
mContent.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER ); |
77 |
|
- |
|
78 |
|
- |
add( new OurLabel( zUser.getFullName() ).style( "ChangePasswordUserName" ) ); |
79 |
|
- |
addLogonAndPasswords(); |
80 |
|
- |
add( new SizeableSpacer( 5 ).stretchable() ); |
|
52 |
+ |
} |
|
53 |
+ |
return false; |
|
54 |
+ |
} |
81 |
55 |
|
|
82 |
|
- |
mFormBinder.setExistingObject( mDataProvider.copyIntoNewTS( zUser ).clearPasswordFields(), FormEngine.Mode.EditRegular ); |
|
56 |
+ |
private boolean focusFromTo( String pNameActual, String pFrom, String pTo ) { |
|
57 |
+ |
if ( pFrom.equals( pNameActual ) ) { |
|
58 |
+ |
mFE.getNamedComponent( pTo ).setFocus(); |
|
59 |
+ |
return true; |
|
60 |
+ |
} |
|
61 |
+ |
return false; |
83 |
62 |
|
} |
84 |
63 |
|
|
85 |
64 |
|
private void addLogonAndPasswords() { |
|
@@ -104,26 +83,9 @@ |
104 |
83 |
|
} |
105 |
84 |
|
|
106 |
85 |
|
@Override |
107 |
|
- |
public Widget getBottomBar() { |
108 |
|
- |
LeftCenterRightHorizontalPanel zActionPanel = new LeftCenterRightHorizontalPanel(); |
109 |
|
- |
if ( mAllowCancel ) { |
110 |
|
- |
zActionPanel.addLeft( createCancelButton() ); |
111 |
|
- |
} |
112 |
|
- |
zActionPanel.addRight( mFE.addEditSubmitButton( mSubmitButton = createSubmitButton() ) ); |
113 |
|
- |
return zActionPanel; |
114 |
|
- |
} |
115 |
|
- |
|
116 |
|
- |
@Override |
117 |
|
- |
public void aboutToShow() { |
118 |
|
- |
super.aboutToShow(); |
119 |
|
- |
mFE.initialize(); |
120 |
|
- |
} |
121 |
|
- |
|
122 |
|
- |
@Override |
123 |
86 |
|
protected void justLoaded() { |
124 |
|
- |
super.justLoaded(); |
125 |
87 |
|
getStatusMessageSinc().clearMessage(); |
126 |
|
- |
mFE.setFocus(); |
|
88 |
+ |
super.justLoaded(); |
127 |
89 |
|
} |
128 |
90 |
|
|
129 |
91 |
|
@Override |