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 votorola.a.web.gwt.GWTConfig; 004 005 006/** An initializer of theatre state. Initializers must ordinarily {@linkplain 007 * Stage#addInitializer(TheatreInitializer) register with the stage}. The {@linkplain 008 * votorola.a.web.gwt.GWTConfig gwt.js} configuration script is implicitly registered, as 009 * some of the <a 010 * href='../../../../votorola/a/web/gwt/class-use/GWTInitCallback.html'>configuration 011 * methods</a> exposed to it are restricted to initializers. Each registered initializer 012 * (plus <code>gwt.js</code>) receives a call to either <strong>A</strong> 013 * <code>initFrom</code> and then <code>initFromComplete</code>, or <strong>B</strong> 014 * <code>initTo</code> and then <code>initToComplete</code>, but never both A and B. 015 * 016 * @see <a href='Stage.html#persistPage'>Persistence of state in a single page</a> 017 */ 018public @GWTConfig interface TheatreInitializer 019{ 020 021 022 // - T h e a t r e - I n i t i a l i z e r -------------------------------------------- 023 024 025 /** Here the prop or other component initializes its own properties by reference to a 026 * previously initialized stage. This method is called on page load after the state 027 * of the stage has been restored via <a href='Stage.html#persistPage'>single-page 028 * persistence</a>. Writing to the stage is permitted here, though ordinarily only 029 * page authors will do this and only in cases where a stage property needs to be 030 * re-initialized owing to a change in the environment, such as a structual change to 031 * the page. 032 * 033 * <p>The equivalent JavaScript callback is the global function 034 * <code>voGWTConfig.s_gwt_stage_Stage_initFrom</code>. It may be defined in the 035 * {@linkplain votorola.a.web.gwt.GWTConfig gwt.js} configuration script, for 036 * example.</p> 037 * 038 * @param rPending whether the referrer (if any) remains to be resolved. If this 039 * flag is true, then initialization will eventually complete at {@linkplain 040 * #initUltimately(Stage,TheatrePage) initUltimately}; otherwise it will 041 * complete earlier at {@linkplain #initFromComplete(Stage,boolean) 042 * initFromComplete}. 043 */ 044 public void initFrom( Stage s, boolean rPending ); 045 046 047 048 /** Signals that <code>initFrom</code> was called for all props and that immediate 049 * initialization of the stage is complete and the associated events have fired. 050 * Referrer resolution may yet follow depending on the value of 051 * <code>rPending</code>. This method is called only when the state is initialized 052 * by restoration, i.e. in those cases where <code>initFrom</code> is called. 053 * 054 * <p>The equivalent JavaScript callback is the global function 055 * <code>voGWTConfig.s_gwt_stage_Stage_initFromComplete</code>. It may be defined in 056 * the {@linkplain votorola.a.web.gwt.GWTConfig gwt.js} configuration script, for 057 * example.</p> 058 * 059 * @param rPending true if initialization will eventually complete at {@linkplain 060 * #initUltimately(Stage,TheatrePage) initUltimately}; false if this is the end 061 * of it. 062 */ 063 public void initFromComplete( Stage s, boolean rPending ); 064 065 066 067 /** Here the prop or other component initializes the properties of the stage. This 068 * method is called on page load when a new page is created from scratch and the 069 * referrer (if any) cannot immediately be resolved. Referrer resolution will be 070 * signaled by a subsequent call to {@linkplain #initUltimately(Stage,TheatrePage) 071 * initUltimately}. 072 * 073 * <p>The equivalent JavaScript callback is the global function 074 * <code>voGWTConfig.s_gwt_stage_Stage_initTo</code>. It may be defined in the 075 * {@linkplain votorola.a.web.gwt.GWTConfig gwt.js} configuration script, for 076 * example.</p> 077 */ 078 public void initTo( Stage s ); 079 080 081 082 /** Here the prop or other component initializes the properties of the stage. This 083 * method is called on page load when a new page is created from scratch and the 084 * referrer (if any) can immediately be resolved. Referrer resolution enables <a 085 * href='Stage.html#persistCrossPage' target='_top'>cross-page persistence</a>. As a 086 * general rule, a prop may transfer state from the referrer to the stage if it also 087 * provides the user with both control over that state <em>and</em> the ability to 088 * restore it. Thus the user might transit a link from one page (referrer) in which 089 * a difference is shown, for example, to a new page (destination) where the same 090 * difference is automatically selected by a prop that makes use of the 091 * <code>r</code> parameter. The prop will also provide a means of selecting other 092 * differences and of re-selecting the original one, such that the user need never 093 * navigate back and re-transit the link for this purpose. 094 * 095 * <p>A prop ought generally to avoid transferring a given property from a referrer 096 * when it already has a non-default value on the destination, whether set by the 097 * scene or by another prop. By the same token, an initializer that sets a default 098 * value for a property, such as {@linkplain Stage#setDefaultActorName(String) actor 099 * name}, will typically null the ordinary value to ensure that the default is 100 * immediately exhibited. It is recommended however that defaults be set earlier, 101 * e.g. during module initialization.</p> 102 * 103 * <p>The equivalent JavaScript callback is the global function 104 * <code>voGWTConfig.s_gwt_stage_Stage_initTo</code>. It may be defined in the 105 * {@linkplain votorola.a.web.gwt.GWTConfig gwt.js} configuration script, for 106 * example.</p> 107 * 108 * @param r the theatre page that linked to this page (referrer), or null if 109 * there was none. 110 */ 111 public void initTo( Stage s, TheatrePage r ); 112 113 114 115 /** Signals that <code>initTo</code> was called for all props and that immediate 116 * initialization of the stage is complete and the associated events have fired. 117 * Referrer resolution may yet follow depending on the value of 118 * <code>rPending</code>. This method is called only when the state is initialized 119 * from scratch, i.e. in those cases where <code>initTo</code> is called. 120 * 121 * <p>The equivalent JavaScript callback is the global function 122 * <code>voGWTConfig.s_gwt_stage_Stage_initToComplete</code>. It may be defined in 123 * the {@linkplain votorola.a.web.gwt.GWTConfig gwt.js} configuration script, for 124 * example.</p> 125 * 126 * @param rPending true if initialization will eventually complete at {@linkplain 127 * #initUltimately(Stage,TheatrePage) initUltimately}; false if this is the end 128 * of it. 129 */ 130 public void initToComplete( Stage s, boolean rPending ); 131 132 133 134 /** Signals that deferred resolution of the referrer is now complete. This method is 135 * called last of all, and only if <code>rPending</code> was asserted in one of the 136 * previous initialization calls. Resolution is never deferred longer than {@value 137 * votorola.s.gwt.stage.ReferrerRelayer#MAX_REFERRER_RESOLUTION_MS} milliseconds. 138 * 139 * <p>The equivalent JavaScript callback is the global function 140 * <code>voGWTConfig.s_gwt_stage_Stage_initUltimately</code>. It may be defined in 141 * the {@linkplain votorola.a.web.gwt.GWTConfig gwt.js} configuration script, for 142 * example.</p> 143 * 144 * @param r the theatre page that linked to this page (referrer), or null if 145 * there was none. The prop may transfer state from the referrer as noted for 146 * {@link #initTo(Stage,TheatrePage) initTo}(stage,referrer), but with the 147 * further stipulation that any state changes by the user subsequent to the 148 * completion of immediate initialization ought to be honoured and not 149 * overidden. 150 */ 151 public void initUltimately( Stage s, TheatrePage r ); 152 153 154}