org.araneaframework.framework.container
Class StandardFlowContainerWidget

java.lang.Object
  extended by org.araneaframework.core.BaseComponent
      extended by org.araneaframework.core.BaseService
          extended by org.araneaframework.core.BaseWidget
              extended by org.araneaframework.core.BaseApplicationWidget
                  extended by org.araneaframework.framework.container.StandardFlowContainerWidget
All Implemented Interfaces:
Serializable, Component, Composite, Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget, ApplicationComponent, ApplicationService, ApplicationWidget, FlowContext, FlowContextWidget, Service, Viewable, Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget, Widget
Direct Known Subclasses:
ExceptionHandlingFlowContainerWidget, RootFlowContainerWidget

public class StandardFlowContainerWidget
extends BaseApplicationWidget
implements FlowContextWidget

A FlowContext where the flows are structured as a stack.

Author:
"Toomas Römer" , Jevgeni Kabanov (ekabanov at araneaframework dot org)
See Also:
Serialized Form

Nested Class Summary
protected static class StandardFlowContainerWidget.CallFrame
          A widget, configurator and a handler are encapsulated into one logical structure, a call frame.
protected  class StandardFlowContainerWidget.CancelClosure
           
protected  class StandardFlowContainerWidget.FinishClosure
           
protected  class StandardFlowContainerWidget.ReplaceClosure
           
protected  class StandardFlowContainerWidget.ResetClosure
           
static class StandardFlowContainerWidget.StandardTransitionHandler
           
protected  class StandardFlowContainerWidget.StartClosure
           
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseApplicationWidget
BaseApplicationWidget.CompositeImpl, BaseApplicationWidget.ViewableImpl, BaseApplicationWidget.ViewModel
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseWidget
BaseWidget.WidgetImpl
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseService
BaseService.ServiceImpl
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseComponent
BaseComponent.ComponentImpl
 
Nested classes/interfaces inherited from interface org.araneaframework.framework.FlowContext
FlowContext.Configurator, FlowContext.Handler, FlowContext.TransitionHandler
 
Nested classes/interfaces inherited from interface org.araneaframework.Widget
Widget.Interface
 
Nested classes/interfaces inherited from interface org.araneaframework.core.ApplicationWidget
ApplicationWidget.WidgetViewModel
 
Nested classes/interfaces inherited from interface org.araneaframework.core.ApplicationService
ApplicationService.ServiceViewModel
 
Nested classes/interfaces inherited from interface org.araneaframework.core.ApplicationComponent
ApplicationComponent.ComponentViewModel
 
Nested classes/interfaces inherited from interface org.araneaframework.Composite
Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget
 
Nested classes/interfaces inherited from interface org.araneaframework.Viewable
Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget
 
Nested classes/interfaces inherited from interface org.araneaframework.Composite
Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget
 
Nested classes/interfaces inherited from interface org.araneaframework.Viewable
Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget
 
Nested classes/interfaces inherited from interface org.araneaframework.Composite
Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget
 
Nested classes/interfaces inherited from interface org.araneaframework.Viewable
Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget
 
Field Summary
protected  LinkedList callStack
          The stack of all the calls.
protected  boolean finishable
           
protected  Widget top
          The top callable widget.
 
Fields inherited from class org.araneaframework.core.BaseService
currentInputData, currentOutputData
 
Fields inherited from interface org.araneaframework.framework.FlowContext
TRANSITION_CANCEL, TRANSITION_FINISH, TRANSITION_REPLACE, TRANSITION_RESET, TRANSITION_START
 
Fields inherited from interface org.araneaframework.core.ApplicationWidget
EVENT_HANDLER_ID_KEY, EVENT_PARAMETER_KEY, EVENT_PATH_KEY
 
Fields inherited from interface org.araneaframework.core.ApplicationService
ACTION_HANDLER_ID_KEY, ACTION_PARAMETER_KEY, ACTION_PATH_KEY
 
Constructor Summary
StandardFlowContainerWidget()
           
StandardFlowContainerWidget(Widget topWidget)
          Constructs a StandardFlowContainerWidget with topWidget being the first flow on the top of flow stack.
 
Method Summary
protected  void addFrameWidget(StandardFlowContainerWidget.CallFrame frame)
          Activates the widget represented by the StandardFlowContainerWidget.CallFrame.
 void addNestedEnvironmentEntry(ApplicationWidget scope, Object entryId, Object envEntry)
          Adds an environment entry that is visible in all subflows.
 void cancel()
          Finishes the current flow passing control back to the calling flow.
protected  void destroy()
          Destroy callback.
protected  void doCancel()
           
protected  void doFinish(Object returnValue)
           
protected  void doReplace(Widget flow, FlowContext.Configurator configurator)
           
protected  void doReset(EnvironmentAwareCallback callback)
           
protected  void doStart(Widget flow, FlowContext.Configurator configurator, FlowContext.Handler handler)
           
protected  void doTransition(FlowContext.TransitionHandler transitionHandler, int transitionType, org.apache.commons.collections.Closure closure)
           
 void finish(Object returnValue)
          Finishes the current flow passing control back to the calling flow.
protected  StandardFlowContainerWidget.CallFrame getActiveCallFrame()
           
 Widget getActiveFlow()
           
protected  LinkedList getCallStack()
           
protected  Environment getChildWidgetEnvironment()
          Returns the widget's Environment by default.
 FlowContext.TransitionHandler getTransitionHandler()
          Returns currently active FlowContext.TransitionHandler.
protected  void init()
          Init callback.
 boolean isNested()
          Returns whether the current flow is nested, that is has a caller flow.
protected  StandardFlowContainerWidget.CallFrame makeCallFrame(Widget callable, FlowContext.Configurator configurator, FlowContext.Handler handler, StandardFlowContainerWidget.CallFrame previous)
          Returns a new CallFrame constructed of the callable, configurator and handler.
protected  void putLocalEnvironmentEntries(Map nestedEnvironmentEntries)
           
protected  void render(OutputData output)
          Invokes render on the top frame on the stack of callframes.
 void replace(Widget flow)
          Destroys the current flow and starts a new one.
 void replace(Widget flow, FlowContext.Configurator configurator)
          Destroys the current flow and starts a new one.
 void reset(EnvironmentAwareCallback callback)
          Resets all currently running flows and calls the callback allowing to start new flows.
 void setFinishable(boolean finishable)
          Determines whether this StandardFlowContainerWidget will ever return control to FlowContext higher in the Component hierarchy.
 void setTop(Widget topWidget)
           
 void setTransitionHandler(FlowContext.TransitionHandler transitionHandler)
          Sets the FlowContext.TransitionHandler which performs the flow navigation.
 void start(Widget flow)
          Starts a new nested subflow.
 void start(Widget flow, FlowContext.Configurator configurator, FlowContext.Handler handler)
          Starts a new nested subflow, that can be configured using the configurator.
 void start(Widget flow, FlowContext.Handler handler)
          Starts a new nested subflow.
 
Methods inherited from class org.araneaframework.core.BaseApplicationWidget
_getComposite, _getViewable, action, addActionListener, addEventListener, addWidget, addWidget, clearActionListeners, clearEventlisteners, clearGlobalEventListener, disableWidget, enableWidget, event, getActionId, getChildEnvironment, getChildren, getEnvironment, getEventId, getViewModel, getWidget, handleAction, handleEvent, handleUpdate, propagate, putViewData, putViewDataOnce, removeActionListener, removeEventListener, removeViewData, removeWidget, setGlobalEventListener, update
 
Methods inherited from class org.araneaframework.core.BaseWidget
_getWidget, getInputData, getOutputData, handleWidgetException
 
Methods inherited from class org.araneaframework.core.BaseService
_getService, handleServiceException
 
Methods inherited from class org.araneaframework.core.BaseComponent
_addComponent, _addComponent, _checkCall, _disableComponent, _enableComponent, _endCall, _endWaitingCall, _getChildren, _getComponent, _getDisabledChildren, _propagate, _relocateComponent, _removeComponent, _setEnvironment, _setScope, _startCall, _startWaitingCall, _strictCheckCall, _strictStartCall, _waitNoCall, disable, enable, getScope, handleException, isAlive, isDead, isInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.araneaframework.Widget
_getWidget
 
Methods inherited from interface org.araneaframework.Service
_getService
 
Methods inherited from interface org.araneaframework.Component
_getComponent, getEnvironment, getScope, isAlive
 

Field Detail

callStack

protected LinkedList callStack
The stack of all the calls.


top

protected Widget top
The top callable widget.


finishable

protected boolean finishable
Constructor Detail

StandardFlowContainerWidget

public StandardFlowContainerWidget(Widget topWidget)
Constructs a StandardFlowContainerWidget with topWidget being the first flow on the top of flow stack.


StandardFlowContainerWidget

public StandardFlowContainerWidget()
Method Detail

setTop

public void setTop(Widget topWidget)

setFinishable

public void setFinishable(boolean finishable)
Determines whether this StandardFlowContainerWidget will ever return control to FlowContext higher in the Component hierarchy. If such FlowContext exists and finishable is set to true, this StandardFlowContainerWidget will return control to it when last running flow inside it is finished (FlowContext.finish(Object)) or canceled (FlowContext.cancel()). Default is true.

Parameters:
finishable -
Since:
1.1

start

public void start(Widget flow)
Description copied from interface: FlowContext
Starts a new nested subflow. Current flow becomes inactive untils subflow calls FlowContext.finish(Object) or FlowContext.cancel().

Specified by:
start in interface FlowContext

start

public void start(Widget flow,
                  FlowContext.Handler handler)
Description copied from interface: FlowContext
Starts a new nested subflow. Current flow becomes inactive untils subflow calls FlowContext.finish(Object) or FlowContext.cancel(). FlowContext.Handler allows to receive notification, when the subflow ends execution.

Specified by:
start in interface FlowContext

start

public void start(Widget flow,
                  FlowContext.Configurator configurator,
                  FlowContext.Handler handler)
Description copied from interface: FlowContext
Starts a new nested subflow, that can be configured using the configurator. Current flow becomes inactive untils subflow calls FlowContext.finish(Object) or FlowContext.cancel(). FlowContext.Handler allows to receive notification, when the subflow ends execution.

Specified by:
start in interface FlowContext

replace

public void replace(Widget flow)
Description copied from interface: FlowContext
Destroys the current flow and starts a new one. When the new flow will end execution it will return control to the caller of the current flow (if there is one).

Specified by:
replace in interface FlowContext

replace

public void replace(Widget flow,
                    FlowContext.Configurator configurator)
Description copied from interface: FlowContext
Destroys the current flow and starts a new one. When the new flow ends execution it will return control to the caller of the current flow (if there is one). Started subflow can be configured using the configurator.

Specified by:
replace in interface FlowContext

finish

public void finish(Object returnValue)
Description copied from interface: FlowContext
Finishes the current flow passing control back to the calling flow. Optionally may return some value that can be interpreted by the calling flow as the result of the call.

Specified by:
finish in interface FlowContext

cancel

public void cancel()
Description copied from interface: FlowContext
Finishes the current flow passing control back to the calling flow. Should be interpreted by the calling flow as a unsuccessful return.

Specified by:
cancel in interface FlowContext

reset

public void reset(EnvironmentAwareCallback callback)
Description copied from interface: FlowContext
Resets all currently running flows and calls the callback allowing to start new flows. Useful e.g. in a menu, when selecting a new menu item and reseting the old stack.

Specified by:
reset in interface FlowContext

getTransitionHandler

public FlowContext.TransitionHandler getTransitionHandler()
Description copied from interface: FlowContext
Returns currently active FlowContext.TransitionHandler.

Specified by:
getTransitionHandler in interface FlowContext

setTransitionHandler

public void setTransitionHandler(FlowContext.TransitionHandler transitionHandler)
Description copied from interface: FlowContext
Sets the FlowContext.TransitionHandler which performs the flow navigation.

Specified by:
setTransitionHandler in interface FlowContext

addNestedEnvironmentEntry

public void addNestedEnvironmentEntry(ApplicationWidget scope,
                                      Object entryId,
                                      Object envEntry)
Description copied from interface: FlowContext
Adds an environment entry that is visible in all subflows.

Specified by:
addNestedEnvironmentEntry in interface FlowContext

isNested

public boolean isNested()
Description copied from interface: FlowContext
Returns whether the current flow is nested, that is has a caller flow.

Specified by:
isNested in interface FlowContext

init

protected void init()
             throws Exception
Description copied from class: BaseComponent
Init callback. Gets called when the component is initilized.

Overrides:
init in class BaseComponent
Throws:
Exception - Any runtime exception that may occur.

destroy

protected void destroy()
                throws Exception
Description copied from class: BaseComponent
Destroy callback. Gets called when the component is destroyed.

Overrides:
destroy in class BaseComponent
Throws:
Exception - Any runtime exception that may occur.

render

protected void render(OutputData output)
               throws Exception
Invokes render on the top frame on the stack of callframes.

Overrides:
render in class BaseApplicationWidget
Throws:
Exception

putLocalEnvironmentEntries

protected void putLocalEnvironmentEntries(Map nestedEnvironmentEntries)

getChildWidgetEnvironment

protected Environment getChildWidgetEnvironment()
                                         throws Exception
Description copied from class: BaseApplicationWidget
Returns the widget's Environment by default. Usually overridden.

Overrides:
getChildWidgetEnvironment in class BaseApplicationWidget
Throws:
Exception

makeCallFrame

protected StandardFlowContainerWidget.CallFrame makeCallFrame(Widget callable,
                                                              FlowContext.Configurator configurator,
                                                              FlowContext.Handler handler,
                                                              StandardFlowContainerWidget.CallFrame previous)
Returns a new CallFrame constructed of the callable, configurator and handler.


getActiveCallFrame

protected StandardFlowContainerWidget.CallFrame getActiveCallFrame()

getActiveFlow

public Widget getActiveFlow()
Since:
1.1

addFrameWidget

protected void addFrameWidget(StandardFlowContainerWidget.CallFrame frame)
Activates the widget represented by the StandardFlowContainerWidget.CallFrame.

Since:
1.1

doTransition

protected void doTransition(FlowContext.TransitionHandler transitionHandler,
                            int transitionType,
                            org.apache.commons.collections.Closure closure)
Since:
1.1

doReset

protected void doReset(EnvironmentAwareCallback callback)
Since:
1.1

doStart

protected void doStart(Widget flow,
                       FlowContext.Configurator configurator,
                       FlowContext.Handler handler)
Since:
1.1

doFinish

protected void doFinish(Object returnValue)
Since:
1.1

doCancel

protected void doCancel()
Since:
1.1

doReplace

protected void doReplace(Widget flow,
                         FlowContext.Configurator configurator)
Since:
1.1

getCallStack

protected LinkedList getCallStack()