Class AppSessionGyro
- java.lang.Object
- com.iizix.server.gyro.AppSessionGyro
- All Implemented Interfaces:
IPrivateStorage
,IAppSessionGyro
,IFocusEngineProvider
,IMessageBox
,IRuntimeImageCache
,IToaster
,IRuntimeReferenceLookup
,IVirtualizedReferenceLookup
,IGyroFocusEngineOwner
,ILocaleString
public class AppSessionGyro extends java.lang.Object implements IVirtualizedReferenceLookup, IRuntimeReferenceLookup, IFocusEngineProvider, IAppSessionGyro, IGyroFocusEngineOwner
Gyro instance that is used for a single user running one application. If parallel client sessions is enabled or allowed, a single AppSessionGyro is shared among all client sessions and their transaction processors.- Author:
- Christopher Mindus
Nested Class Summary
Nested classes/interfaces inherited from interface com.iizix.gyro.IMessageBox
IMessageBox.Icon
Nested classes/interfaces inherited from interface com.iizix.gyro.IToaster
IToaster.Direction, IToaster.Position, IToaster.Type
Field Summary
Fields inherited from interface com.iizix.gyro.IAppSessionGyro
STORAGE_NAME
Fields inherited from interface com.iizix.gyro.IMessageBox
ICON_ERROR, ICON_INFORMATION, ICON_MAP, ICON_NONE, ICON_QUESTION, ICON_WARNING
Fields inherited from interface com.iizix.gyro.IToaster
TOASTER_DEFAULT_DURATION, TOASTER_MAX_DURATION, TOASTER_MIN_DURATION
Constructor Summary
Constructors Constructor Description AppSessionGyro(ServerShell server, SessionInfo appSessionInfo, java.lang.ThreadGroup appThreadGroup, UserSessions userSessions, ClientParams clientParams, AuthenticatedUser authUser)
Constructs the instance of the application for the first user session.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addClientConnectionListener(IClientSessionConnectionListener listener)
Adds a client connection listener for the application session.boolean
addDisposeListener(IAppSessionDisposeListener listener)
Adds a dispose listener for the application session.LoginResult
changeExternallyAuthenticatedUser(AuthenticatedUser authUser)
Changes the authenticated user due an external authentication mechanism such as LinkedIn.void
clearImageCache()
Clears the entire cache.void
closeAuthenticationWindows()
Closes the remote windows for authentication.ClientSessionGyro
createClientSessionGyro(ClientEndPoint clientEndPoint, Worker worker, EnvProps envProps)
Called to create the ClientSessionGyro for the first client session or for parallel client sessions.int
decrementUILock()
Decreases the incremental lock state.boolean
dispose()
Disposes of the Application session gyro, and effectively closes all the client sessions and end point connections.AppFactory
getAppFactory()
Gets the application factory.IAppHistory
getAppHistory()
Returns the application session history used for backward and forward navigation.java.lang.String
getAppID()
Gets the application ID.IKStringInfoProvider
getAppKStringInfoProvider()
Retrieves the KStringInfoProvider for the application session.ITimerEngine
getApplicationTimerEngine()
Gets the application timer engine.AppPropCnr
getAppPropCnr()
Gets the application root for static references look-up.WSFileProvider
getAppSessionFileProvider()
Get the web server file provider for the application session.SessionInfo
getAppSessionInfo()
Gets the application session info.java.lang.ThreadGroup
getAppThreadGroup()
Gets the AppSessionGyro's Thread Group.Worker
getAppWorker()
Gets the Worker for the Application.AuthenticatedUser
getAuthenticatedUser()
Gets the authenticated user information.java.lang.String
getAuthenticatedUserUUID()
Gets the user ID for background location service identification.ClientSessionGyro[]
getClientSessionGyros()
Gets the active client session Gyro's for this application session Gyro.int
getClientSessionsCount()
Gets the count of client sessions.long
getCreationTime()
Gets the creation time in milliseconds.IVSComponent
getCurrentFocus()
Returns the current focus in the VirtualSpace.java.lang.String
getCustomAppValue(java.lang.String key)
Gets a value for a key in the custom app properties.EnvProps
getEnvironment()
Gets the original environment properties for Selector's or Value's.IFocusEngine
getFocusEngine(IFocusComp comp)
Returns the focus engine instance for the specified component.RuntimeImageDefinition
getImage(java.lang.String name)
Gets an image definition from the image container for the client session.IKStringInfoProvider
getKStringInfoProvider()
Retrieves the KStringInfoProvider for the application session.java.lang.String
getLanguageCode()
Gets the language code of the application session.LocaleInfo
getLocale()
Gets the local info class instance.KString
getLocaleKString(java.lang.String id, boolean system)
Gets the KString of a particular ID from the app's text tables that are flagged to also handle LocaleString's depending on the flag.ILocationService
getLocationService()
Returns the location service for the application session.int
getLockCount()
Returns the incremental lock count that governs the UI locking state.PrettyLocaledTexts
getPrettyLocaledTexts()
Gets the locale'd texts instance for the sessions language and text tables.java.util.Map<java.lang.String,java.lang.Object>
getPrivateStorageMap()
Gets the concurrent hash map used to store the private data.PropCnr
getRootFromName(GProp<?> requestor, java.lang.String module)
Gets the module root for a name.GProp<?>
getRuntimePropFromReference(java.lang.String reference)
Gets a reference for runtime use to get the reference of an item.GProp<?>
getRuntimePropFromReference(java.lang.String reference, boolean fallBackToNonVirtualized)
Gets a reference for runtime use to get the reference of an item.ServerShell
getServer()
Gets the server of this session.ServerConfigEnvProps
getServerConfigurationEnvironment()
Gets the selected Server configuration environment for the Application Session.static AppSessionGyro
getSessionInstance()
Gets the AppSessionGyro instance for the current thread in an application session.static AppSessionGyro
getSessionInstance(SessionInfo sessionInfo)
Gets the AppSessionGyro instance for the current thread in a client session.SessionUserIdentifier
getSessionUserIdentifier()
Gets the SessionUserIdentifier.ITXPCoordinator
getTransactionCoordinator()
Gets the transaction coordinator of the session.IUserAuthenticationUI
getUserAuthenticationUI()
Gets the user authentication UI interface used for the initial login.GProp<?>
getVirtualizedPropFromReference(java.lang.String reference)
Attempts to look up a virtualized property from a reference to the VirtualSpace only.VirtualSpace
getVirtualizedVirtualSpace(VirtualSpace virtualSpace, boolean doVirtualize)
Gets the virtualized counterpart of a VirtualSpace.IVSComponent
getVirtualizedVSComponent(IVSComponent component)
Gets the virtualized VSComponent counterpart from a non-virtualized VSComponent.<VSC extends VSComponent>
VSCgetVirtualizedVSComponent(VSC component)
Gets the virtualized VSComponent counterpart from a non-virtualized VSComponent.<T extends PropCnr>
VirtualsContainer<T>getVirtuals(IPluginDescriptor<T> serverPluginDescriptor)
Gets the instance of the VirtualsContainer for the plug-in.IVirtualsContainer<VirtualSpace>
getVirtualSpaceVirtualsContainer()
The VirtualsContainer instance for VirtualSpace.int
incrementUILock()
Increases the incremental lock state.boolean
initialize(EnvProps envProps, ClientSessionGyro clientGyro)
Initiates the application for the client session.boolean
isDisposed()
Checks if the application session Gyro is disposed of.boolean
isUILocked()
Get the current UI lock state.boolean
isVirtualized(VirtualSpace virtualSpace)
Returns if a VirtualSpace already is virtualized for the application.boolean
lockUI(KString waitMsg, int delay)
Locks the UI with a message and a delay.boolean
lockUI(KString waitMsg, ProgressIndicatorDelay delay)
Locks the UI with a message and a delay.void
messageBox(IMessageBoxReply reply, IMessageBox.Icon icon, KString title, KString message, KString... buttons)
Displays a message box with the specified title and message.void
onFocusChanged(IFocusComp newComp, IFocusComp oldComp, IGProp<?> trigger, boolean isRemoteInduced, boolean isInternal)
Called when focus changes.void
onFocusVetoChange(FocusEvent event)
Called to perform veto.boolean
removeClientConnectionListener(IClientSessionConnectionListener listener)
Removes a client connection listener for the application session.boolean
removeDisposeListener(IAppSessionDisposeListener listener)
Removes a dispose listener for the application session.boolean
removeImage(java.lang.String name)
Removes an image with a name from the client session.IOAuthCallbackProvider
requestOAuthCallbackDisplay(IOAuthService service)
Requests the OAuth (1.0a or 2.0) authentication callback provider to show an URL to the user in order to be accepted.ILockState
requestUILock()
Requests a UI lock state.boolean
setImage(RuntimeImageDefinition image)
Adds the image definition to the image container for the client session.boolean
setLockMessage(KString msg)
Sets the message to display for the lock state, above the indicator.boolean
setLockMessage(KString msg, int progress)
Sets the message to display for the lock state, above the indicator, along with a progress value.boolean
setLockMessage(KString msg, int delay, int progress)
Sets the message to display for the lock state, above the indicator, along with a progress value.boolean
setLockProgress(int progress)
Sets the current progress bar value.java.lang.String
setVirtualizeSupportFocus(IVSComponent vsComp)
Sets the focus to the specified VS component, regardless if the VS component is virtualized or not.java.lang.String
setVirtualizeSupportFocus(IVSComponent vsComp, IGProp<?> trigger)
Sets the focus to the specified VS component, regardless if the VS component is virtualized or not.void
toast(KString message, IToaster.Position position, IToaster.Direction direction, IToaster.Type type, int duration)
Displays a simple, unobstructive and ephemeral text message to the user.java.lang.String
toString()
Formats the instance to a String.boolean
unlockUI()
Unlocks the UI.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.iizix.gyro.IAppSessionGyro
post
Methods inherited from interface com.iizix.text.ILocaleString
getLocaleKString
Methods inherited from interface com.iizix.gyro.IMessageBox
messageBox, messageBox
Methods inherited from interface com.iizix.api.IPrivateStorage
getPrivateData, getPrivateData, setPrivateData
Constructor Detail
AppSessionGyro
public AppSessionGyro(ServerShell server, SessionInfo appSessionInfo, java.lang.ThreadGroup appThreadGroup, UserSessions userSessions, ClientParams clientParams, AuthenticatedUser authUser) throws UserException
Constructs the instance of the application for the first user session. Subsequent parallel user sessions do not construct this instance.- Parameters:
server
- The Server.appSessionInfo
- The application session information.appThreadGroup
- The application thread group.userSessions
- The user sessions.clientParams
- The client parameters.authUser
- The authenticated user information.- Throws:
UserException
- If the user is not allowed access.
Method Detail
getSessionInstance
public static AppSessionGyro getSessionInstance()
Gets the AppSessionGyro instance for the current thread in an application session.- Returns:
- The AppSessionGyro instance when called from a thread of the client session,
null
otherwise.
getSessionInstance
public static AppSessionGyro getSessionInstance(SessionInfo sessionInfo)
Gets the AppSessionGyro instance for the current thread in a client session.- Parameters:
sessionInfo
- A session information instance, or null for none.- Returns:
- The AppSessionGyro instance when called from a thread of the application session,
null
otherwise.
addDisposeListener
public boolean addDisposeListener(IAppSessionDisposeListener listener)
Adds a dispose listener for the application session. Calling this method multiple times with the same listener will have no effect (but to return false).- Specified by:
addDisposeListener
in interfaceIAppSessionGyro
- Parameters:
listener
- The listener to add.- Returns:
- true if the listener was added, false otherwise.
- Throws:
java.lang.NullPointerException
- If the listener isnull
.
removeDisposeListener
public boolean removeDisposeListener(IAppSessionDisposeListener listener)
Removes a dispose listener for the application session.- Specified by:
removeDisposeListener
in interfaceIAppSessionGyro
- Parameters:
listener
- The listener to remove.- Returns:
- true if listener is successfully removed, false otherwise.
addClientConnectionListener
public boolean addClientConnectionListener(IClientSessionConnectionListener listener)
Adds a client connection listener for the application session. Calling this method multiple times with the same listener will have no effect (but to return false).- Specified by:
addClientConnectionListener
in interfaceIAppSessionGyro
- Parameters:
listener
- The listener to add.- Returns:
- true if the listener was added, false otherwise.
- Throws:
java.lang.NullPointerException
- If the listener isnull
.
removeClientConnectionListener
public boolean removeClientConnectionListener(IClientSessionConnectionListener listener)
Removes a client connection listener for the application session.- Specified by:
removeClientConnectionListener
in interfaceIAppSessionGyro
- Parameters:
listener
- The listener to remove.- Returns:
- true if listener is successfully removed, false otherwise.
dispose
public boolean dispose()
Disposes of the Application session gyro, and effectively closes all the client sessions and end point connections.- Specified by:
dispose
in interfaceIAppSessionGyro
- Returns:
- true for dispose success, false if already disposed of.
isDisposed
public boolean isDisposed()
Checks if the application session Gyro is disposed of.- Specified by:
isDisposed
in interfaceIAppSessionGyro
- Returns:
- true if the user's app-session is disposed of along with all client sessions, false otherwise.
getVirtuals
public <T extends PropCnr> VirtualsContainer<T> getVirtuals(IPluginDescriptor<T> serverPluginDescriptor)
Gets the instance of the VirtualsContainer for the plug-in. The instance is allocated if not yet created. This instance will be disposed of when the application session is disposed of.- Parameters:
serverPluginDescriptor
- The server plug-in descriptor.- Returns:
- The instance of the virtuals container, or null if appGyro is disposed of.
- Throws:
java.lang.NullPointerException
- If the plug-ins server ID is null fromIPluginDescriptor.getServerID()
.
getServer
public ServerShell getServer()
Gets the server of this session.
getAppSessionInfo
public SessionInfo getAppSessionInfo()
Gets the application session info.- Specified by:
getAppSessionInfo
in interfaceIAppSessionGyro
- Returns:
- The original session information that initiated the application session.
getAppThreadGroup
public java.lang.ThreadGroup getAppThreadGroup()
Gets the AppSessionGyro's Thread Group.- Specified by:
getAppThreadGroup
in interfaceIAppSessionGyro
- Returns:
- The Thread Group.
getEnvironment
public EnvProps getEnvironment()
Gets the original environment properties for Selector's or Value's.This is NOT the same instance as the one available from the
ClientSessionGyro.getEnvironment()
.- Specified by:
getEnvironment
in interfaceIAppSessionGyro
- Specified by:
getEnvironment
in interfaceIRuntimeReferenceLookup
- Returns:
- The original environment properties for selectors, null if never initialized.
getServerConfigurationEnvironment
public ServerConfigEnvProps getServerConfigurationEnvironment()
Gets the selected Server configuration environment for the Application Session.- Returns:
- The Server configuration environment to use for the sessions, null for none.
getFocusEngine
public IFocusEngine getFocusEngine(IFocusComp comp)
Returns the focus engine instance for the specified component.- Specified by:
getFocusEngine
in interfaceIAppSessionGyro
- Specified by:
getFocusEngine
in interfaceIFocusEngineProvider
- Parameters:
comp
- The component requesting the focus engine. For the AppSessionGyro, the focus engine returns an instance of the VirtualSpace focus engine if the component instance is a IVSComponent (VSTable, VSField, etc) or a VirtualSpace, for now.- Returns:
- The focus engine instance, or null if not found.
getCreationTime
public long getCreationTime()
Gets the creation time in milliseconds.- Specified by:
getCreationTime
in interfaceIAppSessionGyro
- Returns:
- Milliseconds since the epoch.
getAppID
public java.lang.String getAppID()
Gets the application ID.- Specified by:
getAppID
in interfaceIAppSessionGyro
- Returns:
- The AppID is an upper case string.
getAppFactory
public AppFactory getAppFactory()
Gets the application factory.- Specified by:
getAppFactory
in interfaceIRuntimeReferenceLookup
- Returns:
- The AppFactory.
getCustomAppValue
public java.lang.String getCustomAppValue(java.lang.String key)
Gets a value for a key in the custom app properties.- Specified by:
getCustomAppValue
in interfaceIAppSessionGyro
- Parameters:
key
- The key or name of the property to retrieve.- Returns:
- The value, or null if no value is defined for the key, or the custom map is not defined.
getTransactionCoordinator
public ITXPCoordinator getTransactionCoordinator()
Gets the transaction coordinator of the session.- Specified by:
getTransactionCoordinator
in interfaceIAppSessionGyro
- Returns:
- The TXP coordinator, or null for none.
getVirtualSpaceVirtualsContainer
public IVirtualsContainer<VirtualSpace> getVirtualSpaceVirtualsContainer()
The VirtualsContainer instance for VirtualSpace. This instance is shared for all parallel client sessions (if this is enabled or allowed).
getSessionUserIdentifier
public SessionUserIdentifier getSessionUserIdentifier()
Gets the SessionUserIdentifier.- Specified by:
getSessionUserIdentifier
in interfaceIAppSessionGyro
- Returns:
- The user identifier of the session.
getAuthenticatedUser
public AuthenticatedUser getAuthenticatedUser()
Gets the authenticated user information.
changeExternallyAuthenticatedUser
public LoginResult changeExternallyAuthenticatedUser(AuthenticatedUser authUser)
Changes the authenticated user due an external authentication mechanism such as LinkedIn.- Parameters:
authUser
- The new authenticated user.- Returns:
- The authentication result, perhaps error "user is disabled".
- Throws:
java.lang.NullPointerException
- If the client gyro or authUser parameter is null.
getAppPropCnr
public AppPropCnr getAppPropCnr()
Gets the application root for static references look-up.
getVirtualizedPropFromReference
public GProp<?> getVirtualizedPropFromReference(java.lang.String reference)
Attempts to look up a virtualized property from a reference to the VirtualSpace only.- Specified by:
getVirtualizedPropFromReference
in interfaceIVirtualizedReferenceLookup
- Parameters:
reference
- The reference to look-up.- Returns:
- The virtualized instance of the property, null if not found.
getRuntimePropFromReference
public GProp<?> getRuntimePropFromReference(java.lang.String reference)
Gets a reference for runtime use to get the reference of an item. The reference must be fully qualified such as "*ALIAS:/type/path" or "MODULE:/type/path" and cannot be relative.Note: The reference can be to the static or virtualized properties, but if a property type is virtualized and the property is not found, a fall-back to search the application for the static non-virtualized property IS NOT PERFORMED.
Calling this method is the same as calling
getRuntimePropFromReference(reference, false)}
.- Specified by:
getRuntimePropFromReference
in interfaceIAppSessionGyro
- Specified by:
getRuntimePropFromReference
in interfaceIRuntimeReferenceLookup
- Parameters:
reference
- The reference to look-up.- Returns:
- The property found, or null for reference not found.
getRuntimePropFromReference
public GProp<?> getRuntimePropFromReference(java.lang.String reference, boolean fallBackToNonVirtualized)
Gets a reference for runtime use to get the reference of an item. The reference must be fully qualified such as "*ALIAS:/type/path" or "MODULE:/type/path" and cannot be relative.If the flag
fallBackToNonVirtualized
is false, the search will not fallback to searching for the non-virtualized property in the runtime app. The result will only returned virtualized properties, i.e. for a reference as e.g. "module:/vs/someVS", and depending on where this method is called (the client session), also includes other virtualized properties such as panels as e.g. "module:/panel/somePanel".To always fallback to also searching the runtime app, specify
fallBackToNonVirtualized
to true.- Specified by:
getRuntimePropFromReference
in interfaceIAppSessionGyro
- Specified by:
getRuntimePropFromReference
in interfaceIRuntimeReferenceLookup
- Parameters:
reference
- The reference to look-up.fallBackToNonVirtualized
- Flag indicating a fallback to non-virtualized properties.- Returns:
- The property found, or null for reference not found.
getRootFromName
public PropCnr getRootFromName(GProp<?> requestor, java.lang.String module)
Gets the module root for a name. In the Editor, the module is the project, and that root container is returned. In the Server, the module doesn't matter, so the real root returns itself.When running with assertions, this call throws an assertion error by default, showing that the call is directed to a non-root property container.
- Specified by:
getRootFromName
in interfaceIAppSessionGyro
- Specified by:
getRootFromName
in interfaceIRuntimeReferenceLookup
- Parameters:
requestor
- The requestor property.module
- The module name (without colon), i.e. the project name in the Designer.- Returns:
- The root property container, or null if this container is not the root, or if the module name is not found. The default implementation returns null.
createClientSessionGyro
public ClientSessionGyro createClientSessionGyro(ClientEndPoint clientEndPoint, Worker worker, EnvProps envProps)
Called to create the ClientSessionGyro for the first client session or for parallel client sessions.- Parameters:
clientEndPoint
- The client end point.worker
- The worker.- Returns:
- The client session gyro
getClientSessionGyros
public ClientSessionGyro[] getClientSessionGyros()
Gets the active client session Gyro's for this application session Gyro.- Specified by:
getClientSessionGyros
in interfaceIAppSessionGyro
- Returns:
- The array of active client session Gyro's.
getClientSessionsCount
public int getClientSessionsCount()
Gets the count of client sessions.- Specified by:
getClientSessionsCount
in interfaceIAppSessionGyro
toString
public java.lang.String toString()
Formats the instance to a String.- Overrides:
toString
in classjava.lang.Object
initialize
public boolean initialize(EnvProps envProps, ClientSessionGyro clientGyro)
Initiates the application for the client session. This is done only once for the same user and will remain in that state, e.g. languages, etc.- Parameters:
envProps
- The client environment properties.clientGyro
- The client session gyro used to place an additional session according to the current VirtualSpace.- Returns:
- true for success, false if configuration is unsupported.
isVirtualized
public boolean isVirtualized(VirtualSpace virtualSpace)
Returns if a VirtualSpace already is virtualized for the application.- Specified by:
isVirtualized
in interfaceIAppSessionGyro
- Parameters:
virtualSpace
- The VirtualSpace.- Returns:
- true if
vs
already is virtualized or a virtualized instance is present, false otherwise.
getVirtualizedVirtualSpace
public VirtualSpace getVirtualizedVirtualSpace(VirtualSpace virtualSpace, boolean doVirtualize)
Gets the virtualized counterpart of a VirtualSpace. If the VirtualSpace is not virtualized, it will be done. If the VirtualSpace parameter already is a virtualized VirtualSpace, that instance is returned.This method is typically used by data connectors as action actors that have another target VirtualSpace. Focus can be set to a component in another VirtualSpace once virtualized.
- Specified by:
getVirtualizedVirtualSpace
in interfaceIAppSessionGyro
- Parameters:
virtualSpace
- The VirtualSpace.doVirtualize
- Flag to virtualize the VirtualSpace if not already virtualized or not.- Returns:
- A virtualized VirtualSpace for the virtualSpace parameter, or the virtualSpace parameter instance if it was virtualized.
getVirtualizedVSComponent
public IVSComponent getVirtualizedVSComponent(IVSComponent component)
Gets the virtualized VSComponent counterpart from a non-virtualized VSComponent. If the component's VirtualSpace is not virtualized, it will be done. If the component parameter already is virtualized, that instance is returned. This method can also process a VirtualSpace instance as it is implementing the IVSComponent interface.- Specified by:
getVirtualizedVSComponent
in interfaceIAppSessionGyro
- Parameters:
component
- A VS component.- Returns:
- A virtualized component for the component parameter, or the component parameter instance if it was virtualized.
null
is returned if the VirtualSpace is virtualized and the VSComponent counterpart doesn't exist or the class instance is not the same as the original component, or if thecomponent
parameter isnull
.
getVirtualizedVSComponent
public <VSC extends VSComponent> VSC getVirtualizedVSComponent(VSC component)
Gets the virtualized VSComponent counterpart from a non-virtualized VSComponent. If the component's VirtualSpace is not virtualized, it will be done. If the component parameter already is virtualized, that instance is returned.- Specified by:
getVirtualizedVSComponent
in interfaceIAppSessionGyro
- Parameters:
component
- A VS component.- Returns:
- A virtualized component for the component parameter, or the component parameter instance if it was virtualized.
null
is returned if the VirtualSpace is virtualized and the VSComponent counterpart doesn't exist or the class instance is not the same as the original component, or if thecomponent
parameter isnull
.
onFocusVetoChange
public void onFocusVetoChange(FocusEvent event) throws FocusVetoException
Called to perform veto.- Specified by:
onFocusVetoChange
in interfaceIGyroFocusEngineOwner
- Parameters:
event
- The focus event, InternalFocusEvent perhaps.- Throws:
FocusVetoException
- When the focus is veto'ed.
onFocusChanged
public void onFocusChanged(IFocusComp newComp, IFocusComp oldComp, IGProp<?> trigger, boolean isRemoteInduced, boolean isInternal)
Called when focus changes.- Specified by:
onFocusChanged
in interfaceIGyroFocusEngineOwner
- Parameters:
newComp
- New focus component.oldComp
- Old focus component.trigger
- The trigger property, null for none.isRemoteInduced
- If the event is remote induced.isInternal
- The internal flag as specified in thesetFocus
method to the focus engine.
getCurrentFocus
public IVSComponent getCurrentFocus()
Returns the current focus in the VirtualSpace. If no particular component is in focus, the VirtualSpace that last had focus is returned.- Specified by:
getCurrentFocus
in interfaceIAppSessionGyro
- Returns:
- The component in focus, or null if no focus is currently set.
setVirtualizeSupportFocus
public java.lang.String setVirtualizeSupportFocus(IVSComponent vsComp)
Sets the focus to the specified VS component, regardless if the VS component is virtualized or not. If not virtualized, it will be prior to setting the focus.- Specified by:
setVirtualizeSupportFocus
in interfaceIAppSessionGyro
- Parameters:
vsComp
- The VS component to focus.- Returns:
- Error message, or null for success.
setVirtualizeSupportFocus
public java.lang.String setVirtualizeSupportFocus(IVSComponent vsComp, IGProp<?> trigger)
Sets the focus to the specified VS component, regardless if the VS component is virtualized or not. If not virtualized, it will be prior to setting the focus.- Specified by:
setVirtualizeSupportFocus
in interfaceIAppSessionGyro
- Parameters:
vsComp
- The VS component to focus.trigger
- The trigger component, null for none.- Returns:
- Error message, or null for success.
getApplicationTimerEngine
public ITimerEngine getApplicationTimerEngine()
Gets the application timer engine. All timer tasks as disposed of automatically when the application session exits.- Specified by:
getApplicationTimerEngine
in interfaceIAppSessionGyro
- Returns:
- The application session implementation of the timeout engine.
getAppWorker
public Worker getAppWorker()
Gets the Worker for the Application.- Specified by:
getAppWorker
in interfaceIAppSessionGyro
- Returns:
- The Application Worker.
getPrivateStorageMap
public java.util.Map<java.lang.String,java.lang.Object> getPrivateStorageMap()
Gets the concurrent hash map used to store the private data.- Specified by:
getPrivateStorageMap
in interfaceIPrivateStorage
- Returns:
- The private storage map.
requestUILock
public ILockState requestUILock()
Requests a UI lock state. The object returned can be used to set a message below the lock spinner. It can also be used to set a progress indicator, also below the spinner. A progress indicator can also be handled using the lock object.Note: You MUST call the objects
{link @ILockState#release()}
method to release the lock state.- Specified by:
requestUILock
in interfaceIAppSessionGyro
- Returns:
- The lock state object.
isUILocked
public boolean isUILocked()
Get the current UI lock state.You may also query the incremental lock state using
.getLockCount()
- Specified by:
isUILocked
in interfaceIAppSessionGyro
- Returns:
- true if busy state is on, false otherwise.
lockUI
public boolean lockUI(KString waitMsg, ProgressIndicatorDelay delay)
Locks the UI with a message and a delay.Consider using the method
to handle UI locking along with optional message, wait delay and progress indicator.requestUILock()
This call will not change the potential wait message or wait message delay if the method is not successful.
Also consider using the method
in case multiple operations and threads can toggle the lock state.decrementUILock()
- Specified by:
lockUI
in interfaceIAppSessionGyro
- Parameters:
waitMsg
- The wait message, null for none.delay
- Delay before the message is shown in the Client.- Returns:
- Busy change flag, true if busy state changed, false otherwise. The return value may be false because the lock count is non-zero.
lockUI
public boolean lockUI(KString waitMsg, int delay)
Locks the UI with a message and a delay.Consider using the method
to handle UI locking along with optional message, wait delay and progress indicator.requestUILock()
This call will not change the potential wait message or wait message delay if the method is not successful.
Also consider using the method
in case multiple operations and threads can toggle the lock state.decrementUILock()
- Specified by:
lockUI
in interfaceIAppSessionGyro
- Parameters:
waitMsg
- The wait message, null for none.delay
- Delay of lock spinner: -2 for default (1.5 second), -1 disabled, 0=no delay, >0 wait time in milliseconds (1-20000, i.e. 20 seconds).- Returns:
- Busy change flag, true if busy state changed, false otherwise. The return value may be false because the lock count is non-zero.
- Throws:
java.lang.IllegalArgumentException
- If thedelay
value is not -1 to 20000 (20 seconds).
unlockUI
public boolean unlockUI()
Unlocks the UI.Consider using the method
to handle UI locking along with optional message, wait delay and progress indicator.requestUILock()
This call will not change the potential wait message or wait message delay if the method is not successful.
Also consider using the method
in case multiple operations and threads can toggle the lock state.decrementUILock()
- Specified by:
unlockUI
in interfaceIAppSessionGyro
- Returns:
- Busy change flag, true if busy state changed, false otherwise. The return value may be false because the lock count is non-zero.
getLockCount
public int getLockCount()
Returns the incremental lock count that governs the UI locking state. Note that the lock state may be in effect even if the lock count is zero.- Specified by:
getLockCount
in interfaceIAppSessionGyro
- Returns:
- The lock count, zero or positive value.
incrementUILock
public int incrementUILock()
Increases the incremental lock state. If it was zero, it will UI lock the session. Each call to this method must match a call to
.decrementUILock()
Consider using the method
to handle UI locking along with optional message, wait delay and progress indicator.requestUILock()
- Specified by:
incrementUILock
in interfaceIAppSessionGyro
- Returns:
- The lock count, i.e. the number of calls that has been made to this method minus the number of calls to
, after the call to this method.decrementUILock()
decrementUILock
public int decrementUILock()
Decreases the incremental lock state. If it becomes zero, it will UI unlock the session. Each call to this method must match a call to
.incrementUILock()
If this method is called and the lock count is zero, nothing will happen, but a warning event with a call stack will be logged.
- Specified by:
decrementUILock
in interfaceIAppSessionGyro
- Returns:
- The lock count, i.e. the number of calls that has been made to
minus the number of calls to this method.incrementUILock()
setLockMessage
public boolean setLockMessage(KString msg)
Sets the message to display for the lock state, above the indicator.- Specified by:
setLockMessage
in interfaceIAppSessionGyro
- Parameters:
msg
- The message to display, or null to remove it.- Returns:
- true for changed, or false if busy state is not present or no change of message.
setLockMessage
public boolean setLockMessage(KString msg, int progress)
Sets the message to display for the lock state, above the indicator, along with a progress value.- Specified by:
setLockMessage
in interfaceIAppSessionGyro
- Parameters:
msg
- The message to display, or null to remove it.progress
- The progress value between 0 and 100, or -1 to remove it.- Returns:
- true for changed, or false if busy state is not present or no change of values.
- Throws:
java.lang.IllegalArgumentException
- If the progress value is not -1 or 0 to 100.
setLockMessage
public boolean setLockMessage(KString msg, int delay, int progress)
Sets the message to display for the lock state, above the indicator, along with a progress value.- Specified by:
setLockMessage
in interfaceIAppSessionGyro
- Parameters:
msg
- The message to display, or null to remove it.delay
- Delay of lock spinner: -2 for default (1.5 second), -1 disabled, 0=no delay, >0 wait time in milliseconds (1-20000, i.e. 20 seconds).progress
- The progress value between 0 and 100, or -1 to remove it.- Returns:
- true for changed, or false if busy state is not present or no change of values.
- Throws:
java.lang.IllegalArgumentException
- If progress value is not -1 or 0 to 100, or delay is smaller than -2 or larger than 20000.
setLockProgress
public boolean setLockProgress(int progress)
Sets the current progress bar value. This method will not do anything if the lock state is not present.- Specified by:
setLockProgress
in interfaceIAppSessionGyro
- Parameters:
progress
- The progress value between 0 and 100, or -1 to remove it.- Returns:
- true for changes, false for no change or no lock state.
- Throws:
java.lang.IllegalArgumentException
- If the progress value is not -1 or 0 to 100.
getAppHistory
public IAppHistory getAppHistory()
Returns the application session history used for backward and forward navigation.- Specified by:
getAppHistory
in interfaceIAppSessionGyro
- Returns:
- The application session history instance.
getLanguageCode
public java.lang.String getLanguageCode()
Gets the language code of the application session. This language may very well not be the one requested by the end user device, but rather one of the languages the application supports.- Specified by:
getLanguageCode
in interfaceIAppSessionGyro
- Returns:
- The language code.
getAppKStringInfoProvider
public IKStringInfoProvider getAppKStringInfoProvider()
Retrieves the KStringInfoProvider for the application session.Note: it is recommended to use the
when available as it has more precise information available for the client session.IClientSessionGyro.getKStringInfoProvider()
- Specified by:
getAppKStringInfoProvider
in interfaceIAppSessionGyro
- Returns:
- The KString information provider instance, or null if not possible.
getKStringInfoProvider
public IKStringInfoProvider getKStringInfoProvider()
Retrieves the KStringInfoProvider for the application session.Note: it is recommended to use the
when available as it has more precise information available for the client session.IClientSessionGyro.getKStringInfoProvider()
- Specified by:
getKStringInfoProvider
in interfaceIAppSessionGyro
- Specified by:
getKStringInfoProvider
in interfaceILocaleString
- Returns:
- The KString information provider instance, or null if not possible. This method returns the same value as
getAppKStringInfoProvider()
.
getLocale
public LocaleInfo getLocale()
Gets the local info class instance.- Specified by:
getLocale
in interfaceILocaleString
- Returns:
- The locale info class instance when the client environment has been set, otherwise the default client locale info instance specified for the server.
getLocaleKString
public KString getLocaleKString(java.lang.String id, boolean system)
Gets the KString of a particular ID from the app's text tables that are flagged to also handle LocaleString's depending on the flag.- Specified by:
getLocaleKString
in interfaceILocaleString
- Parameters:
id
- The text ID.system
- Flagged to handle system strings for LocaleString's.- Returns:
- The KString for the text ID in current locale, null if not found.
getPrettyLocaledTexts
public PrettyLocaledTexts getPrettyLocaledTexts()
Gets the locale'd texts instance for the sessions language and text tables.- Specified by:
getPrettyLocaledTexts
in interfaceIAppSessionGyro
- Returns:
- The instance used to create locale'd strings for e.g. duration and distances.
getAppSessionFileProvider
public WSFileProvider getAppSessionFileProvider() throws java.io.IOException
Get the web server file provider for the application session.- Returns:
- The web server file provider.
- Throws:
java.io.IOException
- If the directory for the application session files failed to be created.java.lang.IllegalStateException
- If the application session is disposed of.
requestOAuthCallbackDisplay
public IOAuthCallbackProvider requestOAuthCallbackDisplay(IOAuthService service)
Requests the OAuth (1.0a or 2.0) authentication callback provider to show an URL to the user in order to be accepted.- Returns:
- The authentication callback.
closeAuthenticationWindows
public void closeAuthenticationWindows()
Closes the remote windows for authentication.
getImage
public RuntimeImageDefinition getImage(java.lang.String name)
Gets an image definition from the image container for the client session.- Specified by:
getImage
in interfaceIRuntimeImageCache
- Parameters:
name
- The image name.- Returns:
- The predefined image definition, or null if not found.
setImage
public boolean setImage(RuntimeImageDefinition image)
Adds the image definition to the image container for the client session. If the image already exists, it is replaced with the new definition.- Specified by:
setImage
in interfaceIRuntimeImageCache
- Parameters:
image
- The image definition.- Returns:
- true if the container was changed, i.e. image was added or replaced, false for no change.
removeImage
public boolean removeImage(java.lang.String name)
Removes an image with a name from the client session.- Specified by:
removeImage
in interfaceIRuntimeImageCache
- Parameters:
name
- The image to remove.- Returns:
- true for removed, false if not found.
clearImageCache
public void clearImageCache()
Clears the entire cache.- Specified by:
clearImageCache
in interfaceIRuntimeImageCache
messageBox
public void messageBox(IMessageBoxReply reply, IMessageBox.Icon icon, KString title, KString message, KString... buttons)
Displays a message box with the specified title and message.The callback is done in the application worker thread.
- Specified by:
messageBox
in interfaceIMessageBox
- Parameters:
reply
- The reply callback that is called when the user chooses a button or session is closed,null
for none.icon
- Icon to display, see the{link Icon}
enumeration.title
- The title string, must be non-null.message
- The message to display, must be non-null.buttons
- The strings for the buttons to display, if none, just anOK
button is displayed. This array of buttons defined the index value returned by this method.- Throws:
java.lang.NullPointerException
- Ificon
ormessage
is null, or if any of the elements inbuttons
array is null.java.lang.IllegalStateException
- If the application session is disposed of.
toast
public void toast(KString message, IToaster.Position position, IToaster.Direction direction, IToaster.Type type, int duration)
Displays a simple, unobstructive and ephemeral text message to the user.- Specified by:
toast
in interfaceIToaster
- Parameters:
message
- The message to display.position
- Position of toast, default value is Position.BOTTOM_CENTER if null.direction
- Direction of the toast animation, default Direction.UP if null.type
- Type of message style: message, warning, error of fatal, default is message if nullduration
- Duration of the toast message being shown in ms. Valid values are in the interval [0, 10000], 0 for a sticky toast.
getLocationService
public ILocationService getLocationService()
Returns the location service for the application session.- Specified by:
getLocationService
in interfaceIAppSessionGyro
- Returns:
- The "application singleton" instance of the location service.
getAuthenticatedUserUUID
public java.lang.String getAuthenticatedUserUUID()
Gets the user ID for background location service identification.- Specified by:
getAuthenticatedUserUUID
in interfaceIAppSessionGyro
- Returns:
- String made up of the authenticated user's UUID, null if the user is not yet authenticated or undefined.
getUserAuthenticationUI
public IUserAuthenticationUI getUserAuthenticationUI()
Gets the user authentication UI interface used for the initial login.- Specified by:
getUserAuthenticationUI
in interfaceIAppSessionGyro
- Returns:
- The user authentication interface.