public final class Stage extends Object implements HasHandlers, TheatrePage, WarningSink
The staged state of each page is persisted to ensure that changes by the user (selections and so forth) are not lost due to page reload during back and forth navigation, refresh, and so forth. (A memory cache such as Firefox's BFCache, or WebKit's page cache will also do this, but is not available for all browsers, nor enabled for all pages.) For this to work correctly, scenes and props must initialize on page load vis-a-vis the stage only via theatre initializers that are registered with the stage.
To clear the persisted state and load a pristine page either (A) close and reopen
the window or tab, or otherwise restart the browsing session; or (B) clear the web
store (also known as DOM or HTML5 storage) by whatever means the browser provides
(e.g. entering sessionStorage.clear()
in the Firebug console); or (C) use
the following procedure to clear the state for a single page: (1) ensure the URL has a
fragment '#' delimiter by appending it if necessary; (2) also append "voStage.clear"
to the end of the URL; (3) press return as if to navigate to that fragment; and
finally (4) reload the page. For example here's a URL in its original form and with
the necessary appendage:
http://somewhere.com/fu#bar http://somewhere.com/fu#bar&voStage.clear
The stage provides a mechanism for the selective transfer of state during transit from one page (referrer) to another via hypertext links. This allows user selections and such to persist across pages. This persistence is controlled by the props that depend upon it via the initTo(stage,referrer) methods of their registered initializers.
Subsequent state changes such as those initiated by the user are generally expected as late as the "finally" phase of each event dispatch. The associated change events are then dispatched in the "deferred" phase where they appear atomic regardless of the number of state variables involved. There is a minor exception to this rule: late registration of an initializer (i) will nevertheless flush pending events immediately, as stipulated by i.initFromComplete and initToComplete.
Events are propagated via the common event bus. Each event is pre-dispatched from the suppressable prompter first. The event is cancelled if it gets suppressed, otherwise it is re-dispatched from the ordinary source.
A defaulting property is one that has a default mechanism, such as "difference". A defaulting property that changes from null to the default value, or from the default value to null, exhibits no effective change in its value. The value remains at the default and the change is said to be masked. No change event "NAME" is fired in this case, but rather a change event "NAME masked".
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Stage.StateChunker
Utilities for dealing with a chunk of state that may persist across time and/or
pages and sites.
|
Constructor and Description |
---|
Stage()
Creates the single instance of Stage.
|
Modifier and Type | Method and Description |
---|---|
void |
addInitializer(TheatreInitializer i)
Adds a theatre initializer to be run either immediately or later, depending on the
current state of initialization.
|
void |
addWarning(String warning)
Adds a plain text warning for the user.
|
(package private) void |
appendJSON(StringBuilder b)
Appends a string that encodes the state of this stage as a sequence of JSON
name/value pairs suitable for underwriting an instance of TheatrePageJS, all but for the pageLocation and the surrounding
curly braces.
|
boolean |
areDifferencesShadowed()
Answers whether the page is a position draft to be decorated by difference
shadows, once the necessary differences are fetched from the server.
|
void |
fireEvent(GwtEvent<?> e) |
String |
getActorName()
The username of the actor who is shown, or null if nobody in particular is shown
and no default is set.
|
String |
getDefaultActorName()
The username of the default actor, or null if there is none.
|
DiffLook |
getDefaultDifference()
The key of the default difference, or null if there is none.
|
String |
getDefaultPollName()
The default poll name, or null if there is none.
|
DiffLook |
getDifference()
The key of the difference that is shown, or null if none in particular is shown
and no default is set.
|
Message |
getMessage()
The message that is shown, or null if none in particular is shown.
|
String |
getPollName()
The name of the poll that is shown, or null if none in particular is shown and no
default is set.
|
static Stage |
i()
The single instance of Stage.
|
(package private) void |
init0()
Begins initialization of the stage.
|
(package private) void |
init1(TheatrePageJS _referrer,
ReferrerRelayer _referrerRelayer,
boolean _isReferencePending)
Continues initialization of the stage.
|
(package private) void |
init2b_async(TheatrePageJS latelyResolvedReferrer)
Continues initialization of the stage in the case of a deferred referrer
resolution.
|
LightBank |
lightBank()
The light bank for this stage.
|
String |
pageLocation()
The URL of the page without a fragment.
|
SuppressableSource |
prompter()
The source from which stage events are pre-dispatched.
|
static void |
setActorName(String newActorName)
Sets the username of the actor who is shown, or effectively resets it to the
default.
|
static void |
setDefaultActorName(String newDefault)
Sets the username of the default actor, firing a change event if it affects
the bound property "actorName".
|
static void |
setDefaultDifference(DiffLook newDefault)
Sets the key of the default difference, firing a change event if it affects
the bound property "difference".
|
static void |
setDefaultPollName(String newDefault)
Sets the default poll name, firing a change event if it affects the bound
property "pollName".
|
void |
setDifference(DiffLook k)
Sets the key of the difference that is shown, or effectively resets it to the
default.
|
void |
setDifferencesShadowed()
Specifies that the page is a position draft to be decorated by difference
shadows.
|
void |
setMessage(Message newMessage)
Sets the message that is shown.
|
void |
setPollName(String newPollName)
Sets the name of the poll that is shown, or effectively resets it to the
default.
|
String |
toString() |
List<Track> |
tracks()
The list of all tracks on stage.
|
List<String> |
warnings()
A list of warnings for the user.
|
(package private) void |
wrapJSON(StringBuilder b)
Wraps a sequence of name/value pairs to form a proper JSON object, after removing
any trailing comma (,).
|
Stage()
void init0()
void init1(TheatrePageJS _referrer, ReferrerRelayer _referrerRelayer, boolean _isReferencePending)
_isReferencePending
- whether the referrer (if any) remains to be
resolved asynchronously. When true, _referrer must be null.void init2b_async(TheatrePageJS latelyResolvedReferrer)
public void addInitializer(TheatreInitializer i)
void appendJSON(StringBuilder b)
public boolean areDifferencesShadowed()
public void setDifferencesShadowed()
areDifferencesShadowed()
public SuppressableSource prompter()
GWTX.bus()
void wrapJSON(StringBuilder b)
appendJSON(StringBuilder)
public void fireEvent(GwtEvent<?> e)
fireEvent
in interface HasHandlers
public String pageLocation()
TheatrePage
pageLocation
in interface TheatrePage
public String getActorName()
getActorName
in interface TheatrePage
setActorName(String)
,
IDPair.username()
@GWTInitCallback public static void setActorName(String newActorName)
s_gwt_stage_Stage_setActorName( 'Joe-GmailCom' ); // otherwise null
newActorName
- the name to set, or null to effectively reset it to
the default name.getActorName()
public String getDefaultActorName()
TheatrePage
getDefaultActorName
in interface TheatrePage
getActorName()
,
setDefaultActorName(String)
@GWTInitCallback public static void setDefaultActorName(String newDefault)
s_gwt_stage_Stage_setDefaultActorName( 'Joe-GmailCom' ); // otherwise null
getDefaultActorName()
public DiffLook getDifference()
getDifference
in interface TheatrePage
setDifference(DiffLook)
public void setDifference(DiffLook k)
k
- the key to set, or null to effectively reset it to the
default.getDifference()
public DiffLook getDefaultDifference()
TheatrePage
getDefaultDifference
in interface TheatrePage
getDifference()
,
setDefaultDifference(DiffLook)
@GWTInitCallback public static void setDefaultDifference(DiffLook newDefault)
s_gwt_stage_Stage_setDefaultDifference( // otherwise null { key: '5270.5284', selectand: 'b' });
getDefaultDifference()
public Message getMessage()
getMessage
in interface TheatrePage
setMessage(Message)
public void setMessage(Message newMessage)
getMessage()
public String getPollName()
getPollName
in interface TheatrePage
setPollName(String)
public void setPollName(String newPollName)
newPollName
- the new name to set, or null to effectively reset it to
the default name.getPollName()
public String getDefaultPollName()
TheatrePage
getDefaultPollName
in interface TheatrePage
getPollName()
,
setDefaultPollName(String)
@GWTInitCallback public static void setDefaultPollName(String newDefault)
s_gwt_stage_Stage_setDefaultPollName( 'Sys/p/Sandbox' ); // otherwise null
getDefaultPollName()
public void addWarning(String warning)
WarningSink
addWarning
in interface WarningSink
warnings()
public List<String> warnings()
addWarning(String)