com.sencha.gxt.state.client
Class AbstractStateHandler<S,O>

java.lang.Object
  extended by com.sencha.gxt.state.client.AbstractStateHandler<S,O>
Type Parameters:
S - the state interface
O - the concrete type of the object state will be applied to
All Implemented Interfaces:
BeforeRestoreStateEvent.HasBeforeRestoreStateHandlers<S,O>, BeforeSaveStateEvent.HasBeforeSaveStateHandlers<S,O>, RestoreStateEvent.HasRestoreStateHandlers<S,O>, SaveStateEvent.HasSaveStateHandlers<S,O>
Direct Known Subclasses:
ComponentStateHandler

public abstract class AbstractStateHandler<S,O>
extends Object
implements BeforeRestoreStateEvent.HasBeforeRestoreStateHandlers<S,O>, RestoreStateEvent.HasRestoreStateHandlers<S,O>, BeforeSaveStateEvent.HasBeforeSaveStateHandlers<S,O>, SaveStateEvent.HasSaveStateHandlers<S,O>

Simple class to add support for reading and writing state. Can be subclassed and a concrete type given to O (such as a Store or Component subclass), and a particular interface S can be defined to hold the state for this object.


Method Summary
 HandlerRegistration addBeforeRestoreStateHandler(BeforeRestoreStateEvent.BeforeRestoreStateHandler<S,O> handler)
          Adds a BeforeRestoreStateEvent.BeforeRestoreStateHandler handler for BeforeRestoreStateEvent events.
 HandlerRegistration addBeforeSaveStateHandler(BeforeSaveStateEvent.BeforeSaveStateHandler<S,O> handler)
          Adds a BeforeSaveStateEvent.BeforeSaveStateHandler handler for BeforeSaveStateEvent events.
 HandlerRegistration addRestoreStateHandler(RestoreStateEvent.RestoreStateHandler<S,O> handler)
          Adds a RestoreStateEvent.RestoreStateHandler handler for RestoreStateEvent events.
 HandlerRegistration addSaveStateHandler(SaveStateEvent.SaveStateHandler<S,O> handler)
          Adds a SaveStateEvent.SaveStateHandler handler for SaveStateEvent events.
abstract  void applyState()
          Applies the currently loaded state to the current stateful object.
 O getObject()
          Returns the target object.
 S getState()
          Returns the state.
 void loadState()
          Starts to load the state for the given object.
 void saveState()
          Saves the current state.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addBeforeRestoreStateHandler

public HandlerRegistration addBeforeRestoreStateHandler(BeforeRestoreStateEvent.BeforeRestoreStateHandler<S,O> handler)
Description copied from interface: BeforeRestoreStateEvent.HasBeforeRestoreStateHandlers
Adds a BeforeRestoreStateEvent.BeforeRestoreStateHandler handler for BeforeRestoreStateEvent events.

Specified by:
addBeforeRestoreStateHandler in interface BeforeRestoreStateEvent.HasBeforeRestoreStateHandlers<S,O>
Parameters:
handler - the handler
Returns:
the registration for the event

addBeforeSaveStateHandler

public HandlerRegistration addBeforeSaveStateHandler(BeforeSaveStateEvent.BeforeSaveStateHandler<S,O> handler)
Description copied from interface: BeforeSaveStateEvent.HasBeforeSaveStateHandlers
Adds a BeforeSaveStateEvent.BeforeSaveStateHandler handler for BeforeSaveStateEvent events.

Specified by:
addBeforeSaveStateHandler in interface BeforeSaveStateEvent.HasBeforeSaveStateHandlers<S,O>
Parameters:
handler - the handler
Returns:
the registration for the event

addRestoreStateHandler

public HandlerRegistration addRestoreStateHandler(RestoreStateEvent.RestoreStateHandler<S,O> handler)
Description copied from interface: RestoreStateEvent.HasRestoreStateHandlers
Adds a RestoreStateEvent.RestoreStateHandler handler for RestoreStateEvent events.

Specified by:
addRestoreStateHandler in interface RestoreStateEvent.HasRestoreStateHandlers<S,O>
Parameters:
handler - the handler
Returns:
the registration for the event

addSaveStateHandler

public HandlerRegistration addSaveStateHandler(SaveStateEvent.SaveStateHandler<S,O> handler)
Description copied from interface: SaveStateEvent.HasSaveStateHandlers
Adds a SaveStateEvent.SaveStateHandler handler for SaveStateEvent events.

Specified by:
addSaveStateHandler in interface SaveStateEvent.HasSaveStateHandlers<S,O>
Parameters:
handler - the handler
Returns:
the registration for the event

applyState

public abstract void applyState()
Applies the currently loaded state to the current stateful object.


getObject

public O getObject()
Returns the target object.

Returns:
the target object

getState

public S getState()
Returns the state.

Returns:
the currently loaded state. The state instance may not be set, so this may return null.

loadState

public void loadState()
Starts to load the state for the given object.


saveState

public void saveState()
Saves the current state.



Copyright © 2012. All Rights Reserved.