com.threerings.crowd.client
Class PlaceController

java.lang.Object
  extended by com.samskivert.swing.Controller
      extended by com.threerings.crowd.client.PlaceController
All Implemented Interfaces:
ActionListener, EventListener

public abstract class PlaceController
extends Controller

Controls the user interface that is used to display a place. When the client moves to a new place, the appropriate place controller is constructed and requested to create and display the user interface for that place.


Nested Class Summary
static class PlaceController.DelegateOp
          Used to call methods in delegates.
 
Nested classes/interfaces inherited from class com.samskivert.swing.Controller
Controller.ActionInvoker
 
Field Summary
protected  PlaceConfig _config
          A reference to our place configuration.
protected  CrowdContext _ctx
          A reference to the active client context.
protected  ArrayList<PlaceControllerDelegate> _delegates
          A list of the delegates in use by this controller.
protected  PlaceObject _plobj
          A reference to the place object for which we're controlling a user interface.
protected  PlaceView _view
          A reference to the root user interface component.
 
Fields inherited from class com.samskivert.swing.Controller
DISPATCHER
 
Constructor Summary
PlaceController()
           
 
Method Summary
protected  void addDelegate(PlaceControllerDelegate delegate)
          Adds the supplied delegate to the list for this controller.
protected  void applyToDelegates(PlaceController.DelegateOp op)
          Applies the supplied operation to the registered delegates.
protected  PlaceView createPlaceView()
          Deprecated. Use createPlaceView(CrowdContext).
protected  PlaceView createPlaceView(CrowdContext ctx)
          Creates the user interface that will be used to display this place.
protected  void didInit()
          Derived classes can override this and perform any post-initialization processing they might need.
 void didLeavePlace(PlaceObject plobj)
          This is called by the location director when we are leaving this place and need to clean up after ourselves and shutdown.
 PlaceConfig getPlaceConfig()
          Returns the PlaceConfig associated with this place.
 PlaceView getPlaceView()
          Returns a reference to the place view associated with this controller.
 boolean handleAction(ActionEvent action)
          Handles basic place controller action events.
 void init(CrowdContext ctx, PlaceConfig config)
          Initializes this place controller with a reference to the context that they can use to access client services and to the configuration record for this place.
 void mayLeavePlace(PlaceObject plobj)
          Called before a request is submitted to the server to leave the current place.
 void willEnterPlace(PlaceObject plobj)
          This is called by the location director once the place object has been fetched.
 
Methods inherited from class com.samskivert.swing.Controller
actionPerformed, configureAction, createActionButton, generateArguments, handleAction, handleAction, handleAction, postAction, postAction, postAction, setControlledPanel, wasAdded, wasRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_ctx

protected CrowdContext _ctx
A reference to the active client context.


_config

protected PlaceConfig _config
A reference to our place configuration.


_plobj

protected PlaceObject _plobj
A reference to the place object for which we're controlling a user interface.


_view

protected PlaceView _view
A reference to the root user interface component.


_delegates

protected ArrayList<PlaceControllerDelegate> _delegates
A list of the delegates in use by this controller.

Constructor Detail

PlaceController

public PlaceController()
Method Detail

init

public void init(CrowdContext ctx,
                 PlaceConfig config)
Initializes this place controller with a reference to the context that they can use to access client services and to the configuration record for this place. The controller should create as much of its user interface that it can without having access to the place object because this will be invoked in parallel with the fetching of the place object. When the place object is obtained, the controller will be notified and it can then finish the user interface configuration and put the user interface into operation.

Parameters:
ctx - the client context.
config - the place configuration for this place.

didInit

protected void didInit()
Derived classes can override this and perform any post-initialization processing they might need. They should of course be sure to call super.didInit().


getPlaceView

public PlaceView getPlaceView()
Returns a reference to the place view associated with this controller. This is only valid after a call has been made to init(com.threerings.crowd.util.CrowdContext, com.threerings.crowd.data.PlaceConfig).


getPlaceConfig

public PlaceConfig getPlaceConfig()
Returns the PlaceConfig associated with this place.


createPlaceView

protected PlaceView createPlaceView(CrowdContext ctx)
Creates the user interface that will be used to display this place. The view instance returned will later be configured with the place object, once it becomes available.

Parameters:
ctx - a reference to the CrowdContext associated with this controller.

createPlaceView

@Deprecated
protected PlaceView createPlaceView()
Deprecated. Use createPlaceView(CrowdContext).

Obsolete but retained for runtime compatibility with the old and busted.


willEnterPlace

public void willEnterPlace(PlaceObject plobj)
This is called by the location director once the place object has been fetched. The place controller will dispatch the place object to the user interface hierarchy via PlaceViewUtil.dispatchWillEnterPlace(java.lang.Object, com.threerings.crowd.data.PlaceObject). Derived classes can override this and perform any other starting up that they need to do


mayLeavePlace

public void mayLeavePlace(PlaceObject plobj)
Called before a request is submitted to the server to leave the current place. As such, this method may be called multiple times before didLeavePlace(com.threerings.crowd.data.PlaceObject) is finally called. The request to leave may be rejected, but if a place controller needs to flush any information to the place manager before it leaves, it should so do here. This is the only place in which the controller is guaranteed to be able to communicate to the place manager, as by the time didLeavePlace(com.threerings.crowd.data.PlaceObject) is called, the place manager may have already been destroyed.


didLeavePlace

public void didLeavePlace(PlaceObject plobj)
This is called by the location director when we are leaving this place and need to clean up after ourselves and shutdown. Derived classes should override this method (being sure to call super.didLeavePlace) and perform any necessary cleanup.


handleAction

public boolean handleAction(ActionEvent action)
Handles basic place controller action events. Derived classes should be sure to call super.handleAction for events they don't specifically handle.

Overrides:
handleAction in class Controller

addDelegate

protected void addDelegate(PlaceControllerDelegate delegate)
Adds the supplied delegate to the list for this controller.


applyToDelegates

protected void applyToDelegates(PlaceController.DelegateOp op)
Applies the supplied operation to the registered delegates.