LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.app.behavior
Class LySessionBehavior

java.lang.Object
  extended by leon.app.behavior.LyDataSessionBehavior
      extended by leon.app.behavior.LySessionBehavior
All Implemented Interfaces:
LyDataSessionBehaviorInterface, LySessionBehaviorInterface, LyAnswerInterface, LyQuestionAnswerInterface

public class LySessionBehavior
extends LyDataSessionBehavior
implements LySessionBehaviorInterface, LyQuestionAnswerInterface

This class implements the default behavior of a session.

See Also:
LySession, LySessionBehaviorInterface

Field Summary
static java.lang.String __VERSION
          File version
static java.lang.String ENABLE_ACTION
           
static java.lang.String VALIDATE_ACTION
           
 
Constructor Summary
LySessionBehavior()
          Constructor.
 
Method Summary
 java.lang.String checkControllerId(LyController controller, java.lang.String id)
          Method to compute id of the given controller.
 void close(LySession session)
          Method called when a session is closed.
 void controllerAdded(LySession session, LyController controller)
          Method called when a controller is added to the session.
 void controllerRemoved(LySession session, LyController controller)
          Method called when a controller is removed from the session.
 boolean enableAction(LySession session, LyAction action, LyController controller, LyObjectList objects, boolean showError)
          Enables the given action on the given list of objects for the given controller.
 boolean enableTransverseAction(LySession session, LyAction action, LyClassInfo classInfo, LyController controller, LyObjectList objects, boolean showError)
          Enables the given transverse action on the given list of objects for the given controller.
 void exit(LySession session)
          Method called when the user ask to quit the given session.
 LyController findExistingController(LySession session, LyController parent, LyAction action, LyClassInfo classInfo, LyObjectList objects, boolean recurseAllSessions)
          Searches for an existing controller being shown, and return it if found.
 java.lang.String getHelpFile(LySession session, LyController controller, LyAction action)
          Get an help file for the given session, the given controller and the given action.
 LyAction getRootAction(LySession session)
          Gets root action for this session.
 LyController getRootContextController(LySession session)
          Get a root level context controller.
 int getSessionTimeout(LySession session)
          Gets the session time out for the current session.
 boolean handleDemand(LySession session, LyController controller, LyDemand demand)
          Invoked when a demand is sent to this listener of this session.
 LyController invokeAction(LySession session, LyController controller, LyAction action, LyClassInfo classInfo, LyObjectList objects, boolean show)
          Invoke an action.
 boolean invokeExtraAction(LySession session, LyController controller, LyAction action, LyClassInfo classInfo, LyObjectList objects, boolean show)
          Invoke an action that has no controller.
 LyInfoList<LyInfo> loadUserPreferences(LySession session, java.lang.String userId)
          Load session preferences.
 LyInfoList<LyInfo> loadUserStickers(LySession session, java.lang.String userId)
          Load session stickers.
 void questionAnswer(boolean result, java.lang.Object clientData)
          Answer to a askQuestion request.
 void sessionTimeout(LySession session)
          Method invoked when a session is in time out.
 void showAbout(LySession session, LyController parent)
          Method invoked when the user ask for the 'about' action.
 void showHelp(LySession session, LyController parent)
          Method invoked when the user ask for the 'help' action.
 void showLog(LySession session, LyController controller)
          Show the log file.
 void showVersion(LySession session, LyController parent)
          Method invoked when the user ask for the 'version' action.
 void start(LySession session)
          Method called when a session is started.
 boolean validateAction(LySession session, LyAction action, LyController controller)
          Validates the given action for the given controller.
 void viewControllerHidden(LySession session, LyViewController viewController)
          Method called when a view controller is hidden within the given session.
 void viewControllerShown(LySession session, LyViewController viewController)
          Method called when a view controller is shown within the given session.
 
Methods inherited from class leon.app.behavior.LyDataSessionBehavior
close, connectionLost, controlBeforeCommit, free, getDefaultUnitForField, getKeyValue, getUser, handleException, start, updateUndoRedo
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface leon.app.behaviorinterface.LyDataSessionBehaviorInterface
close, connectionLost, controlBeforeCommit, free, getDefaultUnitForField, getKeyValue, getUser, handleException, start, updateUndoRedo
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
File version

See Also:
Constant Field Values

ENABLE_ACTION

public static final java.lang.String ENABLE_ACTION
See Also:
Constant Field Values

VALIDATE_ACTION

public static final java.lang.String VALIDATE_ACTION
See Also:
Constant Field Values
Constructor Detail

LySessionBehavior

public LySessionBehavior()
Constructor.

Method Detail

start

public void start(LySession session)
Method called when a session is started.
The default implementation checks that the session application has a root action and validate the session if the root action is not a login action.

Specified by:
start in interface LySessionBehaviorInterface
Parameters:
session - the started session.

getRootAction

public LyAction getRootAction(LySession session)
Gets root action for this session.

Specified by:
getRootAction in interface LySessionBehaviorInterface
Parameters:
session - current session.
Returns:
the root action for the session

loadUserPreferences

public LyInfoList<LyInfo> loadUserPreferences(LySession session,
                                              java.lang.String userId)
Load session preferences.

Specified by:
loadUserPreferences in interface LySessionBehaviorInterface
Parameters:
session - Session on which preferences are loaded.
userId - Id of the session user (may be null if preference is shared).
Returns:
List of preferences of the session.

loadUserStickers

public LyInfoList<LyInfo> loadUserStickers(LySession session,
                                           java.lang.String userId)
Load session stickers.

Specified by:
loadUserStickers in interface LySessionBehaviorInterface
Parameters:
session - Session on which stickers are loaded.
userId - Id of the session user (may be null if preference is shared).
Returns:
List of stickers of the session.

close

public void close(LySession session)
Method called when a session is closed.
The default implementation only calls LySession.confirmClosing() method.

Specified by:
close in interface LySessionBehaviorInterface
Parameters:
session - the closed session.

exit

public void exit(LySession session)
Method called when the user ask to quit the given session.
The default implementation asks confirmation to the user before exiting.

Specified by:
exit in interface LySessionBehaviorInterface
Parameters:
session - Session to exit from

questionAnswer

public void questionAnswer(boolean result,
                           java.lang.Object clientData)
Answer to a askQuestion request. Here any answer terminates the confirmation.

Specified by:
questionAnswer in interface LyQuestionAnswerInterface
Parameters:
result - true if the user has clicked on Yes or Ok
clientData - data specified in the askQuestion method
See Also:
LyViewManager.askQuestion(leon.view.LyComponent, String, LyQuestionAnswerInterface, Object)

checkControllerId

public java.lang.String checkControllerId(LyController controller,
                                          java.lang.String id)
Method to compute id of the given controller.

Specified by:
checkControllerId in interface LySessionBehaviorInterface
Parameters:
controller - The new controller.
id - Desired id.
Returns:
Id of the new controller.

controllerAdded

public void controllerAdded(LySession session,
                            LyController controller)
Method called when a controller is added to the session.
The default implementation does nothing.

Specified by:
controllerAdded in interface LySessionBehaviorInterface
Parameters:
session - Session in which a controller is added.
controller - Controller added to the session.

controllerRemoved

public void controllerRemoved(LySession session,
                              LyController controller)
Method called when a controller is removed from the session.
The default implementation does nothing.

Specified by:
controllerRemoved in interface LySessionBehaviorInterface
Parameters:
session - Session in which a controller is removed.
controller - Controller removed from the session.

viewControllerShown

public void viewControllerShown(LySession session,
                                LyViewController viewController)
Method called when a view controller is shown within the given session.
The default implementation does nothing.

Specified by:
viewControllerShown in interface LySessionBehaviorInterface
Parameters:
session - the session
viewController - The view controller that is shown.

viewControllerHidden

public void viewControllerHidden(LySession session,
                                 LyViewController viewController)
Method called when a view controller is hidden within the given session.
The default implementation does nothing.

Specified by:
viewControllerHidden in interface LySessionBehaviorInterface
Parameters:
session - the session
viewController - The view controller that is hidden.

validateAction

public boolean validateAction(LySession session,
                              LyAction action,
                              LyController controller)
Validates the given action for the given controller.
The default implementation does nothing and returns true because all actions are by default valid.

Specified by:
validateAction in interface LySessionBehaviorInterface
Parameters:
session - the current session
action - the action to validate
controller - the controller for this action
Returns:
true if the action is valid, false otherwise.

enableAction

public boolean enableAction(LySession session,
                            LyAction action,
                            LyController controller,
                            LyObjectList objects,
                            boolean showError)
Enables the given action on the given list of objects for the given controller.
The default implementation checks if the number of selected objects match the min and max value of the action. If a filter is defined on the action, this behavior checks that the action is allowed on every object and that every object pass the filter.

Specified by:
enableAction in interface LySessionBehaviorInterface
Parameters:
session - the current session
action - the action to enable
controller - the controller for this action
objects - list of objects on which the action has to be enabled
showError - report an error if the action is not enabled
Returns:
true if the action is enabled, false otherwise.

enableTransverseAction

public boolean enableTransverseAction(LySession session,
                                      LyAction action,
                                      LyClassInfo classInfo,
                                      LyController controller,
                                      LyObjectList objects,
                                      boolean showError)
Enables the given transverse action on the given list of objects for the given controller.
The default implementation only calls enableAction(session, action, controller, objects, showError) and returns its result.

Specified by:
enableTransverseAction in interface LySessionBehaviorInterface
Parameters:
session - the current session
action - the action to enable
classInfo - the classInfo in which the action is checked
controller - the controller for this action
objects - list of objects on which the action has to be enabled
showError - report an error if the action is not enabled
Returns:
true if the action is enabled, false otherwise.

invokeExtraAction

public boolean invokeExtraAction(LySession session,
                                 LyController controller,
                                 LyAction action,
                                 LyClassInfo classInfo,
                                 LyObjectList objects,
                                 boolean show)
Invoke an action that has no controller.
This function is the right place to implement an application specific action because it is not driven by a controller.
The default implementation does nothing and returns false.

Specified by:
invokeExtraAction in interface LySessionBehaviorInterface
Parameters:
session - the current session
controller - the source controller
action - the action to execute
classInfo - class on which the action applies
objects - list of objects on which the action applies
show - indicates if the action must be shown or not
Returns:
true if the action was handled by this behavior, false otherwise.

invokeAction

public LyController invokeAction(LySession session,
                                 LyController controller,
                                 LyAction action,
                                 LyClassInfo classInfo,
                                 LyObjectList objects,
                                 boolean show)
Invoke an action.
This function is the right place to implement an application specific action.
The default implementation does nothing and returns null because it does not handle any Action.

Specified by:
invokeAction in interface LySessionBehaviorInterface
Parameters:
session - the current session
controller - the source controller
action - the action to execute
classInfo - class on which the action applies
objects - list of objects on which the action applies
show - indicates if the action must be shown or not
Returns:
the controller corresponding to the invoked action.

getSessionTimeout

public int getSessionTimeout(LySession session)
Gets the session time out for the current session.

Specified by:
getSessionTimeout in interface LySessionBehaviorInterface
Parameters:
session - the current session
Returns:
the session timeout in seconds

getRootContextController

public LyController getRootContextController(LySession session)
Get a root level context controller. This controller when created defines a top level session context : GUI modification Like set controller should become subcontext of this context. Usually this method returns null (no controller is a top level context controller). The ImportTableController is defining a root level context to grab all user modifications in the import context while the import table is active.

Specified by:
getRootContextController in interface LySessionBehaviorInterface
Parameters:
session - the current session
Returns:
the root level context controller if any, or null if it could not be found.

sessionTimeout

public void sessionTimeout(LySession session)
Method invoked when a session is in time out.
The default implementation does nothing.

Specified by:
sessionTimeout in interface LySessionBehaviorInterface
Parameters:
session - the current session

showAbout

public void showAbout(LySession session,
                      LyController parent)
Method invoked when the user ask for the 'about' action.
The default implementation shows a popup to the user if the given session has a view manager, logs out the 'about' message otherwise.

Specified by:
showAbout in interface LySessionBehaviorInterface
Parameters:
session - the current session
parent - the parent controller

showHelp

public void showHelp(LySession session,
                     LyController parent)
Method invoked when the user ask for the 'help' action. This method must show the corresponding help to the user.

Specified by:
showHelp in interface LySessionBehaviorInterface
Parameters:
session - the current session
parent - the parent controller

showVersion

public void showVersion(LySession session,
                        LyController parent)
Method invoked when the user ask for the 'version' action.
The default implementation shows a popup to the user if the given session has a view manager, logs out the 'version' message otherwise.

Specified by:
showVersion in interface LySessionBehaviorInterface
Parameters:
session - the current session
parent - the parent controller

handleDemand

public boolean handleDemand(LySession session,
                            LyController controller,
                            LyDemand demand)
Invoked when a demand is sent to this listener of this session.

Specified by:
handleDemand in interface LySessionBehaviorInterface
Parameters:
session - the current session
controller - controller that routed the demand.
demand - demand parameters sent by the view component.
Returns:
Return true if the demand was handled, false otherwise. If false, the demand is transmitted to the controller to try to handle it.

findExistingController

public LyController findExistingController(LySession session,
                                           LyController parent,
                                           LyAction action,
                                           LyClassInfo classInfo,
                                           LyObjectList objects,
                                           boolean recurseAllSessions)
Searches for an existing controller being shown, and return it if found.

Specified by:
findExistingController in interface LySessionBehaviorInterface
Parameters:
session - the current session
parent - The source controller.
action - The action to execute.
classInfo - The class on which the action applies.
objects - The list of objects on which the action applies.
recurseAllSessions - indicates if we recurse into all sessions of the application.
Returns:
the controller if found, null otherwise
See Also:
invokeAction(leon.app.LySession, leon.control.LyController, leon.info.LyAction, leon.info.LyClassInfo, leon.data.LyObjectList, boolean)

getHelpFile

public java.lang.String getHelpFile(LySession session,
                                    LyController controller,
                                    LyAction action)
Get an help file for the given session, the given controller and the given action. This default implementation returns null.

Specified by:
getHelpFile in interface LySessionBehaviorInterface
Parameters:
session - the current session.
controller - the controller of the action.
action - the action for which the helpfile is required.
Returns:
the path to the help file, or null if we have to use the generic help file behavior.

showLog

public void showLog(LySession session,
                    LyController controller)
Show the log file. To override.

Specified by:
showLog in interface LySessionBehaviorInterface
Parameters:
session - the current session
controller - the parent controller

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com