|
@@ -1,157 +1,157 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.client; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.client.widgets.*; |
5 |
|
- |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
6 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
7 |
|
- |
import org.litesoft.commonfoundation.typeutils.gregorian.*; |
8 |
|
- |
import org.litesoft.logger.*; |
9 |
|
- |
|
10 |
|
- |
import com.google.gwt.core.client.*; |
11 |
|
- |
import com.google.gwt.event.logical.shared.*; |
12 |
|
- |
import com.google.gwt.user.client.*; |
13 |
|
- |
import com.google.gwt.user.client.ui.*; |
14 |
|
- |
|
15 |
|
- |
public abstract class AbstractClientMainAppEntryPoint implements EntryPoint, |
16 |
|
- |
AppWindowLifeCycle, |
17 |
|
- |
DataTableStyle { |
18 |
|
- |
/** |
19 |
|
- |
* @noinspection NonJREEmulationClassesInClientCode |
20 |
|
- |
*/ |
21 |
|
- |
public static Logger CLIENT_LOGGER = LoggerFactory.getLogger( "Client" ); |
22 |
|
- |
|
23 |
|
- |
public static boolean sWindowClosing = false; |
24 |
|
- |
|
25 |
|
- |
/** |
26 |
|
- |
* @noinspection NonJREEmulationClassesInClientCode |
27 |
|
- |
*/ |
28 |
|
- |
public static final Logger ENTRY_POINT_LOGGER = LoggerFactory.getLogger( EntryPoint.class ); |
29 |
|
- |
|
30 |
|
- |
protected final String mAppName; |
31 |
|
- |
protected final String mShortAllLettersClientName; |
32 |
|
- |
private static final String APP_PANEL = "AppPanel"; |
33 |
|
- |
|
34 |
|
- |
protected AbstractClientMainAppEntryPoint( AppNames pAppNames ) { |
35 |
|
- |
mAppName = pAppNames.getAppName(); |
36 |
|
- |
mShortAllLettersClientName = pAppNames.getShortAllLettersClientName(); |
37 |
|
- |
} |
38 |
|
- |
|
39 |
|
- |
/** |
40 |
|
- |
* This is the entry point method. |
41 |
|
- |
*/ |
42 |
|
- |
@Override |
43 |
|
- |
public final void onModuleLoad() { |
44 |
|
- |
System.err.println( new UtilDateAdaptor() + " | Application Client Start Up" ); |
45 |
|
- |
|
46 |
|
- |
Window.addCloseHandler( this ); |
47 |
|
- |
Window.addWindowClosingHandler( this ); |
48 |
|
- |
|
49 |
|
- |
OurUncaughtExceptionHandler handler = new OurUncaughtExceptionHandler( this ); |
50 |
|
- |
GWT.setUncaughtExceptionHandler( handler ); |
51 |
|
- |
|
52 |
|
- |
RootPanel zBodyPanel = RootPanel.get(); |
53 |
|
- |
zBodyPanel.addStyleName( "litesoft-LayoutOverflowHidden" ); |
54 |
|
- |
zBodyPanel.addStyleName( GWT.isScript() ? "litesoft-RegularMode" : "litesoft-HostedMode" ); |
55 |
|
- |
/** |
56 |
|
- |
* Add a class to the body element to enable platform-specific CSS rules. |
57 |
|
- |
*/ |
58 |
|
- |
UserAgent zUserAgent = UserAgent.getInstance(); |
59 |
|
- |
|
60 |
|
- |
zBodyPanel.addStyleName( "UserAgent-" + zUserAgent.getFamily() ); |
61 |
|
- |
zBodyPanel.addStyleName( zUserAgent.isLegacyIE() ? "UserAgent-LegacyIE" : "UserAgent-Modern" ); |
62 |
|
- |
|
63 |
|
- |
String zReally = zUserAgent.getReally(); |
64 |
|
- |
if ( Strings.isNotNullOrEmpty( zReally ) ) { |
65 |
|
- |
zBodyPanel.addStyleName( "Really" + zReally ); |
66 |
|
- |
} |
67 |
|
- |
|
68 |
|
- |
getAppPanel().addStyleName( "Platform-" + zUserAgent.getPlatform() ); |
69 |
|
- |
|
70 |
|
- |
onAppLoad(); |
71 |
|
- |
} |
72 |
|
- |
|
73 |
|
- |
private RootPanel getAppPanel() { |
74 |
|
- |
return RootPanel.get( APP_PANEL ); |
75 |
|
- |
} |
76 |
|
- |
|
77 |
|
- |
@Override |
78 |
|
- |
public void onAppLoad() { |
79 |
|
- |
nativeCodeInjection(); |
80 |
|
- |
prefetchImages(); |
81 |
|
- |
} |
82 |
|
- |
|
83 |
|
- |
@Override |
84 |
|
- |
public void onWindowClosing( Window.ClosingEvent pEvent ) { |
85 |
|
- |
} |
86 |
|
- |
|
87 |
|
- |
@Override |
88 |
|
- |
public void onClose( CloseEvent<Window> pEvent ) { |
89 |
|
- |
sWindowClosing = true; |
90 |
|
- |
nativeCodeDispose(); |
91 |
|
- |
CLIENT_LOGGER.trace.log( "WindowClosing..." ); |
92 |
|
- |
} |
93 |
|
- |
|
94 |
|
- |
@Override |
95 |
|
- |
public void prefetchImages() { |
96 |
|
- |
AlertManager.prefetchImages(); |
97 |
|
- |
} |
98 |
|
- |
|
99 |
|
- |
@Override |
100 |
|
- |
public void nativeCodeInjection() { |
101 |
|
- |
} |
102 |
|
- |
|
103 |
|
- |
@Override |
104 |
|
- |
public void nativeCodeDispose() { |
105 |
|
- |
} |
106 |
|
- |
|
107 |
|
- |
protected SingleWidgetContainer replaceAppPanel() { |
108 |
|
- |
return replaceAppPanel( new WindowSizingPanel() ); |
109 |
|
- |
} |
110 |
|
- |
|
111 |
|
- |
protected SingleWidgetContainer replaceAppPanel( SingleWidgetContainer pSWC ) { |
112 |
|
- |
Element zElement = RootPanel.get().getElement(); |
113 |
|
- |
CommonElementHelper.setOverflowHidden( zElement ); |
114 |
|
- |
CommonElementHelper.forceNoMarginOrPadding( zElement ); |
115 |
|
- |
|
116 |
|
- |
//noinspection GwtToHtmlReferences |
117 |
|
- |
RootPanel panel = getAppPanel(); |
118 |
|
- |
if ( panel == null ) { |
119 |
|
- |
UtilsGwt.closeWindowNoConfirm( |
120 |
|
- |
"HTML Corrupted - Failed to find an element with an id of 'AppPanel' in the HTML host page\nWill attempt to close Window!" ); |
121 |
|
- |
return null; |
122 |
|
- |
} |
123 |
|
- |
panel.clear(); // properly remove GWT widgets |
124 |
|
- |
zElement = panel.getElement(); |
125 |
|
- |
DOM.setInnerText( zElement, "" ); // remove static content |
126 |
|
- |
DOM.setStyleAttribute( zElement, "height", null ); |
127 |
|
- |
CommonElementHelper.setOverflowHidden( zElement ); |
128 |
|
- |
panel.add( (Widget) pSWC ); |
129 |
|
- |
|
130 |
|
- |
FontSizer.get( DATA_TABLE_TEXT ); |
131 |
|
- |
FontSizer.get( HEADER_TABLE_TEXT ); |
132 |
|
- |
|
133 |
|
- |
return pSWC; |
134 |
|
- |
} |
135 |
|
- |
|
136 |
|
- |
protected void handleUncaughtException( Throwable e ) { |
137 |
|
- |
if ( e != null ) { |
138 |
|
- |
ENTRY_POINT_LOGGER.error.log( e ); |
139 |
|
- |
AlertManager.alert( "MainApp", "Unexpected Exception", e.getClass().getName(), e ); |
140 |
|
- |
} |
141 |
|
- |
} |
142 |
|
- |
|
143 |
|
- |
private static class OurUncaughtExceptionHandler implements GWT.UncaughtExceptionHandler { |
144 |
|
- |
private AbstractClientMainAppEntryPoint mEntryPoint; |
145 |
|
- |
|
146 |
|
- |
public OurUncaughtExceptionHandler( AbstractClientMainAppEntryPoint pEntryPoint ) { |
147 |
|
- |
mEntryPoint = pEntryPoint; |
148 |
|
- |
} |
149 |
|
- |
|
150 |
|
- |
@Override |
151 |
|
- |
public void onUncaughtException( Throwable e ) { |
152 |
|
- |
if ( !sWindowClosing ) { |
153 |
|
- |
mEntryPoint.handleUncaughtException( e ); |
154 |
|
- |
} |
155 |
|
- |
} |
156 |
|
- |
} |
157 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.client; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.client.widgets.*; |
|
5 |
+ |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
|
6 |
+ |
import org.litesoft.commonfoundation.base.*; |
|
7 |
+ |
import org.litesoft.commonfoundation.typeutils.gregorian.*; |
|
8 |
+ |
import org.litesoft.logger.*; |
|
9 |
+ |
|
|
10 |
+ |
import com.google.gwt.core.client.*; |
|
11 |
+ |
import com.google.gwt.event.logical.shared.*; |
|
12 |
+ |
import com.google.gwt.user.client.*; |
|
13 |
+ |
import com.google.gwt.user.client.ui.*; |
|
14 |
+ |
|
|
15 |
+ |
public abstract class AbstractClientMainAppEntryPoint implements EntryPoint, |
|
16 |
+ |
AppWindowLifeCycle, |
|
17 |
+ |
DataTableStyle { |
|
18 |
+ |
/** |
|
19 |
+ |
* @noinspection NonJREEmulationClassesInClientCode |
|
20 |
+ |
*/ |
|
21 |
+ |
public static Logger CLIENT_LOGGER = LoggerFactory.getLogger( "Client" ); |
|
22 |
+ |
|
|
23 |
+ |
public static boolean sWindowClosing = false; |
|
24 |
+ |
|
|
25 |
+ |
/** |
|
26 |
+ |
* @noinspection NonJREEmulationClassesInClientCode |
|
27 |
+ |
*/ |
|
28 |
+ |
public static final Logger ENTRY_POINT_LOGGER = LoggerFactory.getLogger( EntryPoint.class ); |
|
29 |
+ |
|
|
30 |
+ |
protected final String mAppName; |
|
31 |
+ |
protected final String mShortAllLettersClientName; |
|
32 |
+ |
private static final String APP_PANEL = "AppPanel"; |
|
33 |
+ |
|
|
34 |
+ |
protected AbstractClientMainAppEntryPoint( AppNames pAppNames ) { |
|
35 |
+ |
mAppName = pAppNames.getAppName(); |
|
36 |
+ |
mShortAllLettersClientName = pAppNames.getShortAllLettersClientName(); |
|
37 |
+ |
} |
|
38 |
+ |
|
|
39 |
+ |
/** |
|
40 |
+ |
* This is the entry point method. |
|
41 |
+ |
*/ |
|
42 |
+ |
@Override |
|
43 |
+ |
public final void onModuleLoad() { |
|
44 |
+ |
System.err.println( new UtilDateAdaptor() + " | Application Client Start Up" ); |
|
45 |
+ |
|
|
46 |
+ |
Window.addCloseHandler( this ); |
|
47 |
+ |
Window.addWindowClosingHandler( this ); |
|
48 |
+ |
|
|
49 |
+ |
OurUncaughtExceptionHandler handler = new OurUncaughtExceptionHandler( this ); |
|
50 |
+ |
GWT.setUncaughtExceptionHandler( handler ); |
|
51 |
+ |
|
|
52 |
+ |
RootPanel zBodyPanel = RootPanel.get(); |
|
53 |
+ |
zBodyPanel.addStyleName( "litesoft-LayoutOverflowHidden" ); |
|
54 |
+ |
zBodyPanel.addStyleName( GWT.isScript() ? "litesoft-RegularMode" : "litesoft-HostedMode" ); |
|
55 |
+ |
/** |
|
56 |
+ |
* Add a class to the body element to enable platform-specific CSS rules. |
|
57 |
+ |
*/ |
|
58 |
+ |
UserAgent zUserAgent = UserAgent.getInstance(); |
|
59 |
+ |
|
|
60 |
+ |
zBodyPanel.addStyleName( "UserAgent-" + zUserAgent.getFamily() ); |
|
61 |
+ |
zBodyPanel.addStyleName( zUserAgent.isLegacyIE() ? "UserAgent-LegacyIE" : "UserAgent-Modern" ); |
|
62 |
+ |
|
|
63 |
+ |
String zReally = zUserAgent.getReally(); |
|
64 |
+ |
if ( Currently.isNotNullOrEmpty( zReally ) ) { |
|
65 |
+ |
zBodyPanel.addStyleName( "Really" + zReally ); |
|
66 |
+ |
} |
|
67 |
+ |
|
|
68 |
+ |
getAppPanel().addStyleName( "Platform-" + zUserAgent.getPlatform() ); |
|
69 |
+ |
|
|
70 |
+ |
onAppLoad(); |
|
71 |
+ |
} |
|
72 |
+ |
|
|
73 |
+ |
private RootPanel getAppPanel() { |
|
74 |
+ |
return RootPanel.get( APP_PANEL ); |
|
75 |
+ |
} |
|
76 |
+ |
|
|
77 |
+ |
@Override |
|
78 |
+ |
public void onAppLoad() { |
|
79 |
+ |
nativeCodeInjection(); |
|
80 |
+ |
prefetchImages(); |
|
81 |
+ |
} |
|
82 |
+ |
|
|
83 |
+ |
@Override |
|
84 |
+ |
public void onWindowClosing( Window.ClosingEvent pEvent ) { |
|
85 |
+ |
} |
|
86 |
+ |
|
|
87 |
+ |
@Override |
|
88 |
+ |
public void onClose( CloseEvent<Window> pEvent ) { |
|
89 |
+ |
sWindowClosing = true; |
|
90 |
+ |
nativeCodeDispose(); |
|
91 |
+ |
CLIENT_LOGGER.trace.log( "WindowClosing..." ); |
|
92 |
+ |
} |
|
93 |
+ |
|
|
94 |
+ |
@Override |
|
95 |
+ |
public void prefetchImages() { |
|
96 |
+ |
AlertManager.prefetchImages(); |
|
97 |
+ |
} |
|
98 |
+ |
|
|
99 |
+ |
@Override |
|
100 |
+ |
public void nativeCodeInjection() { |
|
101 |
+ |
} |
|
102 |
+ |
|
|
103 |
+ |
@Override |
|
104 |
+ |
public void nativeCodeDispose() { |
|
105 |
+ |
} |
|
106 |
+ |
|
|
107 |
+ |
protected SingleWidgetContainer replaceAppPanel() { |
|
108 |
+ |
return replaceAppPanel( new WindowSizingPanel() ); |
|
109 |
+ |
} |
|
110 |
+ |
|
|
111 |
+ |
protected SingleWidgetContainer replaceAppPanel( SingleWidgetContainer pSWC ) { |
|
112 |
+ |
Element zElement = RootPanel.get().getElement(); |
|
113 |
+ |
CommonElementHelper.setOverflowHidden( zElement ); |
|
114 |
+ |
CommonElementHelper.forceNoMarginOrPadding( zElement ); |
|
115 |
+ |
|
|
116 |
+ |
//noinspection GwtToHtmlReferences |
|
117 |
+ |
RootPanel panel = getAppPanel(); |
|
118 |
+ |
if ( panel == null ) { |
|
119 |
+ |
UtilsGwt.closeWindowNoConfirm( |
|
120 |
+ |
"HTML Corrupted - Failed to find an element with an id of 'AppPanel' in the HTML host page\nWill attempt to close Window!" ); |
|
121 |
+ |
return null; |
|
122 |
+ |
} |
|
123 |
+ |
panel.clear(); // properly remove GWT widgets |
|
124 |
+ |
zElement = panel.getElement(); |
|
125 |
+ |
DOM.setInnerText( zElement, "" ); // remove static content |
|
126 |
+ |
DOM.setStyleAttribute( zElement, "height", null ); |
|
127 |
+ |
CommonElementHelper.setOverflowHidden( zElement ); |
|
128 |
+ |
panel.add( (Widget) pSWC ); |
|
129 |
+ |
|
|
130 |
+ |
FontSizer.get( DATA_TABLE_TEXT ); |
|
131 |
+ |
FontSizer.get( HEADER_TABLE_TEXT ); |
|
132 |
+ |
|
|
133 |
+ |
return pSWC; |
|
134 |
+ |
} |
|
135 |
+ |
|
|
136 |
+ |
protected void handleUncaughtException( Throwable e ) { |
|
137 |
+ |
if ( e != null ) { |
|
138 |
+ |
ENTRY_POINT_LOGGER.error.log( e ); |
|
139 |
+ |
AlertManager.alert( "MainApp", "Unexpected Exception", e.getClass().getName(), e ); |
|
140 |
+ |
} |
|
141 |
+ |
} |
|
142 |
+ |
|
|
143 |
+ |
private static class OurUncaughtExceptionHandler implements GWT.UncaughtExceptionHandler { |
|
144 |
+ |
private AbstractClientMainAppEntryPoint mEntryPoint; |
|
145 |
+ |
|
|
146 |
+ |
public OurUncaughtExceptionHandler( AbstractClientMainAppEntryPoint pEntryPoint ) { |
|
147 |
+ |
mEntryPoint = pEntryPoint; |
|
148 |
+ |
} |
|
149 |
+ |
|
|
150 |
+ |
@Override |
|
151 |
+ |
public void onUncaughtException( Throwable e ) { |
|
152 |
+ |
if ( !sWindowClosing ) { |
|
153 |
+ |
mEntryPoint.handleUncaughtException( e ); |
|
154 |
+ |
} |
|
155 |
+ |
} |
|
156 |
+ |
} |
|
157 |
+ |
} |