Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// This Source Code is in the Public Domain per: http://unlicense.org
package org.litesoft.GWT.client;

import org.litesoft.GWT.client.widgets.*;
import org.litesoft.GWT.client.widgets.nonpublic.*;
import org.litesoft.commonfoundation.typeutils.*;
import org.litesoft.commonfoundation.typeutils.gregorian.*;
import org.litesoft.logger.*;

import com.google.gwt.core.client.*;
import com.google.gwt.event.logical.shared.*;
import com.google.gwt.user.client.*;
import com.google.gwt.user.client.ui.*;

public abstract class AbstractClientMainAppEntryPoint implements EntryPoint,
                                                                 AppWindowLifeCycle,
                                                                 DataTableStyle
{
    /**
     * @noinspection NonJREEmulationClassesInClientCode
     */
    public static Logger CLIENT_LOGGER = LoggerFactory.getLogger( "Client" );

    public static boolean sWindowClosing = false;

    /**
     * @noinspection NonJREEmulationClassesInClientCode
     */
    public static final Logger ENTRY_POINT_LOGGER = LoggerFactory.getLogger( EntryPoint.class );

    protected final String mAppName;
    protected final String mShortAllLettersClientName;
    private static final String APP_PANEL = "AppPanel";

    protected AbstractClientMainAppEntryPoint( AppNames pAppNames )
    {
        mAppName = pAppNames.getAppName();
        mShortAllLettersClientName = pAppNames.getShortAllLettersClientName();
    }

    /**
     * This is the entry point method.
     */
    @Override
    public final void onModuleLoad()
    {
        System.err.println( new UtilDateAdaptor() + " | Application Client Start Up" );

        Window.addCloseHandler( this );
        Window.addWindowClosingHandler( this );

        OurUncaughtExceptionHandler handler = new OurUncaughtExceptionHandler( this );
        GWT.setUncaughtExceptionHandler( handler );

        RootPanel zBodyPanel = RootPanel.get();
        zBodyPanel.addStyleName( "litesoft-LayoutOverflowHidden" );
        zBodyPanel.addStyleName( GWT.isScript() ? "litesoft-RegularMode" : "litesoft-HostedMode" );
        /**
         * Add a class to the body element to enable platform-specific CSS rules.
         */
        UserAgent zUserAgent = UserAgent.getInstance();

        zBodyPanel.addStyleName( "UserAgent-" + zUserAgent.getFamily() );
        zBodyPanel.addStyleName( zUserAgent.isLegacyIE() ? "UserAgent-LegacyIE" : "UserAgent-Modern" );

        String zReally = zUserAgent.getReally();
        if ( Strings.isNotNullOrEmpty( zReally ) )
        {
            zBodyPanel.addStyleName( "Really" + zReally );
        }

        getAppPanel().addStyleName( "Platform-" + zUserAgent.getPlatform() );

        onAppLoad();
    }

    private RootPanel getAppPanel()
    {
        return RootPanel.get( APP_PANEL );
    }

    @Override
    public void onAppLoad()
    {
        nativeCodeInjection();
        prefetchImages();
    }

    @Override
    public void onWindowClosing( Window.ClosingEvent pEvent )
    {
    }

    @Override
    public void onClose( CloseEvent<Window> pEvent )
    {
        sWindowClosing = true;
        nativeCodeDispose();
        CLIENT_LOGGER.trace.log( "WindowClosing..." );
    }

    @Override
    public void prefetchImages()
    {
        AlertManager.prefetchImages();
    }

    @Override
    public void nativeCodeInjection()
    {
    }

    @Override
    public void nativeCodeDispose()
    {
    }

    protected SingleWidgetContainer replaceAppPanel()
    {
        return replaceAppPanel( new WindowSizingPanel() );
    }

    protected SingleWidgetContainer replaceAppPanel( SingleWidgetContainer pSWC )
    {
        Element zElement = RootPanel.get().getElement();
        CommonElementHelper.setOverflowHidden( zElement );
        CommonElementHelper.forceNoMarginOrPadding( zElement );

        //noinspection GwtToHtmlReferences
        RootPanel panel = getAppPanel();
        if ( panel == null )
        {
            UtilsGwt.closeWindowNoConfirm( "HTML Corrupted - Failed to find an element with an id of 'AppPanel' in the HTML host page\nWill attempt to close Window!" );
            return null;
        }
        panel.clear(); // properly remove GWT widgets
        zElement = panel.getElement();
        DOM.setInnerText( zElement, "" ); // remove static content
        DOM.setStyleAttribute( zElement, "height", null );
        CommonElementHelper.setOverflowHidden( zElement );
        panel.add( (Widget) pSWC );

        FontSizer.get( DATA_TABLE_TEXT );
        FontSizer.get( HEADER_TABLE_TEXT );

        return pSWC;
    }

    protected void handleUncaughtException( Throwable e )
    {
        if ( e != null )
        {
            ENTRY_POINT_LOGGER.error.log( e );
            AlertManager.alert( "MainApp", "Unexpected Exception", e.getClass().getName(), e );
        }
    }

    private static class OurUncaughtExceptionHandler implements GWT.UncaughtExceptionHandler
    {
        private AbstractClientMainAppEntryPoint mEntryPoint;

        public OurUncaughtExceptionHandler( AbstractClientMainAppEntryPoint pEntryPoint )
        {
            mEntryPoint = pEntryPoint;
        }

        @Override
        public void onUncaughtException( Throwable e )
        {
            if ( !sWindowClosing )
            {
                mEntryPoint.handleUncaughtException( e );
            }
        }
    }
}

Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/client/AbstractClientMainAppEntryPoint.java

Diff revisions: vs.
Revision Author Commited Message
947 Diff Diff GeorgeS picture GeorgeS Fri 06 Jun, 2014 23:36:56 +0000

Correct Spelling of package!

942 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 23:41:46 +0000

Extracting commonfoundation

939 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 21:30:31 +0000

Extracting commonfoundation

802 Diff Diff GeorgeS picture GeorgeS Wed 15 Aug, 2012 04:04:47 +0000
500 Diff Diff GeorgeS picture GeorgeS Sun 11 Sep, 2011 21:24:47 +0000
243 Diff Diff GeorgeS picture GeorgeS Sun 05 Jun, 2011 20:29:12 +0000
49 Diff Diff GeorgeS picture GeorgeS Mon 12 Apr, 2010 02:59:10 +0000

License Text

23 Diff Diff GeorgeS picture GeorgeS Wed 24 Feb, 2010 00:34:32 +0000
2 GeorgeS picture GeorgeS Sun 07 Feb, 2010 12:50:58 +0000