001package votorola.s.gwt.stage; // Copyright 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.*; 005import votorola.g.hold.*; 006 007 008/** The GWT library module for the Crossforum Theatre stage. An instance of this class is 009 * automatically constructed and invoked per module definition <a 010 * href='../../../../../s/gwt/stage/StageMod.gwt.xml' target='_top'>StageMod.gwt.xml</a>. 011 * It then calls global JavaScript function <code>voGWTConfig.s_gwt_stage</code> if it is 012 * defined. Here is an example function definition suitable for use in the configuration 013 * script {@linkplain GWTConfig gwt.js}:<pre> 014 * 015 * voGWTConfig.s_gwt_stage = function() 016 * { 017 * s_gwt_stage_link_NominalDifferenceTargeter_setEnabled(); 018 * s_gwt_stage_vote_CountNodeV_setDeselectionGuard( 'Lax' ); 019 * s_gwt_stage_vote_DifferenceLight_setScene( 'Frank-FlippityNet' ); 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 * callbacks</a>. Usage instructions are provided for each.</p> 026 */ 027public final @GWTConfig class StageMod 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 void onModuleLoad() 048 { 049 final Spool configurationSpool = new Spool1(); 050 isForcedInit = true; 051 try // force class init prior to callback from config script gwt.js 052 { 053 votorola.s.gwt.stage.link.NominalDifferenceTargeter.forceInitClass(); 054 votorola.s.gwt.stage.vote.NodeV.forceInitClass( configurationSpool ); 055 votorola.s.gwt.stage.vote.DifferenceLight.forceInitClass(); 056 } 057 finally { isForcedInit = false; } 058 configureJS(); 059 if( PollwikiG.getScriptLocation() == null ) // default: 060 { 061 String serverName = Document.get().getDomain(); 062 if( serverName == null ) serverName = "localhost"; 063 PollwikiG.setScriptLocation( "http://" + serverName + "/mediawiki" ); 064 } 065 if( PollwikiG.getLocation() == null ) // default: 066 { 067 PollwikiG.setLocation( PollwikiG.getScriptLocation() + "/index.php" ); 068 } 069 configurationSpool.unwind(); 070 new Stage(); 071 EntryPointS.U.schedule( StageMod.this ); 072 } 073 074 075 076 // - 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 ---------------------------- 077 078 079 public void execute() { Stage.i().init0(); } 080 081 082 083//// P r i v a t e /////////////////////////////////////////////////////////////////////// 084 085 086 private static native void configureJS() 087 /*-{ 088 var f; 089 try{ f = $wnd.voGWTConfig.s_gwt_stage; } catch( e ) {} // in case parents undefined 090 if( f ) f(); 091 }-*/; 092 093 094}