001package votorola.s.gwt.scene; // Copyright 2011-2012, Michael Allan.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE.
002
003import com.google.gwt.dom.client.*;
004import votorola.a.web.gwt.*;
005
006
007/** The GWT entry module for launching Crossforum Theatre (both stage and scenes) as a
008  * stand-alone GWT application.  An instance of this class is automatically constructed
009  * and invoked per module definition <a
010  * href='../../../../../../s/gwt/scene/SceneIn.gwt.xml'
011  * target='_top'>SceneIn.gwt.xml</a>.  It then calls global JavaScript function
012  * <code>voGWTConfig.s_gwt_scene</code> if it is defined.  Here is an example function
013  * definition suitable for use in the configuration script {@linkplain GWTConfig
014  * gwt.js}:<pre>
015  *
016  *     voGWTConfig.s_gwt_scene = function()
017  *     {
018  *         s_gwt_scene_Scenes_setUseRAC( true );
019  *         s_gwt_scene_geo_Geomap_setDefaultBaseLayerName( 'Osmarender OSM' );
020  *         // and so on
021  *     };</pre>
022  *
023  * <p>See the complete <a
024  * href='../../../../votorola/a/web/gwt/class-use/GWTConfigCallback.html'>list of configuration
025  * callacks</a>.  Usage instructions are provided for each.</p>
026  */
027public final @GWTConfig class SceneIn implements EntryPointS
028{
029
030
031    /** Answers whether this module's {@linkplain GWTConfigCallback configurable classes} are
032      * currently being forced to initialize in preparation for configuration.  This is
033      * for asserting in boilerplate code that is liable to be incorrectly copied.  If you
034      * see the corresponding assertion error, then simply add the offending class to
035      * {@linkplain #onModuleLoad() onModuleLoad}'s forced initialization.
036      */
037    public static boolean isForcedInit() { return isForcedInit; }
038
039
040        private static boolean isForcedInit;
041
042
043
044   // - E n t r y - P o i n t ------------------------------------------------------------
045
046
047    public final void onModuleLoad()
048    {
049        isForcedInit = true;
050        try // force class init prior to callback from config script gwt.js
051        {
052            votorola.s.gwt.scene.Scenes.forceInitClass();
053            votorola.s.gwt.scene.geo.Geomap.forceInitClass();
054        }
055        finally { isForcedInit = false; }
056        configureJS();
057        if( App.getServletContextLocation() == null ) // default to relative URL:
058        {
059            String loc = Document.get().getURL();            // http://n.t/v/xf/default.html?q=t#frag
060              // maybe OPT with GWT.getHostPageBaseURL or getModuleBaseURL
061            int endBound = loc.length();
062            int c = loc.indexOf( '#' );
063            if( c >= 0 && c < endBound ) endBound = c;       // http://n.t/v/xf/default.html?q=t
064            c = loc.lastIndexOf( '?', endBound - 1 );
065            if( c >= 0 && c < endBound ) endBound = c;       // http://n.t/v/xf/default.html
066            endBound = loc.lastIndexOf( '/', endBound - 1 ); // http://n.t/v/xf
067            endBound = loc.lastIndexOf( '/', endBound - 1 ); // http://n.t/v
068            loc = loc.substring( 0, endBound );
069            App.setServletContextLocation( loc );
070        }
071        EntryPointS.U.schedule( SceneIn.this );
072        EntryPointS.U.execute(); // because all modules are now loaded
073    }
074
075
076
077   // - S c h e d u l e r . S c h e d u l e d - C o m m a n d ----------------------------
078
079
080    public void execute()
081    {
082        new Scenes();
083        new ScenesV();
084    }
085
086
087
088//// P r i v a t e ///////////////////////////////////////////////////////////////////////
089
090
091    private static native void configureJS()
092    /*-{
093        var f;
094        try{ f = $wnd.voGWTConfig.s_gwt_scene; } catch( e ) {} // in case parents undefined
095        if( f ) f();
096    }-*/;
097
098
099}