|
@@ -1,26 +1,96 @@ |
1 |
1 |
|
package org.litesoft.GWT.client.view; |
2 |
2 |
|
|
|
3 |
+ |
import org.litesoft.GWT.client.*; |
3 |
4 |
|
import org.litesoft.GWT.client.context.*; |
|
5 |
+ |
import org.litesoft.GWT.client.widgets.*; |
4 |
6 |
|
import org.litesoft.GWT.forms.client.*; |
|
7 |
+ |
import org.litesoft.GWT.forms.client.components.*; |
5 |
8 |
|
import org.litesoft.commonfoundation.base.*; |
6 |
9 |
|
import org.litesoft.commonfoundation.independence.*; |
7 |
10 |
|
import org.litesoft.security.*; |
8 |
11 |
|
|
|
12 |
+ |
import com.google.gwt.user.client.ui.*; |
|
13 |
+ |
|
|
14 |
+ |
import static org.litesoft.uispecification.FormWidgetCtrl.*; |
|
15 |
+ |
|
9 |
16 |
|
public abstract class AbstractSecurityDialogView<T extends SecurityUserView<T>> extends DialogView { |
10 |
17 |
|
protected final SecurityUserViewDataProvider<T> mDataProvider; |
11 |
18 |
|
protected final SecurityUserViewMetaData<T> mUserViewMetaData; |
12 |
19 |
|
protected FormEngine mFE; |
13 |
20 |
|
protected FormBinder<T> mFormBinder; |
|
21 |
+ |
protected ButtonBase mSubmitButton; |
|
22 |
+ |
protected boolean mCancelable; |
14 |
23 |
|
|
15 |
|
- |
public AbstractSecurityDialogView( CO pCO, Opaqueness pOpaqueness ) { |
|
24 |
+ |
public AbstractSecurityDialogView( CO pCO, Opaqueness pOpaqueness, boolean pCancelable ) { |
16 |
25 |
|
super( pCO, pOpaqueness ); |
|
26 |
+ |
mCancelable = pCancelable; |
17 |
27 |
|
|
18 |
28 |
|
mDataProvider = Cast.it( Instance.of( SecurityUserViewDataProvider.class ) ); |
19 |
29 |
|
mUserViewMetaData = Cast.it( Instance.of( SecurityUserViewMetaData.class ) ); |
20 |
30 |
|
} |
21 |
31 |
|
|
22 |
|
- |
protected FormBinder<T> createFormBinder() { |
23 |
|
- |
return mFormBinder = new FormBinder<T>( mFE, mUserViewMetaData ); |
|
32 |
+ |
@Override |
|
33 |
+ |
public final boolean isCancelable() { |
|
34 |
+ |
return mCancelable; |
|
35 |
+ |
} |
|
36 |
+ |
|
|
37 |
+ |
protected void centerContent() { |
|
38 |
+ |
mContent.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER ); |
|
39 |
+ |
} |
|
40 |
+ |
|
|
41 |
+ |
protected WidgetCtrlMap initializeFormInfrastructure( IFormComponent.Listener.Factory pListenerFactory ) { |
|
42 |
+ |
WidgetCtrlMap zWidgetCtrlMap = new WidgetCtrlMap( VISIBLE_AND_ACTIVE_ENABLED ); |
|
43 |
+ |
|
|
44 |
+ |
mFE = new FormEngine( zWidgetCtrlMap, FormEngine.Mode.EditRegular, pListenerFactory ) { |
|
45 |
+ |
@Override |
|
46 |
+ |
protected void changeOccurredOn( String pName, IFormComponent pComponent, boolean pChanged ) { |
|
47 |
+ |
super.changeOccurredOn( pName, pComponent, pChanged ); |
|
48 |
+ |
setDialogErrorMessage( null ); |
|
49 |
+ |
} |
|
50 |
+ |
|
|
51 |
+ |
@Override |
|
52 |
+ |
protected void enterPressedOn( String pName, IFormComponent pComponent, KeyboardKeyModifier pModifiers ) { |
|
53 |
+ |
if ( processEnterPressedOn( pName ) ) { |
|
54 |
+ |
super.enterPressedOn( pName, pComponent, pModifiers ); |
|
55 |
+ |
} |
|
56 |
+ |
} |
|
57 |
+ |
}; |
|
58 |
+ |
mFormBinder = new FormBinder<T>( mFE, mUserViewMetaData ); |
|
59 |
+ |
return zWidgetCtrlMap; |
|
60 |
+ |
} |
|
61 |
+ |
|
|
62 |
+ |
abstract protected boolean processEnterPressedOn( String pName ); |
|
63 |
+ |
|
|
64 |
+ |
protected T getUserView() { |
|
65 |
+ |
return Cast.it( Instance.of( AbstractCurrentUserViewAccessor.class ).getUser() ); |
|
66 |
+ |
} |
|
67 |
+ |
|
|
68 |
+ |
protected void setEditUser( T pUserView ) { |
|
69 |
+ |
mFormBinder.setExistingObject( pUserView, FormEngine.Mode.EditRegular ); |
|
70 |
+ |
} |
|
71 |
+ |
|
|
72 |
+ |
@Override |
|
73 |
+ |
public Widget getBottomBar() { |
|
74 |
+ |
LeftCenterRightHorizontalPanel zActionPanel = new LeftCenterRightHorizontalPanel(); |
|
75 |
+ |
if ( mCancelable ) { |
|
76 |
+ |
zActionPanel.addLeft( createCancelButton() ); |
|
77 |
+ |
} |
|
78 |
+ |
zActionPanel.addRight( mSubmitButton = createRightButton() ); |
|
79 |
+ |
return zActionPanel; |
|
80 |
+ |
} |
|
81 |
+ |
|
|
82 |
+ |
protected ButtonBase createLeftButton() { |
|
83 |
+ |
return createCancelButton(); |
|
84 |
+ |
} |
|
85 |
+ |
|
|
86 |
+ |
protected ButtonBase createRightButton() { |
|
87 |
+ |
return mFE.addEditSubmitButton( createSubmitButton() ); |
|
88 |
+ |
} |
|
89 |
+ |
|
|
90 |
+ |
@Override |
|
91 |
+ |
public void aboutToShow() { |
|
92 |
+ |
super.aboutToShow(); |
|
93 |
+ |
mFE.initialize(); |
24 |
94 |
|
} |
25 |
95 |
|
|
26 |
96 |
|
@Override |