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.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget, BreadcrumbSupport, HistorySupport, ReportExport
Direct Known Subclasses:
LayoutController, OrgApplicationManager

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

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
protected  ViewContext context
           
static Callback<Boolean> NO_OP_CALLBACK
           
protected  Controller parentController
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Fields inherited from interface org.kuali.student.common.ui.client.reporting.ReportExport
exportTemplateName
 
Constructor Summary
protected Controller()
           
 
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.
 String collectHistory(String historyStack)
          This particular implementation appends to the history stack the name of the current view shown by this controller and view context (in string format) to that historyStack and passes the stack to be processed to the currentView.
 void doReportExport(List<ExportElement> exportElements, String format, String reportTitle)
          This method implement the "Generic Export" of a windows content to Jasper based on the format the user selected.
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.
protected  void fireNavigationEvent()
           
 View getCurrentView()
          Returns the currently displayed view
 Enum<?> getCurrentViewEnum()
           
 String getDefaultModelId()
           
 DataModel getExportDataModel()
          This method needs to be implemented on every controller that want's to export the data
 List<ExportElement> getExportElementsFromView()
          This method returns array of ExportElements which represent the elements on the view that must be exported
 String getExportTemplateName()
          This overridden method only needs to be implemented if the Generic Export reports has to be overwritten for a particular COntroller.
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.
protected
<V extends Enum<?>>
void
getView(V viewType, Callback<View> callback, Map<String,String> tokenMap)
          Returns the view associated with the specified enum value.
 ViewContext getViewContext()
           
abstract  Enum<?> getViewEnumValue(String enumValue)
           
protected abstract  void hideView(View view)
          Must be implemented by the subclass to hide the view.
 void onHistoryEvent(String historyStack)
          The onHistoryEvent implementation in controller reads the history stack it receives and determines if the next token/view to be processed is a controller, if it is, it hands off the rest of the history stack to that controller after showing it.
<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)
          Sets the view context.
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
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, 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, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, 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

parentController

protected Controller parentController

context

protected ViewContext context
Constructor Detail

Controller

protected Controller()
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

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 <V extends Enum<?>> void getView(V viewType,
                                           Callback<View> callback,
                                           Map<String,String> tokenMap)
Returns the view associated with the specified enum value. See showView(V viewType) above for a full description defaults to the abstract get view method unless overridden

Type Parameters:
V -
Parameters:
viewType -
callback -
tokenMap - optionally passed in token map if you need tokens from the history manager

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.


getViewEnumValue

public abstract Enum<?> getViewEnumValue(String enumValue)

collectHistory

public String collectHistory(String historyStack)
This particular implementation appends to the history stack the name of the current view shown by this controller and view context (in string format) to that historyStack and passes the stack to be processed to the currentView.

Specified by:
collectHistory in interface HistorySupport
See Also:
HistorySupport.collectHistory(java.lang.String)

getHistoryToken

protected String getHistoryToken()

onHistoryEvent

public void onHistoryEvent(String historyStack)
The onHistoryEvent implementation in controller reads the history stack it receives and determines if the next token/view to be processed is a controller, if it is, it hands off the rest of the history stack to that controller after showing it. Otherwise, it shows the view and allows that view to perform any onHistoryEvent actions it may need to take.

For example the historyStack /HOME/CURRICULUM_HOME/COURSE_PROPOSAL would start at the root controller, and hand it off to the home controller, then the curriculum home controller, then the course proposal controller and stop there. Along the way each of those controller would show themselves visually in the UI, if they contain any layout (some do not).

Specified by:
onHistoryEvent in interface HistorySupport
See Also:
HistorySupport.onHistoryEvent(java.lang.String)

setViewContext

public void setViewContext(ViewContext viewContext)
Sets the view context. This is important for determining the permission for seeing views under this controllers scope, what the id and id type of the model the controller handles are defined here. Additional attributes that the controller and it's views need to know about are also defined in the viewContext.

Parameters:
viewContext -

getViewContext

public ViewContext getViewContext()

resetCurrentView

public void resetCurrentView()

doReportExport

public void doReportExport(List<ExportElement> exportElements,
                           String format,
                           String reportTitle)
This method implement the "Generic Export" of a windows content to Jasper based on the format the user selected. This method can be overwritten on a subclass to do specific export to the specific view

Specified by:
doReportExport in interface ReportExport
See Also:
org.kuali.student.common.ui.client.reporting.ReportExport#doReportExport(java.util.ArrayList)

getExportDataModel

public DataModel getExportDataModel()
Description copied from interface: ReportExport
This method needs to be implemented on every controller that want's to export the data

Specified by:
getExportDataModel in interface ReportExport
Returns:

getExportTemplateName

public String getExportTemplateName()
Description copied from interface: ReportExport
This overridden method only needs to be implemented if the Generic Export reports has to be overwritten for a particular COntroller.

Specified by:
getExportTemplateName in interface ReportExport
See Also:
ReportExport.getExportTemplateName()

getExportElementsFromView

public List<ExportElement> getExportElementsFromView()
Description copied from interface: ReportExport
This method returns array of ExportElements which represent the elements on the view that must be exported

Specified by:
getExportElementsFromView in interface ReportExport
Returns:


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.