Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/GWT_Sandbox/NAS-Video/src/org/litesoft/nasvideo/client/NasVideo.java

Diff revisions: vs.
  @@ -1,220 +1,196 @@
1 - package org.litesoft.nasvideo.client;
2 -
3 - import org.litesoft.GWT.client.*;
4 - import org.litesoft.GWT.client.command.*;
5 - import org.litesoft.GWT.client.command.queue.*;
6 - import org.litesoft.GWT.client.dev.*;
7 - import org.litesoft.GWT.client.logging.*;
8 - import org.litesoft.GWT.client.rpc.*;
9 - import org.litesoft.GWT.client.view.*;
10 - import org.litesoft.GWT.client.widgets.*;
11 - import org.litesoft.GWT.client.widgets.datatables.*;
12 - import org.litesoft.bo.views.*;
13 - import org.litesoft.bo.views.communication.*;
14 - import org.litesoft.core.*;
15 - import org.litesoft.core.simpletypes.temporal.*;
16 - import org.litesoft.core.typeutils.*;
17 - import org.litesoft.nasvideo.client.boviews.*;
18 - import org.litesoft.nasvideo.client.ui.views.admin.*;
19 - import org.litesoft.nasvideo.client.ui.views.home.*;
20 - import org.litesoft.logger.*;
21 - import org.litesoft.loggerconfig.*;
22 - import org.litesoft.security.*;
23 - import org.litesoft.uispecification.*;
24 -
25 - import com.google.gwt.user.client.*;
26 - import com.google.gwt.user.client.rpc.*;
27 - import com.google.gwt.user.client.ui.*;
28 -
29 - public class NasVideo extends AbstractClientMainAppEntryPoint implements ViewDefs,
30 - RestrictedResourceSwitcherCallBack
31 - {
32 - private VACMproxy mACM = new VACMproxy();
33 -
34 - // pull in all the factories. This can be broken out into different modules if compile becomes too slow.
35 - private ViewManagerImpl mVM = new ViewManagerImpl( mACM, //
36 - // Admin
37 - new ChangePasswordFactory(), //
38 - new MyProfileFactory(), //
39 - new ReportsFactory(), //
40 - new UsersFactory(), //
41 - new RestrictedResourceEditorFactory(), //
42 - new RestrictedResourceManagementFactory(), //
43 - // Reports...
44 - // new MedicationTrackingReportFactory(), //
45 - // HOME!
46 - new HomeFactory() );
47 -
48 - public NasVideo()
49 - {
50 - super( new AppNames( "NasVideo", "NasVideo" ) );
51 -
52 - // add in all the factory-less screens. This can be broken out into different modules if compile becomes too slow.
53 - // mVM.add( ADMIN_RESTRICTED_RESOURCE_MANAGEMENT );
54 - }
55 -
56 - @Override
57 - public void onAppLoad()
58 - {
59 - System.out.println( "DevMode " + Dev.state() );
60 -
61 - replaceAppPanel();
62 -
63 - super.onAppLoad();
64 -
65 - CScomm.setInstance( new GwtCScomm( null, mVM, new AppInitializationCallback() ) );
66 - }
67 -
68 - public void finishAppLoad()
69 - {
70 - ClientContext zContext = ClientContext.get();
71 -
72 - Dev.init( zContext );
73 -
74 - AppPanel zAppPanel = new AppPanel( Dev.isDevMode() ? 1 : 0 ); // 1 = see Red Line
75 -
76 - CurrentUserViewAccessor zCUA = new CurrentUserViewAccessor( zAppPanel, mACM );
77 - CurrentRestrictedResourceViewAccessor zCSA = new CurrentRestrictedResourceViewAccessor( zAppPanel );
78 - CurrentRestrictedResourceOptionsAccessor zCRROA = new CurrentRestrictedResourceOptionsAccessor( new RestrictedResourceSwitcher( zAppPanel, this ) );
79 -
80 - WindowSizingPanel.setContent( zAppPanel );
81 -
82 - zContext.set( LoginServerStateChecker.class, UserViewDataProvider.getInstance() );
83 - zContext.set( LoginDialogViewFactory.class, new LoginDialogFactory() );
84 - zContext.set( LoginPasswordResetDialogViewFactory.class, new ResetPasswordDialogFactory() );
85 - zContext.set( ViewAccessControlManager.class, mACM );
86 - zContext.set( CurrentRestrictedResourceOptionsAccessor.class, zCRROA );
87 - zContext.set( CurrentRestrictedResourceViewAccessor.class, zCSA );
88 - zContext.set( CurrentUserViewAccessor.class, zCUA );
89 - zContext.set( LoginPasswordResetAccessor.class, zCUA );
90 - zContext.set( StatusMessageSinc.class, zAppPanel );
91 - zContext.set( SingleWidgetPanel.class, zAppPanel );
92 - zContext.set( PageRefreshableProxy.class, zAppPanel );
93 - zContext.set( CommandQueue.class, new CommandQueue() );
94 - zContext.set( ScreenViewShower.class, mVM );
95 - zContext.set( DialogViewShower.class, mVM );
96 - zContext.set( ViewFactoryAccessor.class, mVM );
97 - zContext.set( NextDemoUserRequestHandler.class, new NextDemoUserRequestHandlerImpl() );
98 -
99 - mVM.initialize();
100 -
101 - System.err.println( new UtilDateAdaptor() + " | Application Client Ready" );
102 -
103 - PaddingProperty.setDefaults( 2, 10, 2, 6 );
104 -
105 - zAppPanel.setInfoMessage( "Hello" );
106 - }
107 -
108 - protected void initializeLoggerFactory()
109 - {
110 - //noinspection NonJREEmulationClassesInClientCode
111 - LoggerFactory.init( new ConfigurationLoggerLevel(), BrowserAsLogSyncFactory.INSTANCE );
112 - }
113 -
114 - private class AppInitializationCallback implements AsyncCallback<AppInitializationResult>
115 - {
116 - @Override
117 - public void onFailure( Throwable pThrowable )
118 - {
119 - String message;
120 -
121 - if ( pThrowable instanceof InvocationException )
122 - {
123 - // see javadoc for InvocationException
124 - message = "A connection could not be established with the server";
125 - }
126 - else if ( pThrowable instanceof IncompatibleRemoteServiceException )
127 - {
128 - /*
129 - * This _should_ not happen to users, so long as the .nocache
130 - * file isn't cached by the client.
131 - */
132 - message = "Client and server versions are incompatible. Try ctrl-clicking\n" + //
133 - "or shift-clicking the browser refresh button, or clearing your\n" + //
134 - "browser's cache in 'Internet Options' / your browser's preferences. ";
135 - }
136 - else
137 - {
138 - // probably an application-specific execption on the server
139 - message = "An application error occured on the server";
140 - }
141 -
142 - reportFailure( pThrowable, "onFailure()", message );
143 - }
144 -
145 - @Override
146 - public void onSuccess( AppInitializationResult result )
147 - {
148 - System.err.println( new UtilDateAdaptor() + " | Client AppInitialization" );
149 -
150 - if ( result == null )
151 - {
152 - UtilsGwt.closeWindowNoConfirm( 5 );
153 - return;
154 - }
155 -
156 - try
157 - {
158 - new ClientConfiguration( result.getClientConfig() ); // This line must preceed the next
159 - initializeLoggerFactory(); // ......................... This line must follow the previous
160 -
161 - AlertManager.setVersion( "Version " + result.getApplicationVersion() );
162 -
163 - finishAppLoad();
164 - }
165 - catch ( RuntimeException e )
166 - {
167 - reportFailure( e, "onSuccess()", null );
168 - }
169 - }
170 -
171 - private void reportFailure( Throwable pThrowable, String method, String message )
172 - {
173 - pThrowable.printStackTrace(); // prints the trace in the GWT hosted shell
174 - String html = "<h1>Application Initialization Failed</h1>" + //
175 - "<p>" + message + "</p>" + //
176 - "<p>at " + getClass().getName() + "." + method + "</p>" + //
177 - "<p>Exception: </p>" + //
178 - "<p><pre>" + pThrowable + "</pre></p>";
179 - DOM.setInnerHTML( RootPanel.getBodyElement(), html );
180 - }
181 - }
182 -
183 - private static class NextDemoUserRequestHandlerImpl implements NextDemoUserRequestHandler
184 - {
185 - @Override
186 - public void nextDemoUser()
187 - {
188 - UserViewDataProvider.getInstance().nextDemoUser( new SimpleDataProviderCallBack()
189 - {
190 - @Override
191 - public void error( String pError )
192 - {
193 - new ShowScreenCommand( ViewDefs.HOME, pError ).execute();
194 - }
195 - } );
196 - }
197 - }
198 -
199 - @Override
200 - public void switchToRestrictedResource( AlternateRestrictedResourceOption pAlternateOption )
201 - {
202 - UserViewDataProvider.getInstance().attemptSwitchToRestrictedResource( (RestrictedResourceView) pAlternateOption, new SimpleDataProviderCallBack()
203 - {
204 - @Override
205 - public void error( String pError )
206 - {
207 - if ( Strings.isNullOrEmpty( pError ) )
208 - {
209 - PageRefreshableProxy zRefreshableProxy = ClientContext.get().checkGet( PageRefreshableProxy.class );
210 - if ( zRefreshableProxy != null )
211 - {
212 - zRefreshableProxy.refreshPage();
213 - return;
214 - }
215 - }
216 - new ShowScreenCommand( ViewDefs.HOME, pError ).execute();
217 - }
218 - } );
219 - }
220 - }
1 + package org.litesoft.nasvideo.client;
2 +
3 + import org.litesoft.GWT.client.*;
4 + import org.litesoft.GWT.client.command.*;
5 + import org.litesoft.GWT.client.command.queue.*;
6 + import org.litesoft.GWT.client.dev.*;
7 + import org.litesoft.GWT.client.logging.*;
8 + import org.litesoft.GWT.client.rpc.*;
9 + import org.litesoft.GWT.client.view.*;
10 + import org.litesoft.GWT.client.widgets.*;
11 + import org.litesoft.GWT.client.widgets.datatables.*;
12 + import org.litesoft.bo.views.*;
13 + import org.litesoft.bo.views.communication.*;
14 + import org.litesoft.commonfoundation.base.*;
15 + import org.litesoft.commonfoundation.typeutils.gregorian.*;
16 + import org.litesoft.core.*;
17 + import org.litesoft.initfrom.client.accessors.CurrentRestrictedResourceViewAccessor;
18 + import org.litesoft.initfrom.client.accessors.CurrentUserViewAccessor;
19 + import org.litesoft.initfrom.client.boviews.*;
20 + import org.litesoft.logger.*;
21 + import org.litesoft.loggerconfig.*;
22 + import org.litesoft.nasvideo.client.ui.views.admin.*;
23 + import org.litesoft.nasvideo.client.ui.views.home.*;
24 + import org.litesoft.security.*;
25 + import org.litesoft.uispecification.*;
26 +
27 + import com.google.gwt.user.client.*;
28 + import com.google.gwt.user.client.rpc.*;
29 + import com.google.gwt.user.client.ui.*;
30 +
31 + public class NasVideo extends AbstractClientMainAppEntryPoint implements ViewDefs,
32 + RestrictedResourceSwitcherCallBack {
33 + private VACMproxy mACM = new VACMproxy();
34 +
35 + // pull in all the factories. This can be broken out into different modules if compile becomes too slow.
36 + private ViewManagerImpl mVM = new ViewManagerImpl( mACM, //
37 + // Admin
38 + new ChangePasswordFactory(), //
39 + new MyProfileFactory(), //
40 + new ReportsFactory(), //
41 + new UsersFactory(), //
42 + new RestrictedResourceEditorFactory(), //
43 + new RestrictedResourceManagementFactory(), //
44 + // Reports...
45 + // new MedicationTrackingReportFactory(), //
46 + // HOME!
47 + new HomeFactory() );
48 +
49 + public NasVideo() {
50 + super( new AppNames( "NasVideo", "NasVideo" ) );
51 +
52 + // add in all the factory-less screens. This can be broken out into different modules if compile becomes too slow.
53 + // mVM.add( ADMIN_RESTRICTED_RESOURCE_MANAGEMENT );
54 + }
55 +
56 + @Override
57 + public void onAppLoad() {
58 + System.out.println( "DevMode " + Dev.state() );
59 +
60 + replaceAppPanel();
61 +
62 + super.onAppLoad();
63 +
64 + CScomm.setInstance( new GwtCScomm( null, mVM, new AppInitializationCallback() ) );
65 + }
66 +
67 + public void finishAppLoad() {
68 + ClientContext zContext = ClientContext.get();
69 +
70 + Dev.init( zContext );
71 +
72 + AppPanel zAppPanel = new AppPanel( Dev.isDevMode() ? 1 : 0 ); // 1 = see Red Line
73 +
74 + CurrentUserViewAccessor zCUA = new CurrentUserViewAccessor( zAppPanel, mACM );
75 + CurrentRestrictedResourceViewAccessor zCSA = new CurrentRestrictedResourceViewAccessor( zAppPanel );
76 + CurrentRestrictedResourceOptionsAccessor zCRROA = new CurrentRestrictedResourceOptionsAccessor( new RestrictedResourceSwitcher( zAppPanel, this ) );
77 +
78 + WindowSizingPanel.setContent( zAppPanel );
79 +
80 + zContext.set( LoginServerStateChecker.class, UserViewDataProvider.getInstance() );
81 + zContext.set( LoginDialogViewFactory.class, new LoginDialogFactory() );
82 + zContext.set( LoginPasswordResetDialogViewFactory.class, new ResetPasswordDialogFactory() );
83 + zContext.set( ViewAccessControlManager.class, mACM );
84 + zContext.set( CurrentRestrictedResourceOptionsAccessor.class, zCRROA );
85 + zContext.set( CurrentRestrictedResourceViewAccessor.class, zCSA );
86 + zContext.set( CurrentUserViewAccessor.class, zCUA );
87 + zContext.set( LoginPasswordResetAccessor.class, zCUA );
88 + zContext.set( StatusMessageSinc.class, zAppPanel );
89 + zContext.set( SingleWidgetPanel.class, zAppPanel );
90 + zContext.set( PageRefreshableProxy.class, zAppPanel );
91 + zContext.set( CommandQueue.class, new CommandQueue() );
92 + zContext.set( ScreenViewShower.class, mVM );
93 + zContext.set( DialogViewShower.class, mVM );
94 + zContext.set( ViewFactoryAccessor.class, mVM );
95 + zContext.set( NextDemoUserRequestHandler.class, new NextDemoUserRequestHandlerImpl() );
96 +
97 + mVM.initialize();
98 +
99 + System.err.println( new UtilDateAdaptor() + " | Application Client Ready" );
100 +
101 + PaddingProperty.setDefaults( 2, 10, 2, 6 );
102 +
103 + zAppPanel.setInfoMessage( "Hello" );
104 + }
105 +
106 + protected void initializeLoggerFactory() {
107 + //noinspection NonJREEmulationClassesInClientCode
108 + LoggerFactory.init( new ConfigurationLoggerLevel(), BrowserAsLogSyncFactory.INSTANCE );
109 + }
110 +
111 + private class AppInitializationCallback implements AsyncCallback<AppInitializationResult> {
112 + @Override
113 + public void onFailure( Throwable pThrowable ) {
114 + String message;
115 +
116 + if ( pThrowable instanceof InvocationException ) {
117 + // see javadoc for InvocationException
118 + message = "A connection could not be established with the server";
119 + } else if ( pThrowable instanceof IncompatibleRemoteServiceException ) {
120 + /*
121 + * This _should_ not happen to users, so long as the .nocache
122 + * file isn't cached by the client.
123 + */
124 + message = "Client and server versions are incompatible. Try ctrl-clicking\n" + //
125 + "or shift-clicking the browser refresh button, or clearing your\n" + //
126 + "browser's cache in 'Internet Options' / your browser's preferences. ";
127 + } else {
128 + // probably an application-specific execption on the server
129 + message = "An application error occured on the server";
130 + }
131 +
132 + reportFailure( pThrowable, "onFailure()", message );
133 + }
134 +
135 + @Override
136 + public void onSuccess( AppInitializationResult result ) {
137 + System.err.println( new UtilDateAdaptor() + " | Client AppInitialization" );
138 +
139 + if ( result == null ) {
140 + UtilsGwt.closeWindowNoConfirm( 5 );
141 + return;
142 + }
143 +
144 + try {
145 + new ClientConfiguration( result.getClientConfig() ); // This line must preceed the next
146 + initializeLoggerFactory(); // ......................... This line must follow the previous
147 +
148 + AlertManager.setVersion( "Version " + result.getApplicationVersion() );
149 +
150 + finishAppLoad();
151 + }
152 + catch ( RuntimeException e ) {
153 + reportFailure( e, "onSuccess()", null );
154 + }
155 + }
156 +
157 + private void reportFailure( Throwable pThrowable, String method, String message ) {
158 + pThrowable.printStackTrace(); // prints the trace in the GWT hosted shell
159 + String html = "<h1>Application Initialization Failed</h1>" + //
160 + "<p>" + message + "</p>" + //
161 + "<p>at " + getClass().getName() + "." + method + "</p>" + //
162 + "<p>Exception: </p>" + //
163 + "<p><pre>" + pThrowable + "</pre></p>";
164 + DOM.setInnerHTML( RootPanel.getBodyElement(), html );
165 + }
166 + }
167 +
168 + private static class NextDemoUserRequestHandlerImpl implements NextDemoUserRequestHandler {
169 + @Override
170 + public void nextDemoUser() {
171 + UserViewDataProvider.getInstance().nextDemoUser( new SimpleDataProviderCallBack() {
172 + @Override
173 + public void error( String pError ) {
174 + new ShowScreenCommand( ViewDefs.HOME, pError ).execute();
175 + }
176 + } );
177 + }
178 + }
179 +
180 + @Override
181 + public void switchToRestrictedResource( AlternateRestrictedResourceOption pAlternateOption ) {
182 + UserViewDataProvider.getInstance().attemptSwitchToRestrictedResource( (RestrictedResourceView) pAlternateOption, new SimpleDataProviderCallBack() {
183 + @Override
184 + public void error( String pError ) {
185 + if ( Currently.isNullOrEmpty( pError ) ) {
186 + PageRefreshableProxy zRefreshableProxy = ClientContext.get().checkGet( PageRefreshableProxy.class );
187 + if ( zRefreshableProxy != null ) {
188 + zRefreshableProxy.refreshPage();
189 + return;
190 + }
191 + }
192 + new ShowScreenCommand( ViewDefs.HOME, pError ).execute();
193 + }
194 + } );
195 + }
196 + }