Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/GWT_Sandbox/InitFrom/src/org/litesoft/initfrom/client/InitFrom.java

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