|
@@ -1,142 +1,142 @@ |
1 |
|
- |
package org.litesoft.GWT.client.view; |
2 |
|
- |
|
3 |
|
- |
import org.litesoft.GWT.client.*; |
4 |
|
- |
import org.litesoft.GWT.client.context.*; |
5 |
|
- |
import org.litesoft.GWT.client.widgets.*; |
6 |
|
- |
import org.litesoft.GWT.forms.client.*; |
7 |
|
- |
import org.litesoft.GWT.forms.client.components.*; |
8 |
|
- |
import org.litesoft.bo.views.*; |
9 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
10 |
|
- |
import org.litesoft.core.*; |
11 |
|
- |
import org.litesoft.security.*; |
12 |
|
- |
|
13 |
|
- |
import com.google.gwt.core.client.*; |
14 |
|
- |
import com.google.gwt.event.dom.client.*; |
15 |
|
- |
import com.google.gwt.user.client.*; |
16 |
|
- |
import com.google.gwt.user.client.ui.*; |
17 |
|
- |
|
18 |
|
- |
import static org.litesoft.uispecification.FormWidgetAspectCtrl.*; |
19 |
|
- |
import static org.litesoft.uispecification.FormWidgetCtrl.*; |
20 |
|
- |
|
21 |
|
- |
public class SuspendDialogFactory<T extends SecurityUserView<T>> implements SuspendDialogViewFactory { |
22 |
|
- |
@Override |
23 |
|
- |
public DialogView createDialog( LogoutCallBack pCallBack ) { |
24 |
|
- |
return new SuspendDialog<T>( pCallBack ); |
25 |
|
- |
} |
26 |
|
- |
|
27 |
|
- |
private static class SuspendDialog<T extends SecurityUserView<T>> extends DialogView implements SecurityUserViewNames { |
28 |
|
- |
private FormEngine mFE; |
29 |
|
- |
|
30 |
|
- |
private SecurityUserViewDataProvider<T> mDataProvider; |
31 |
|
- |
private FormBinder<T> mFormBinder; |
32 |
|
- |
private ButtonBase mSubmitButton; |
33 |
|
- |
|
34 |
|
- |
private LogoutCallBack mLogoutCallBack; |
35 |
|
- |
|
36 |
|
- |
public SuspendDialog( LogoutCallBack pLogoutCallBack ) { |
37 |
|
- |
super( null, Opaqueness.Full ); |
38 |
|
- |
Objects.assertNotNull( "LogoutCallBack", mLogoutCallBack = pLogoutCallBack ); |
39 |
|
- |
|
40 |
|
- |
ClientContext zContext = ClientContext.get(); |
41 |
|
- |
|
42 |
|
- |
mDataProvider = zContext.get( SecurityUserViewDataProvider.class ); |
43 |
|
- |
SecurityUserViewMetaData<T> zUserViewMetaData = zContext.get( SecurityUserViewMetaData.class ); |
44 |
|
- |
|
45 |
|
- |
T zUser = ((AbstractCurrentUserViewAccessor<T>) zContext.get( AbstractCurrentUserViewAccessor.class )).getUser(); |
46 |
|
- |
|
47 |
|
- |
setViewTitle( "Locked by " + zUser ); |
48 |
|
- |
|
49 |
|
- |
WidgetCtrlMap zWidgetCtrlMap = new WidgetCtrlMap( VISIBLE_AND_ACTIVE_ENABLED ); |
50 |
|
- |
|
51 |
|
- |
zWidgetCtrlMap.add( VISIBLE_BUT_DISABLED, aLogonEmail ); |
52 |
|
- |
zWidgetCtrlMap.add( Visible( Yes ).enable( Edit ).required(), aCurrentPassword ); |
53 |
|
- |
|
54 |
|
- |
mFE = new FormEngine( zWidgetCtrlMap, FormEngine.Mode.EditRegular, null ) { |
55 |
|
- |
@Override |
56 |
|
- |
protected void changeOccurredOn( String pName, IFormComponent pComponent, boolean pChanged ) { |
57 |
|
- |
super.changeOccurredOn( pName, pComponent, pChanged ); |
58 |
|
- |
setDialogErrorMessage( null ); |
59 |
|
- |
} |
60 |
|
- |
|
61 |
|
- |
@Override |
62 |
|
- |
protected void enterPressedOn( String pName, IFormComponent pComponent, KeyboardKeyModifier pModifiers ) { |
63 |
|
- |
if ( pName.equals( aCurrentPassword ) && (mSubmitButton != null) && mSubmitButton.isEnabled() ) { |
64 |
|
- |
submitRequested(); |
65 |
|
- |
} else { |
66 |
|
- |
super.enterPressedOn( pName, pComponent, pModifiers ); |
67 |
|
- |
} |
68 |
|
- |
} |
69 |
|
- |
}; |
70 |
|
- |
mFormBinder = new FormBinder<T>( mFE, zUserViewMetaData ); |
71 |
|
- |
|
72 |
|
- |
mContent.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER ); |
73 |
|
- |
|
74 |
|
- |
add( createLogonAndCurrentPassword() ); |
75 |
|
- |
add( new SizeableSpacer( 5 ).stretchable() ); |
76 |
|
- |
|
77 |
|
- |
mFormBinder.setExistingObject( mDataProvider.copyIntoNewTS( zUser ), FormEngine.Mode.EditRegular ); |
78 |
|
- |
} |
79 |
|
- |
|
80 |
|
- |
@Override |
81 |
|
- |
public boolean isCancelable() { |
82 |
|
- |
return false; |
83 |
|
- |
} |
84 |
|
- |
|
85 |
|
- |
private Widget createLogonAndCurrentPassword() { |
86 |
|
- |
SizeableHorizontalPanel zPanel = new SizeableHorizontalPanel().stretchableHorizontally(); |
87 |
|
- |
zPanel.add( mFormBinder.add( aLogonEmail, 0, LOGON ) ); |
88 |
|
- |
zPanel.add( mFormBinder.add( aCurrentPassword, PASSWORD_LENGTH, PASSWORD ) ); |
89 |
|
- |
return zPanel; |
90 |
|
- |
} |
91 |
|
- |
|
92 |
|
- |
@Override |
93 |
|
- |
public Widget getBottomBar() { |
94 |
|
- |
LeftCenterRightHorizontalPanel zActionPanel = new LeftCenterRightHorizontalPanel(); |
95 |
|
- |
zActionPanel.addLeft( LogoutRedButton.factory().add( new ClickHandler() { |
96 |
|
- |
@Override |
97 |
|
- |
public void onClick( ClickEvent event ) { |
98 |
|
- |
logoutRequested(); |
99 |
|
- |
} |
100 |
|
- |
} ).create() ); |
101 |
|
- |
zActionPanel.addRight( mFE.addEditSubmitButton( mSubmitButton = UnlockButton.factory().add( createSubmitClickHandler() ).create() ) ); |
102 |
|
- |
return zActionPanel; |
103 |
|
- |
} |
104 |
|
- |
|
105 |
|
- |
@Override |
106 |
|
- |
public void aboutToShow() { |
107 |
|
- |
super.aboutToShow(); |
108 |
|
- |
mFE.initialize(); |
109 |
|
- |
} |
110 |
|
- |
|
111 |
|
- |
@Override |
112 |
|
- |
protected void justLoaded() { |
113 |
|
- |
super.justLoaded(); |
114 |
|
- |
mFE.setFocus(); |
115 |
|
- |
} |
116 |
|
- |
|
117 |
|
- |
private void logoutRequested() { |
118 |
|
- |
close(); |
119 |
|
- |
Scheduler.get().scheduleDeferred( new Command() { |
120 |
|
- |
@Override |
121 |
|
- |
public void execute() { |
122 |
|
- |
mLogoutCallBack.logoutConfirmed(); |
123 |
|
- |
} |
124 |
|
- |
} ); |
125 |
|
- |
} |
126 |
|
- |
|
127 |
|
- |
@Override |
128 |
|
- |
protected void submitRequested() { |
129 |
|
- |
mFormBinder.commitForm(); |
130 |
|
- |
mDataProvider.validatePassword( mFormBinder.getObject(), new SimpleDataProviderCallBack() { |
131 |
|
- |
@Override |
132 |
|
- |
public void error( String pError ) { |
133 |
|
- |
if ( Strings.isNotNullOrEmpty( pError ) ) { |
134 |
|
- |
setDialogErrorMessage( pError ); |
135 |
|
- |
} else { |
136 |
|
- |
close(); |
137 |
|
- |
} |
138 |
|
- |
} |
139 |
|
- |
} ); |
140 |
|
- |
} |
141 |
|
- |
} |
142 |
|
- |
} |
|
1 |
+ |
package org.litesoft.GWT.client.view; |
|
2 |
+ |
|
|
3 |
+ |
import org.litesoft.GWT.client.*; |
|
4 |
+ |
import org.litesoft.GWT.client.context.*; |
|
5 |
+ |
import org.litesoft.GWT.client.widgets.*; |
|
6 |
+ |
import org.litesoft.GWT.forms.client.*; |
|
7 |
+ |
import org.litesoft.GWT.forms.client.components.*; |
|
8 |
+ |
import org.litesoft.bo.views.*; |
|
9 |
+ |
import org.litesoft.commonfoundation.base.*; |
|
10 |
+ |
import org.litesoft.core.*; |
|
11 |
+ |
import org.litesoft.security.*; |
|
12 |
+ |
|
|
13 |
+ |
import com.google.gwt.core.client.*; |
|
14 |
+ |
import com.google.gwt.event.dom.client.*; |
|
15 |
+ |
import com.google.gwt.user.client.*; |
|
16 |
+ |
import com.google.gwt.user.client.ui.*; |
|
17 |
+ |
|
|
18 |
+ |
import static org.litesoft.uispecification.FormWidgetAspectCtrl.*; |
|
19 |
+ |
import static org.litesoft.uispecification.FormWidgetCtrl.*; |
|
20 |
+ |
|
|
21 |
+ |
public class SuspendDialogFactory<T extends SecurityUserView<T>> implements SuspendDialogViewFactory { |
|
22 |
+ |
@Override |
|
23 |
+ |
public DialogView createDialog( LogoutCallBack pCallBack ) { |
|
24 |
+ |
return new SuspendDialog<T>( pCallBack ); |
|
25 |
+ |
} |
|
26 |
+ |
|
|
27 |
+ |
private static class SuspendDialog<T extends SecurityUserView<T>> extends DialogView implements SecurityUserViewNames { |
|
28 |
+ |
private FormEngine mFE; |
|
29 |
+ |
|
|
30 |
+ |
private SecurityUserViewDataProvider<T> mDataProvider; |
|
31 |
+ |
private FormBinder<T> mFormBinder; |
|
32 |
+ |
private ButtonBase mSubmitButton; |
|
33 |
+ |
|
|
34 |
+ |
private LogoutCallBack mLogoutCallBack; |
|
35 |
+ |
|
|
36 |
+ |
public SuspendDialog( LogoutCallBack pLogoutCallBack ) { |
|
37 |
+ |
super( null, Opaqueness.Full ); |
|
38 |
+ |
Confirm.isNotNull( "LogoutCallBack", mLogoutCallBack = pLogoutCallBack ); |
|
39 |
+ |
|
|
40 |
+ |
ClientContext zContext = ClientContext.get(); |
|
41 |
+ |
|
|
42 |
+ |
mDataProvider = zContext.get( SecurityUserViewDataProvider.class ); |
|
43 |
+ |
SecurityUserViewMetaData<T> zUserViewMetaData = zContext.get( SecurityUserViewMetaData.class ); |
|
44 |
+ |
|
|
45 |
+ |
T zUser = ((AbstractCurrentUserViewAccessor<T>) zContext.get( AbstractCurrentUserViewAccessor.class )).getUser(); |
|
46 |
+ |
|
|
47 |
+ |
setViewTitle( "Locked by " + zUser ); |
|
48 |
+ |
|
|
49 |
+ |
WidgetCtrlMap zWidgetCtrlMap = new WidgetCtrlMap( VISIBLE_AND_ACTIVE_ENABLED ); |
|
50 |
+ |
|
|
51 |
+ |
zWidgetCtrlMap.add( VISIBLE_BUT_DISABLED, aLogonEmail ); |
|
52 |
+ |
zWidgetCtrlMap.add( Visible( Yes ).enable( Edit ).required(), aCurrentPassword ); |
|
53 |
+ |
|
|
54 |
+ |
mFE = new FormEngine( zWidgetCtrlMap, FormEngine.Mode.EditRegular, null ) { |
|
55 |
+ |
@Override |
|
56 |
+ |
protected void changeOccurredOn( String pName, IFormComponent pComponent, boolean pChanged ) { |
|
57 |
+ |
super.changeOccurredOn( pName, pComponent, pChanged ); |
|
58 |
+ |
setDialogErrorMessage( null ); |
|
59 |
+ |
} |
|
60 |
+ |
|
|
61 |
+ |
@Override |
|
62 |
+ |
protected void enterPressedOn( String pName, IFormComponent pComponent, KeyboardKeyModifier pModifiers ) { |
|
63 |
+ |
if ( pName.equals( aCurrentPassword ) && (mSubmitButton != null) && mSubmitButton.isEnabled() ) { |
|
64 |
+ |
submitRequested(); |
|
65 |
+ |
} else { |
|
66 |
+ |
super.enterPressedOn( pName, pComponent, pModifiers ); |
|
67 |
+ |
} |
|
68 |
+ |
} |
|
69 |
+ |
}; |
|
70 |
+ |
mFormBinder = new FormBinder<T>( mFE, zUserViewMetaData ); |
|
71 |
+ |
|
|
72 |
+ |
mContent.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER ); |
|
73 |
+ |
|
|
74 |
+ |
add( createLogonAndCurrentPassword() ); |
|
75 |
+ |
add( new SizeableSpacer( 5 ).stretchable() ); |
|
76 |
+ |
|
|
77 |
+ |
mFormBinder.setExistingObject( mDataProvider.copyIntoNewTS( zUser ), FormEngine.Mode.EditRegular ); |
|
78 |
+ |
} |
|
79 |
+ |
|
|
80 |
+ |
@Override |
|
81 |
+ |
public boolean isCancelable() { |
|
82 |
+ |
return false; |
|
83 |
+ |
} |
|
84 |
+ |
|
|
85 |
+ |
private Widget createLogonAndCurrentPassword() { |
|
86 |
+ |
SizeableHorizontalPanel zPanel = new SizeableHorizontalPanel().stretchableHorizontally(); |
|
87 |
+ |
zPanel.add( mFormBinder.add( aLogonEmail, 0, LOGON ) ); |
|
88 |
+ |
zPanel.add( mFormBinder.add( aCurrentPassword, PASSWORD_LENGTH, PASSWORD ) ); |
|
89 |
+ |
return zPanel; |
|
90 |
+ |
} |
|
91 |
+ |
|
|
92 |
+ |
@Override |
|
93 |
+ |
public Widget getBottomBar() { |
|
94 |
+ |
LeftCenterRightHorizontalPanel zActionPanel = new LeftCenterRightHorizontalPanel(); |
|
95 |
+ |
zActionPanel.addLeft( LogoutRedButton.factory().add( new ClickHandler() { |
|
96 |
+ |
@Override |
|
97 |
+ |
public void onClick( ClickEvent event ) { |
|
98 |
+ |
logoutRequested(); |
|
99 |
+ |
} |
|
100 |
+ |
} ).create() ); |
|
101 |
+ |
zActionPanel.addRight( mFE.addEditSubmitButton( mSubmitButton = UnlockButton.factory().add( createSubmitClickHandler() ).create() ) ); |
|
102 |
+ |
return zActionPanel; |
|
103 |
+ |
} |
|
104 |
+ |
|
|
105 |
+ |
@Override |
|
106 |
+ |
public void aboutToShow() { |
|
107 |
+ |
super.aboutToShow(); |
|
108 |
+ |
mFE.initialize(); |
|
109 |
+ |
} |
|
110 |
+ |
|
|
111 |
+ |
@Override |
|
112 |
+ |
protected void justLoaded() { |
|
113 |
+ |
super.justLoaded(); |
|
114 |
+ |
mFE.setFocus(); |
|
115 |
+ |
} |
|
116 |
+ |
|
|
117 |
+ |
private void logoutRequested() { |
|
118 |
+ |
close(); |
|
119 |
+ |
Scheduler.get().scheduleDeferred( new Command() { |
|
120 |
+ |
@Override |
|
121 |
+ |
public void execute() { |
|
122 |
+ |
mLogoutCallBack.logoutConfirmed(); |
|
123 |
+ |
} |
|
124 |
+ |
} ); |
|
125 |
+ |
} |
|
126 |
+ |
|
|
127 |
+ |
@Override |
|
128 |
+ |
protected void submitRequested() { |
|
129 |
+ |
mFormBinder.commitForm(); |
|
130 |
+ |
mDataProvider.validatePassword( mFormBinder.getObject(), new SimpleDataProviderCallBack() { |
|
131 |
+ |
@Override |
|
132 |
+ |
public void error( String pError ) { |
|
133 |
+ |
if ( Currently.isNotNullOrEmpty( pError ) ) { |
|
134 |
+ |
setDialogErrorMessage( pError ); |
|
135 |
+ |
} else { |
|
136 |
+ |
close(); |
|
137 |
+ |
} |
|
138 |
+ |
} |
|
139 |
+ |
} ); |
|
140 |
+ |
} |
|
141 |
+ |
} |
|
142 |
+ |
} |