|
@@ -18,39 +18,31 @@ |
18 |
18 |
|
* mechanism. |
19 |
19 |
|
*/ |
20 |
20 |
|
public class ViewManagerImpl extends AbstractViewManager implements ValueChangeHandler<String>, |
21 |
|
- |
SecurityIssueable |
22 |
|
- |
{ |
|
21 |
+ |
SecurityIssueable { |
23 |
22 |
|
private final TransientScreenProperties mNextScreenProperties = new TransientScreenProperties(); |
24 |
23 |
|
|
25 |
|
- |
public ViewManagerImpl( ViewAccessControlManager pAccessControlManager, ViewFactory... pFactories ) |
26 |
|
- |
{ |
|
24 |
+ |
public ViewManagerImpl( ViewAccessControlManager pAccessControlManager, ViewFactory... pFactories ) { |
27 |
25 |
|
super( pAccessControlManager, pFactories ); |
28 |
26 |
|
} |
29 |
27 |
|
|
30 |
|
- |
public void initialize() |
31 |
|
- |
{ |
|
28 |
+ |
public void initialize() { |
32 |
29 |
|
History.addValueChangeHandler( this ); |
33 |
30 |
|
onValueChangeImpl( History.getToken() ); |
34 |
31 |
|
} |
35 |
32 |
|
|
36 |
33 |
|
@Override |
37 |
|
- |
public void showDialog( ViewDef pViewDef, Object pParams ) |
38 |
|
- |
{ |
|
34 |
+ |
public void showDialog( ViewDef pViewDef, Object pParams ) { |
39 |
35 |
|
Objects.assertNotNull( "(Dialog) ViewDef", pViewDef ); |
40 |
36 |
|
ViewFactory zFactory = getViewFactory( pViewDef ); |
41 |
|
- |
if ( zFactory instanceof DialogViewFactory ) |
42 |
|
- |
{ |
|
37 |
+ |
if ( zFactory instanceof DialogViewFactory ) { |
43 |
38 |
|
new DialogViewDialog( ((DialogViewFactory) zFactory).createDialog( ClientContext.get(), pParams ) ).show(); |
44 |
|
- |
} |
45 |
|
- |
else |
46 |
|
- |
{ |
|
39 |
+ |
} else { |
47 |
40 |
|
AlertManager.alert( "ViewManager", "No Dialog Factory", "No Dialog for: " + pViewDef ); |
48 |
41 |
|
} |
49 |
42 |
|
} |
50 |
43 |
|
|
51 |
44 |
|
@Override |
52 |
|
- |
public void showScreen( ViewDef pViewDef, UriFragmentIdParams pParams, TransientScreenProperties pNextScreenProperties ) |
53 |
|
- |
{ |
|
45 |
+ |
public void showScreen( ViewDef pViewDef, UriFragmentIdParams pParams, TransientScreenProperties pNextScreenProperties ) { |
54 |
46 |
|
UtilsGwt.busyCursor(); |
55 |
47 |
|
Objects.assertNotNull( "(Screen) ViewDef", pViewDef ); |
56 |
48 |
|
mNextScreenProperties.putAll( pNextScreenProperties ); |
|
@@ -59,8 +51,7 @@ |
59 |
51 |
|
History.newItem( zFragmentId.toNewUriFragmentId( History.getToken() ), true ); // will "eventually" cause an AttachScreenCommand to be issued |
60 |
52 |
|
} |
61 |
53 |
|
|
62 |
|
- |
void showScreen( String pHistoryToken, TransientScreenProperties pNextScreenProperties ) |
63 |
|
- |
{ |
|
54 |
+ |
void showScreen( String pHistoryToken, TransientScreenProperties pNextScreenProperties ) { |
64 |
55 |
|
mNextScreenProperties.putAll( pNextScreenProperties ); |
65 |
56 |
|
onValueChangeImpl( pHistoryToken ); |
66 |
57 |
|
} |
|
@@ -69,36 +60,25 @@ |
69 |
60 |
|
{ |
70 |
61 |
|
String zUriFragmentId = ParameterizedUriFragmentId.removePrefix( pHistoryToken ); |
71 |
62 |
|
ParameterizedUriFragmentId zFragmentId; |
72 |
|
- |
try |
73 |
|
- |
{ |
|
63 |
+ |
try { |
74 |
64 |
|
zFragmentId = new ParameterizedUriFragmentId( zUriFragmentId ); |
75 |
65 |
|
} |
76 |
|
- |
catch ( IllegalArgumentException e ) |
77 |
|
- |
{ |
|
66 |
+ |
catch ( IllegalArgumentException e ) { |
78 |
67 |
|
LOGGER.warn.log( e, zUriFragmentId ); |
79 |
68 |
|
zFragmentId = ParameterizedUriFragmentId.DEFAULT; |
80 |
69 |
|
} |
81 |
70 |
|
|
82 |
|
- |
if ( mAccessControlManager.loginRequired() ) |
83 |
|
- |
{ |
|
71 |
+ |
if ( mAccessControlManager.loginRequired() ) { |
84 |
72 |
|
LoginServerStateChecker zChecker = ClientContext.get().checkGet( LoginServerStateChecker.class ); |
85 |
|
- |
if ( zChecker == null ) |
86 |
|
- |
{ |
|
73 |
+ |
if ( zChecker == null ) { |
87 |
74 |
|
requestUserLogin( pHistoryToken, null ); |
88 |
|
- |
} |
89 |
|
- |
else |
90 |
|
- |
{ |
91 |
|
- |
zChecker.checkServerLogin( new SimpleDataProviderCallBack() |
92 |
|
- |
{ |
|
75 |
+ |
} else { |
|
76 |
+ |
zChecker.checkServerLogin( new SimpleDataProviderCallBack() { |
93 |
77 |
|
@Override |
94 |
|
- |
public void error( String pError ) |
95 |
|
- |
{ |
96 |
|
- |
if ( mAccessControlManager.loginRequired() ) |
97 |
|
- |
{ |
|
78 |
+ |
public void error( String pError ) { |
|
79 |
+ |
if ( mAccessControlManager.loginRequired() ) { |
98 |
80 |
|
requestUserLogin( pHistoryToken, pError ); |
99 |
|
- |
} |
100 |
|
- |
else |
101 |
|
- |
{ |
|
81 |
+ |
} else { |
102 |
82 |
|
new LoginSuccessCommand( pHistoryToken, mNextScreenProperties ).execute(); |
103 |
83 |
|
} |
104 |
84 |
|
} |
|
@@ -108,12 +88,11 @@ |
108 |
88 |
|
} |
109 |
89 |
|
|
110 |
90 |
|
LoginPasswordResetAccessor zAccessor = ClientContext.get().get( LoginPasswordResetAccessor.class ); |
111 |
|
- |
if ( zAccessor.isPasswordResetRequired() ) |
112 |
|
- |
{ |
|
91 |
+ |
if ( zAccessor.isPasswordResetRequired() ) { |
113 |
92 |
|
LoginPasswordResetDialogViewFactory zFactory = ClientContext.get().get( LoginPasswordResetDialogViewFactory.class ); |
114 |
|
- |
if ( zFactory != null ) |
115 |
|
- |
{ |
116 |
|
- |
DialogView zView = zFactory.createDialog( ClientContext.get(), new LoginSuccessCommand( pHistoryToken, mNextScreenProperties, "Password updated" ) ); |
|
93 |
+ |
if ( zFactory != null ) { |
|
94 |
+ |
DialogView zView = |
|
95 |
+ |
zFactory.createDialog( ClientContext.get(), new LoginSuccessCommand( pHistoryToken, mNextScreenProperties, "Password updated" ) ); |
117 |
96 |
|
ClientContext.get().get( SingleWidgetPanel.class ).setWidget( new SizeableSpacer().stretchable() ); |
118 |
97 |
|
new DialogViewDialog( zView ).show(); |
119 |
98 |
|
return; |
|
@@ -125,34 +104,28 @@ |
125 |
104 |
|
ViewDef zViewDef = getViewDef( viewDefId ); |
126 |
105 |
|
|
127 |
106 |
|
UriFragmentIdParams zParams = UriFragmentIdParams.fromParamsString( viewParams ); |
128 |
|
- |
if ( zViewDef == null ) |
129 |
|
- |
{ |
|
107 |
+ |
if ( zViewDef == null ) { |
130 |
108 |
|
zViewDef = ViewDef.HOME; |
131 |
109 |
|
zParams = null; |
132 |
|
- |
if ( Strings.isNotNullOrEmpty( viewDefId ) ) |
133 |
|
- |
{ |
|
110 |
+ |
if ( Strings.isNotNullOrEmpty( viewDefId ) ) { |
134 |
111 |
|
mNextScreenProperties.ERROR.set( "No Screen for: " + viewDefId ); |
135 |
112 |
|
} |
136 |
113 |
|
} |
137 |
114 |
|
ViewFactory zFactory = getViewFactory( zViewDef ); |
138 |
|
- |
if ( !(zFactory instanceof ScreenViewFactory) ) |
139 |
|
- |
{ |
|
115 |
+ |
if ( !(zFactory instanceof ScreenViewFactory) ) { |
140 |
116 |
|
zParams = null; |
141 |
117 |
|
mNextScreenProperties.ERROR.set( "No Screen for: " + viewDefId ); |
142 |
118 |
|
zFactory = getViewFactory( zViewDef = ViewDef.HOME ); |
143 |
119 |
|
} |
144 |
120 |
|
|
145 |
|
- |
if ( zFactory == null ) |
146 |
|
- |
{ |
|
121 |
+ |
if ( zFactory == null ) { |
147 |
122 |
|
throw new IllegalStateException( "No Screen for: " + zViewDef ); |
148 |
123 |
|
} |
149 |
124 |
|
|
150 |
125 |
|
StatusMessageSinc zMessageSinc = ClientContext.get().checkGet( StatusMessageSinc.class ); |
151 |
|
- |
if ( zMessageSinc != null ) |
152 |
|
- |
{ |
|
126 |
+ |
if ( zMessageSinc != null ) { |
153 |
127 |
|
zMessageSinc.setErrorMessage( mNextScreenProperties.ERROR.get() ); |
154 |
|
- |
if ( Strings.isNullOrEmpty( mNextScreenProperties.ERROR.get() ) ) |
155 |
|
- |
{ |
|
128 |
+ |
if ( Strings.isNullOrEmpty( mNextScreenProperties.ERROR.get() ) ) { |
156 |
129 |
|
zMessageSinc.setWarningMessage( mNextScreenProperties.WARNING.get() ); |
157 |
130 |
|
} |
158 |
131 |
|
} |
|
@@ -164,13 +137,11 @@ |
164 |
137 |
|
} |
165 |
138 |
|
|
166 |
139 |
|
@Override |
167 |
|
- |
public void handleSecurityIssue( String pError ) |
168 |
|
- |
{ |
|
140 |
+ |
public void handleSecurityIssue( String pError ) { |
169 |
141 |
|
requestUserLogin( ViewDef.HOME.getFragmentID(), pError ); |
170 |
142 |
|
} |
171 |
143 |
|
|
172 |
|
- |
private void requestUserLogin( String pHistoryToken, String pError ) |
173 |
|
- |
{ |
|
144 |
+ |
private void requestUserLogin( String pHistoryToken, String pError ) { |
174 |
145 |
|
LoginDialogViewFactory zFactory = ClientContext.get().get( LoginDialogViewFactory.class ); |
175 |
146 |
|
DialogView zView = zFactory.createDialog( false, new LoginSuccessCommand( pHistoryToken, mNextScreenProperties ) ); |
176 |
147 |
|
zView.setDialogErrorMessage( pError ); |
|
@@ -179,34 +150,28 @@ |
179 |
150 |
|
} |
180 |
151 |
|
|
181 |
152 |
|
@Override |
182 |
|
- |
public void onValueChange( ValueChangeEvent<String> pEvent ) |
183 |
|
- |
{ |
|
153 |
+ |
public void onValueChange( ValueChangeEvent<String> pEvent ) { |
184 |
154 |
|
onValueChangeImpl( pEvent.getValue() ); |
185 |
155 |
|
} |
186 |
156 |
|
|
187 |
|
- |
private class LoginSuccessCommand implements Command |
188 |
|
- |
{ |
|
157 |
+ |
private class LoginSuccessCommand implements Command { |
189 |
158 |
|
private final String mHistoryToken; |
190 |
159 |
|
private final TransientScreenProperties mNextScreenProperties; |
191 |
160 |
|
|
192 |
|
- |
public LoginSuccessCommand( String pHistoryToken, TransientScreenProperties pNextScreenProperties ) |
193 |
|
- |
{ |
|
161 |
+ |
public LoginSuccessCommand( String pHistoryToken, TransientScreenProperties pNextScreenProperties ) { |
194 |
162 |
|
this( pHistoryToken, pNextScreenProperties, null ); |
195 |
163 |
|
} |
196 |
164 |
|
|
197 |
|
- |
private LoginSuccessCommand( String pHistoryToken, TransientScreenProperties pNextScreenProperties, String pWarning ) |
198 |
|
- |
{ |
|
165 |
+ |
private LoginSuccessCommand( String pHistoryToken, TransientScreenProperties pNextScreenProperties, String pWarning ) { |
199 |
166 |
|
mHistoryToken = pHistoryToken; |
200 |
167 |
|
mNextScreenProperties = pNextScreenProperties.copy(); |
201 |
|
- |
if ( pWarning != null ) |
202 |
|
- |
{ |
|
168 |
+ |
if ( pWarning != null ) { |
203 |
169 |
|
mNextScreenProperties.WARNING.set( pWarning ); |
204 |
170 |
|
} |
205 |
171 |
|
} |
206 |
172 |
|
|
207 |
173 |
|
@Override |
208 |
|
- |
public void execute() |
209 |
|
- |
{ |
|
174 |
+ |
public void execute() { |
210 |
175 |
|
showScreen( mHistoryToken, mNextScreenProperties ); |
211 |
176 |
|
} |
212 |
177 |
|
} |