org.kuali.student.common.ui.client.mvc
Class Controller

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by org.kuali.student.common.ui.client.mvc.Controller
All Implemented Interfaces:
com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, BreadcrumbSupport, HistorySupport
Direct Known Subclasses:
LayoutController, OrgApplicationManager, ViewLayout

public abstract class Controller
extends com.google.gwt.user.client.ui.Composite
implements HistorySupport, BreadcrumbSupport

Abstract Controller composite. Provides basic controller operations, and defines abstract methods that a composite must implement in order to be a controller.

Author:
Kuali Student Team

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
private  com.google.gwt.event.shared.HandlerManager applicationEventHandlers
           
protected  ViewContext context
           
private  String controllerId
           
private  View currentView
           
private  Enum<?> currentViewEnum
           
private  String defaultModelId
           
private  boolean fireNavEvents
           
private  Map<String,ModelProvider<? extends Model>> models
           
static Callback<Boolean> NO_OP_CALLBACK
           
protected  Controller parentController
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
protected Controller(String controllerId)
           
 
Method Summary
 com.google.gwt.event.shared.HandlerRegistration addApplicationEventHandler(com.google.gwt.event.shared.GwtEvent.Type type, ApplicationEventHandler handler)
          Registers an application eventhandler.
 void beforeViewChange(Enum<?> viewChangingTo, Callback<Boolean> okToChangeCallback)
          If a controller which extends this class must perform some action or check before a view is changed, then override this method.
private
<V extends Enum<?>>
void
beginShowView(View view, V viewType, Callback<Boolean> onReadyCallback)
           
 void clearViewContext()
           
 String collectHistory(String historyStack)
           
private
<V extends Enum<?>>
void
finalizeShowView(View view, V viewType, Callback<Boolean> onReadyCallback)
           
static Controller findController(com.google.gwt.user.client.ui.Widget w)
          Attempts to find the parent controller of a given widget via the DOM
 void fireApplicationEvent(ApplicationEvent event)
          Fires an application event.
 void fireNavEvents(boolean fireEvents)
           
protected  void fireNavigationEvent()
           
 String getControllerId()
           
 View getCurrentView()
          Returns the currently displayed view
 Enum<?> getCurrentViewEnum()
           
 String getDefaultModelId()
           
protected  String getHistoryToken()
           
 Controller getParentController()
          Returns the parent controller.
protected abstract
<V extends Enum<?>>
void
getView(V viewType, Callback<View> callback)
          Returns the view associated with the specified enum value.
 ViewContext getViewContext()
           
abstract  Enum<?> getViewEnumValue(String enumValue)
           
abstract  Class<? extends Enum<?>> getViewsEnum()
           
protected abstract  void hideView(View view)
          Must be implemented by the subclass to hide the view.
 void onHistoryEvent(String historyStack)
           
<T extends Model>
void
registerModel(String modelId, ModelProvider<T> provider)
           
protected abstract  void renderView(View view)
          Must be implemented by the subclass to render the view.
 void requestModel(Class modelType, ModelRequestCallback callback)
          Called by child views and controllers to request a model reference.
 void requestModel(ModelRequestCallback callback)
           
 void requestModel(String modelId, ModelRequestCallback callback)
           
 void resetCurrentView()
           
 void setCurrentViewEnum(Enum<?> currentViewEnum)
           
 void setDefaultModelId(String defaultModelId)
           
 void setParentController(Controller controller)
          Sets the controller's parent controller.
 void setViewContext(ViewContext viewContext)
           
abstract  void showDefaultView(Callback<Boolean> onReadyCallback)
          Shows the default view.
<V extends Enum<?>>
void
showView(V viewType)
          Simple Version of showView, no callback
<V extends Enum<?>>
void
showView(V viewType, Callback<Boolean> onReadyCallback)
          Directs the controller to display the specified view.
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
getWidget, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addDomHandler, addHandler, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.kuali.student.common.ui.client.mvc.breadcrumb.BreadcrumbSupport
collectBreadcrumbNames
 

Field Detail

NO_OP_CALLBACK

public static final Callback<Boolean> NO_OP_CALLBACK

controllerId

private final String controllerId

parentController

protected Controller parentController

currentView

private View currentView

currentViewEnum

private Enum<?> currentViewEnum

defaultModelId

private String defaultModelId

context

protected ViewContext context

models

private final Map<String,ModelProvider<? extends Model>> models

fireNavEvents

private boolean fireNavEvents

applicationEventHandlers

private com.google.gwt.event.shared.HandlerManager applicationEventHandlers
Constructor Detail

Controller

protected Controller(String controllerId)
Method Detail

showView

public <V extends Enum<?>> void showView(V viewType)
Simple Version of showView, no callback

Type Parameters:
V - view enum type
Parameters:
viewType - enum value representing the view to show

showView

public <V extends Enum<?>> void showView(V viewType,
                                         Callback<Boolean> onReadyCallback)
Directs the controller to display the specified view. The parameter must be an enum value, based on an enum defined in the controller implementation. For example, a "Search" controller might have an enumeration of: public enum SearchViews { SIMPLE_SEARCH, ADVANCED_SEARCH, SEARCH_RESULTS } The implementing class must define a getView(V viewType) method that will cast the generic enum to the view specific enum.

Type Parameters:
V - view enum type
Parameters:
viewType - enum value representing the view to show
onReadyCallback - the callback to invoke when the method has completed execution

beginShowView

private <V extends Enum<?>> void beginShowView(View view,
                                               V viewType,
                                               Callback<Boolean> onReadyCallback)

finalizeShowView

private <V extends Enum<?>> void finalizeShowView(View view,
                                                  V viewType,
                                                  Callback<Boolean> onReadyCallback)

fireNavigationEvent

protected void fireNavigationEvent()

getCurrentView

public View getCurrentView()
Returns the currently displayed view

Returns:
the currently displayed view

getCurrentViewEnum

public Enum<?> getCurrentViewEnum()

setCurrentViewEnum

public void setCurrentViewEnum(Enum<?> currentViewEnum)

setParentController

public void setParentController(Controller controller)
Sets the controller's parent controller. In most cases, this can be omitted as the controller will be automatically detected via the DOM in cases where it is not specified. The only time that the controller needs to be manually set is in cases where the logical controller hierarchy differs from the physical DOM hierarchy. For example, if a nested controller is rendered in a PopupPanel, then the parent controller must be set manually using this method

Parameters:
controller - the parent controller

getParentController

public Controller getParentController()
Returns the parent controller. If the current parent controller is not set, then the controller will attempt to automatically locate the parent controller via the DOM.

Returns:

findController

public static Controller findController(com.google.gwt.user.client.ui.Widget w)
Attempts to find the parent controller of a given widget via the DOM

Parameters:
w - the widget for which to find the parent controller
Returns:
the controller, or null if not found

requestModel

public void requestModel(Class modelType,
                         ModelRequestCallback callback)
Called by child views and controllers to request a model reference. By default it delegates calls to the parent controller if one is found. Override this method to declare a model local to the controller. Always make sure to delegate the call to the superclass if the requested type is not one which is defined locally. For example:

Parameters:
modelType -
callback -

requestModel

public void requestModel(String modelId,
                         ModelRequestCallback callback)

requestModel

public void requestModel(ModelRequestCallback callback)

registerModel

public <T extends Model> void registerModel(String modelId,
                                            ModelProvider<T> provider)

getDefaultModelId

public String getDefaultModelId()

setDefaultModelId

public void setDefaultModelId(String defaultModelId)

addApplicationEventHandler

public com.google.gwt.event.shared.HandlerRegistration addApplicationEventHandler(com.google.gwt.event.shared.GwtEvent.Type type,
                                                                                  ApplicationEventHandler handler)
Registers an application eventhandler. The controller will try to propagate "unchecked" handlers to the parent controller if a parent controller exists. This method can be overridden to handle unchecked locally if they are fired locally.

Parameters:
type -
handler -
Returns:

fireApplicationEvent

public void fireApplicationEvent(ApplicationEvent event)
Fires an application event.

Parameters:
event -

renderView

protected abstract void renderView(View view)
Must be implemented by the subclass to render the view.

Parameters:
view -

hideView

protected abstract void hideView(View view)
Must be implemented by the subclass to hide the view.

Parameters:
view -

getView

protected abstract <V extends Enum<?>> void getView(V viewType,
                                                    Callback<View> callback)
Returns the view associated with the specified enum value. See showView(V viewType) above for a full description

Type Parameters:
V -
Parameters:
viewType -

beforeViewChange

public void beforeViewChange(Enum<?> viewChangingTo,
                             Callback<Boolean> okToChangeCallback)
If a controller which extends this class must perform some action or check before a view is changed, then override this method. Do not call super() in the override, as it will allow the view to continue to change.

Parameters:
okToChangeCallback -

showDefaultView

public abstract void showDefaultView(Callback<Boolean> onReadyCallback)
Shows the default view. Must be implemented by subclass, in order to define the default view.


getViewsEnum

public abstract Class<? extends Enum<?>> getViewsEnum()

getViewEnumValue

public abstract Enum<?> getViewEnumValue(String enumValue)

collectHistory

public String collectHistory(String historyStack)
Specified by:
collectHistory in interface HistorySupport

getHistoryToken

protected String getHistoryToken()

onHistoryEvent

public void onHistoryEvent(String historyStack)
Specified by:
onHistoryEvent in interface HistorySupport

setViewContext

public void setViewContext(ViewContext viewContext)

getViewContext

public ViewContext getViewContext()

clearViewContext

public void clearViewContext()

getControllerId

public String getControllerId()

resetCurrentView

public void resetCurrentView()

fireNavEvents

public void fireNavEvents(boolean fireEvents)


Copyright © 2010 The Kuali Foundation. All rights reserved.