Package com.storedobject.ui
Class Application
java.lang.Object
com.storedobject.vaadin.Application
com.storedobject.ui.Application
- All Implemented Interfaces:
Device
,ErrorLogger
,RequiresApproval
,RunningLogic
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionApplication
(ApplicationLayout applicationLayout) Application
(ApplicationLayout applicationLayout, boolean singleLogicMode) Application
(ApplicationLayout applicationLayout, boolean singleLogicMode, boolean abortOnLogicSwitch) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addContent
(long fileId, AbstractContentGenerator content) void
addMultiContent
(long fileId, AbstractContentGenerator content) void
alert
(LoginMessage message) void
void
void
Displays an alert dialog with a specified caption, message, and icon.void
alertCountChanged
(Object owner) This method is invoked whenever alter count changes for a particular owner.void
attached()
Invoked whenever this application is attached to a UI.protected boolean
canCreateMenu
(Logic logic) protected boolean
canCreateMenu
(LogicGroup logicGroup) void
void
close()
Close the application by closing all registered "resources".void
close
(int reason) Closes the application server connection with a specified reason.void
Closes the current session or process and redirects to the specified exit site.void
Closes the current session, releasing resources and optionally triggering client-side behaviors based on the provided parameters.void
closeAllViews
(boolean forShutdown) Close all current views by invokingView.abort()
on each of them.void
Closes the application open.void
Closes the currently displayed wait message, if any.protected ApplicationEnvironment
An "application environment" may be created to specify certain behaviours of the application.static Object
createInstance
(String propertyName, boolean showError, boolean raiseError) protected final ApplicationLayout
This method is invoked only once to determine the layout of the application.protected Runnable
protected PostLogin
void
detached()
Invoked whenever this application is detached from its UI (it may get attached again to another UI if the user just refreshed the browser).void
For internal use only.void
download
(ContentProducer producer, Consumer<Long> informMe) void
void
Exit the application after showing a message.final void
forgotPassword
(IdentityCheck identityCheck) final boolean
forgotPassword
(Login login) static Application
get()
Retrieves the current instance of the Application.getAlert()
Retrieves a StyledBuilder object that represents an alert.Retrieves a StyledBuilder object that represents an alert, using the provided reference.Retrieves a StyledBuilder instance configured for a specific alert.Retrieves a configured alert using the provided alert handler and reference ID.com.vaadin.flow.component.Component
Retrieves the alert button component.Retrieves the identifier of the biometric device associated with this instance.int
The reason for closing the application.Get ISO 2-character the country-code of the user in capital letters.static String
Retrieves the default country associated with the application.static Currency
Retrieves the default currency used by the application.final String
static MediaFile
Retrieves the background image used for the home view.static String
getLogicCaption
(String defaultCaption) Get the caption of the currently running logic from the currentApplication
.getLogicTitle
(String defaultTitle) Get the title of the currently running logic.getLogin()
This returns theLogin
instance associated with application.final MessageViewer
final String
getName()
getProgressBar
(boolean indeterminate) Retrieves the TransactionManager associated with the server.protected Consumer
<com.vaadin.flow.component.UI> Get UI configurator if any so that UI will be passed to it for handling any special configuration.static FilterProvider
getUserVisibility
(String action) void
information
(StyledBuilder appDetails) protected void
init
(com.vaadin.flow.server.VaadinRequest request) This method is invoked byApplicationView
class.protected boolean
This method is invoked when the application comes up.boolean
Checks if biometric authentication is available on the device.boolean
Checks if biometric authentication is registered on the device.boolean
Is the application theme currently in compact mode?boolean
Determines whether the application menu is currently opened.void
loadStyles
(String textContentName) void
Log something (goes to the System error stream).void
Log something along with an exception (goes to the System error stream).final boolean
final void
login()
Handles the login process for the application.void
logout()
void
openMenu()
Triggers the action to open the aplication menu.void
void
Remove the alert and speaker buttons from the toolbar.void
setAbortOnLogicSwitch
(boolean abortOnLogicSwitch) void
setCompactTheme
(boolean compactMode) Set the application theme in compact mode.void
void
setDeviceLayout
(DeviceLayout layout) void
setRunningLogic
(Logic logic) void
setServer
(ApplicationServer server) void
setSingleLogicMode
(boolean singleLogicMode) boolean
Whether this application supportsCloseableView
or not.void
Displays the details of an object with the given identifier.void
view
(Id objectId, String actionName, Consumer<StoredObject> action) Performs a view operation for the given object ID and action name, executing the provided action.void
Displays the specified media file.void
Displays the given media file in the appropriate view mode.void
view
(StoredObject object) Displays or processes a view for the specified stored object.void
view
(StoredObject object, ObjectViewerButton<?>... actionButtons) Displays the specified stored object with optional action buttons.void
view
(StoredObject object, String actionName, Consumer<StoredObject> action) Displays the given stored object and performs an action based on the provided action name.void
view
(String caption, ContentProducer producer, Consumer<Long> timeTracker, boolean windowMode) Displays a view with the specified caption and content producer.void
view
(String caption, ContentProducer producer, Consumer<Long> timeTracker, boolean windowMode, com.vaadin.flow.component.Component... extraHeaderButtons) Displays content produced by the given ContentProducer in a specific view.void
Displays the view for a specific object based on its ID with the provided caption.void
view
(String caption, Id objectId, ObjectViewerButton<?>... actionButtons) Displays the view for the specified object with the given caption and action buttons.void
Opens a view for the specified object using the provided parameters.void
Displays the media file with the given caption.void
Displays the specified media file in the viewer with the given caption.void
view
(String caption, StoredObject object) Displays the specified stored object with an optional caption.void
view
(String caption, StoredObject object, ObjectViewerButton<?>... actionButtons) Displays the given stored object using the specified caption and action buttons.void
view
(String caption, StoredObject object, String actionName, Consumer<StoredObject> action) Displays the given stored object using a specific viewer with an associated action.protected void
viewDetached
(View view) This method is invoked whenever a runningView
is detached.Methods inherited from class com.storedobject.vaadin.Application
access, addBrowserResizedListener, addContentResizedListener, clearAlert, clearAlerts, clearAlerts, createMenuItem, createMenuItem, createMenuItemGroup, error, error, execute, execute, get, getActiveView, getActiveViewCount, getActiveViews, getAlertCount, getAlerts, getCaption, getCommonAlert, getContentHeight, getContentWidth, getData, getDeviceHeight, getDeviceWidth, getEnvironment, getIdentifier, getIPAddress, getLinkName, getLocale, getMajorVersion, getMinorVersion, getPage, getQueryParameter, getUI, getURL, getViewFor, getWebBrowser, isFullScreenMode, isSpeakerOn, isSpeaking, loggedin, message, message, registerAlert, registerResource, removeData, removeData, removeQueryParameter, removeQueryParameters, setCaption, setData, setData, setLocale, setPollInterval, setPollInterval, setPostFocus, showAlerts, showAlerts, showNotification, showNotification, showNotification, showNotification, speak, startPolling, stopPolling, tray, tray, warning, warning
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.storedobject.core.Device
download, download, download, getDateFormat, getDefaultEntity, getDeviceHeight, getDeviceWidth, getIdentifier, getIPAddress, getLocale, getMajorVersion, getMinorVersion, setLocale, showNotification, showNotification, showNotification, showNotification, view, view, view, view, view, view, view, view, view, view, view, view, view, view, view
-
Field Details
-
COLOR_ERROR
- See Also:
-
COLOR_SUCCESS
- See Also:
-
COLOR_INFO
- See Also:
-
COLOR_NORMAL
- See Also:
-
-
Constructor Details
-
Application
public Application() -
Application
-
Application
-
Application
public Application(ApplicationLayout applicationLayout, boolean singleLogicMode, boolean abortOnLogicSwitch)
-
-
Method Details
-
init
protected void init(com.vaadin.flow.server.VaadinRequest request) Description copied from class:Application
This method is invoked byApplicationView
class. If you want to override this method, make sure thatsuper
is called.- Overrides:
init
in classApplication
- Parameters:
request
- Vaadin Request
-
init
Description copied from class:Application
This method is invoked when the application comes up.- Overrides:
init
in classApplication
- Parameters:
link
- The context path of the application.- Returns:
- True if application can go ahead. Otherwise, an "Initialization failed" message is displayed.
Default return value is
true
.
-
getUIConfigurator
Description copied from class:Application
Get UI configurator if any so that UI will be passed to it for handling any special configuration. This will be invoked beforeApplication.setUI(UI)
is called.- Overrides:
getUIConfigurator
in classApplication
- Returns:
- Default implementation returns
null
.
-
getLogin
-
setCompactTheme
public void setCompactTheme(boolean compactMode) Set the application theme in compact mode.- Parameters:
compactMode
- Whether to show compact mode or not.
-
isCompactTheme
public boolean isCompactTheme()Is the application theme currently in compact mode?- Returns:
- True/false.
-
supportsCloseableView
public boolean supportsCloseableView()Whether this application supportsCloseableView
or not. Applications may override the standard menu system, and the overridden menu system may not have support for displaying the appropriate "close" icon for closing the view. In such cases, this method should returnfalse
.- Returns:
- True/false. Default is true.
-
attached
public void attached()Description copied from class:Application
Invoked whenever this application is attached to a UI. Default implementation does nothing.- Overrides:
attached
in classApplication
-
loadStyles
-
createLayout
Description copied from class:Application
This method is invoked only once to determine the layout of the application.- Specified by:
createLayout
in classApplication
- Returns:
- Application layout.
-
getName
-
createEnvironment
Description copied from class:Application
An "application environment" may be created to specify certain behaviours of the application. If this method returnsnull
, a default "environment" will be created.- Overrides:
createEnvironment
in classApplication
- Returns:
- Returns null by default.
-
setSingleLogicMode
public void setSingleLogicMode(boolean singleLogicMode) -
setAbortOnLogicSwitch
public void setAbortOnLogicSwitch(boolean abortOnLogicSwitch) -
execute
-
logout
public void logout() -
detached
public void detached()Description copied from class:Application
Invoked whenever this application is detached from its UI (it may get attached again to another UI if the user just refreshed the browser). The default implementation closes the application (Application.close()
) after 20 seconds.- Overrides:
detached
in classApplication
-
getCloseReason
public int getCloseReason()The reason for closing the application. A negative number is returned if a redirection had happened while closing.0: Not closed 1, -1: Logged out by the user. 2, -2: Closed after showing a message. 3, -3: Application server session expired. 4, -4: Login failed and closed. 5, -5: Canceled from the login screen. 6, -6: Canceled while selecting the entity. 7, -7: Timed out during interactive session dialog. 8, -8: Closed by the user in the interactive session dialog. 9, -9: Closed while switching to another server/DB. 10, -10: MFA not verified. 100, -100: Programmatic close from unknown code. 101, -101: Programmatic redirection for authentication.
- Returns:
- Reason code.
-
close
public void close()Description copied from class:Application
Close the application by closing all registered "resources". If the associated session is not closed and no other Application instance exists, it will also be closed.- Specified by:
close
in interfaceDevice
- Overrides:
close
in classApplication
-
close
-
close
public void close(int reason) Closes the application server connection with a specified reason. Handles the logic for determining the exit site from global properties or layout configuration before initiating closure.- Parameters:
reason
- the integer code representing the reason for closing the connection
-
close
Closes the current session, releasing resources and optionally triggering client-side behaviors based on the provided parameters. This method ensures proper cleanup and performs actions such as closing views, removing layout components, and optionally navigating to an external site.- Parameters:
exitSite
- The URL to navigate to when the session is closed. If null or empty, a default close behavior is executed.reason
- The integer code representing the reason for the closure. This value influences internal handling of the close operation.
-
exit
-
closeAllViews
public void closeAllViews(boolean forShutdown) Close all current views by invokingView.abort()
on each of them.- Parameters:
forShutdown
- True should be passed if this is for a shutdown so that all internal timers will be removed.
-
get
Retrieves the current instance of the Application.- Returns:
- The current Application instance.
-
getDefaultCurrency
Retrieves the default currency used by the application.- Returns:
- the default
Currency
of the application - Throws:
SORuntimeException
- if the default currency cannot be determined
-
getDefaultCountry
Retrieves the default country associated with the application. If an application instance is available, this method fetches and returns the country set in the application's transaction manager. If no application instance is available, an exception is thrown.- Returns:
- the default country as a string if available
- Throws:
SORuntimeException
- if the default country cannot be determined
-
isBiometricAvailable
public boolean isBiometricAvailable()Checks if biometric authentication is available on the device.- Returns:
- true if biometric authentication is available, false otherwise.
-
isBiometricRegistered
public boolean isBiometricRegistered()Checks if biometric authentication is registered on the device.- Returns:
- true if biometric authentication is registered, false otherwise.
-
getBiometricDeviceId
Retrieves the identifier of the biometric device associated with this instance.- Returns:
- the unique identifier of the biometric device
-
disableBiometric
public void disableBiometric()For internal use only. -
getTransactionManager
Retrieves the TransactionManager associated with the server.- Returns:
- the TransactionManager if the server is not null; otherwise, null.
-
log
Description copied from class:Application
Log something (goes to the System error stream).- Specified by:
log
in interfaceDevice
- Specified by:
log
in interfaceErrorLogger
- Overrides:
log
in classApplication
- Parameters:
anything
- Message to log, it could be aThrowable
-
log
Description copied from class:Application
Log something along with an exception (goes to the System error stream).- Specified by:
log
in interfaceDevice
- Specified by:
log
in interfaceErrorLogger
- Overrides:
log
in classApplication
- Parameters:
anything
- Message to log, it could be aThrowable
error
- Error to be printed
-
setRunningLogic
- Specified by:
setRunningLogic
in interfaceRunningLogic
-
getRunningLogic
- Specified by:
getRunningLogic
in interfaceRunningLogic
-
getLogicTitle
Get the title of the currently running logic. Note: A call to this method will reset it, and you cannot call it again to get it!- Parameters:
defaultTitle
- Default title to be returned if there is no current logic.- Returns:
- Title of the logic or default title.
-
getLogicCaption
Get the caption of the currently running logic from the currentApplication
. Note: A call to this method will reset it, and you cannot call it again to get it!- Parameters:
defaultCaption
- Default caption to be returned if there is no current logic or application instance in the current context.- Returns:
- Title of the logic or default caption.
-
setServer
-
getServer
-
setDate
-
parse
- Specified by:
parse
in interfaceDevice
- Throws:
SOException
-
getMessageViewer
- Specified by:
getMessageViewer
in interfaceDevice
-
getDeviceType
- Specified by:
getDeviceType
in interfaceDevice
-
getDisplayVersion
-
getDriverIdentifier
- Specified by:
getDriverIdentifier
in interfaceDevice
-
getDeviceLayout
- Specified by:
getDeviceLayout
in interfaceDevice
-
setDeviceLayout
- Specified by:
setDeviceLayout
in interfaceDevice
-
view
Displays the specified media file. By default, the media file is not set to fullscreen mode.- Parameters:
mediaFile
- the media file to be displayed
-
view
-
view
Displays the given media file in the appropriate view mode.- Parameters:
mediaFile
- the media file to be viewedwindowMode
- indicates whether the media should be displayed in windowed mode
-
view
Displays the specified media file in the viewer with the given caption.- Parameters:
caption
- The title or description to be displayed alongside the media file.mediaFile
- The media file that needs to be displayed.windowMode
- Determines whether the viewer should open in windowed mode (true for windowed mode, false for fullscreen mode).
-
view
-
view
Displays the details of an object with the given identifier.- Parameters:
objectId
- the identifier of the object to be viewed
-
view
Displays or processes a view for the specified stored object. If the view logic requires additional parameters, it defaults the first parameter to null.- Parameters:
object
- the stored object to be viewed or processed
-
view
Displays the specified stored object with an optional caption.- Parameters:
caption
- the caption to be displayed along with the stored objectobject
- the stored object to be viewed
-
view
Opens a view for the specified object using the provided parameters.- Parameters:
caption
- the caption or title to be displayed in the viewobjectId
- the identifier of the object to be viewedactionName
- the name of the action to be performed in the viewaction
- a callback that provides a consumer for the stored object
-
view
Displays the view for the specified object with the given caption and action buttons.- Parameters:
caption
- The caption to be displayed for the view.objectId
- The ID of the object to be viewed.actionButtons
- Optional action buttons to be displayed with the view.
-
view
Performs a view operation for the given object ID and action name, executing the provided action.- Parameters:
objectId
- the unique identifier of the object to be viewedactionName
- the name of the action to be performedaction
- a Consumer functional interface to execute the specific operation on the object
-
view
Displays the given stored object and performs an action based on the provided action name.- Parameters:
object
- the stored object to be viewedactionName
- the name of the action to be executedaction
- a consumer that defines the behavior to execute on the stored object
-
view
Displays the specified stored object with optional action buttons.- Parameters:
object
- the stored object to be viewedactionButtons
- an optional array of action buttons to be included in the view
-
view
public void view(String caption, StoredObject object, String actionName, Consumer<StoredObject> action) Displays the given stored object using a specific viewer with an associated action.- Parameters:
caption
- the caption or title to be used for the viewobject
- the stored object to be viewedactionName
- the name of the action that can be performed on the objectaction
- the action to be executed on the stored object
-
view
Displays the given stored object using the specified caption and action buttons.- Parameters:
caption
- the caption or title to display for the viewobject
- the stored object that needs to be viewedactionButtons
- optional action buttons to display along with the view
-
view
public void view(String caption, ContentProducer producer, Consumer<Long> timeTracker, boolean windowMode) Displays a view with the specified caption and content producer. Tracks the render time and allows for an optional windowed mode.- Specified by:
view
in interfaceDevice
- Parameters:
caption
- the title or label of the view to be displayedproducer
- the content producer responsible for generating the view's contenttimeTracker
- a consumer to track and handle the rendering time in millisecondswindowMode
- a boolean flag indicating whether the view should be displayed in windowed mode
-
view
public void view(String caption, ContentProducer producer, Consumer<Long> timeTracker, boolean windowMode, com.vaadin.flow.component.Component... extraHeaderButtons) Displays content produced by the given ContentProducer in a specific view. Manages the display lifecycle, including the addition of header buttons and tracking view time. Supports windowed mode and asynchronous content generation.- Parameters:
caption
- The title or caption to be displayed for the view.producer
- The ContentProducer responsible for generating content to be displayed.timeTracker
- A Consumer that accepts a Long value representing the time spent in the view.windowMode
- A boolean indicating whether the view should be displayed in window mode.extraHeaderButtons
- Optional additional header buttons to be displayed in the view.
-
closeWaitMessage
public void closeWaitMessage()Closes the currently displayed wait message, if any. This method invokes the close operation on the instance of the waitMessage. -
download
-
removeToolbarButtons
public void removeToolbarButtons()Remove the alert and speaker buttons from the toolbar. -
getAlertButton
public com.vaadin.flow.component.Component getAlertButton()Retrieves the alert button component.- Returns:
- the Component representing the alert button
-
alert
-
alert
-
alert
-
alert
Displays an alert dialog with a specified caption, message, and icon.- Parameters:
caption
- the title text to be displayed on the alert dialogalert
- the message content to be displayed in the alert dialogicon
- the identifier for the icon to be shown in the alert dialog
-
getAlert
Retrieves a StyledBuilder object that represents an alert. Optionally, parameters can be provided to specify the type or content of the alert.- Returns:
- a StyledBuilder instance representing the alert.
-
getAlert
Retrieves a StyledBuilder instance configured for a specific alert.- Parameters:
alertHandler
- the handler object used to identify or process the alert- Returns:
- a StyledBuilder instance for the specified alert
-
getAlert
Retrieves a configured alert using the provided alert handler and reference ID.- Parameters:
alertHandler
- the object responsible for handling alert configurationsreference
- the unique identifier associated with the alert- Returns:
- a StyledBuilder instance representing the constructed alert
-
getAlert
Retrieves a StyledBuilder object that represents an alert, using the provided reference.- Parameters:
reference
- the identifier used to locate or configure the alert- Returns:
- a StyledBuilder object associated with the specified reference
-
alertCountChanged
Description copied from class:Application
This method is invoked whenever alter count changes for a particular owner.- Overrides:
alertCountChanged
in classApplication
- Parameters:
owner
- Alert owner
-
openMenu
public void openMenu()Triggers the action to open the aplication menu. -
closeMenu
public void closeMenu()Closes the application open. -
isMenuOpened
public boolean isMenuOpened()Determines whether the application menu is currently opened.- Returns:
- true if the menu is opened, false otherwise
-
getHomeImage
Retrieves the background image used for the home view.- Returns:
- a MediaFile representing the background image for the home view
-
login
public final void login()Handles the login process for the application. The method performs the following main tasks: 1. Retrieves the application name and sets the screen caption with the application's name and display version unless the application name is unavailable or invalid. 2. Loads and executes the home view for the application if an appropriate HTML content or home background image is available. Otherwise, it proceeds with alternate views. 3. Displays a notice image if available, invoking the `view` method. 4. Initializes the login form, either by calling a custom login form or falling back to a predefined screen-based login method. This method ensures proper handling of missing resources or errors during execution by catching and safely ignoring exceptions. It is an entry point for managing the application's user authentication interface and sets up the required resources for a fresh login session.- Overrides:
login
in classApplication
-
createLogin
-
createPostLogin
-
viewDetached
Description copied from class:Application
This method is invoked whenever a runningView
is detached. (Sometimes, the application wants to take some action when a view is detached).- Overrides:
viewDetached
in classApplication
- Parameters:
view
- View that is detached now.
-
loggedIn
-
forgotPassword
- Specified by:
forgotPassword
in interfaceDevice
-
forgotPassword
-
getUserVisibility
-
getProgressBar
-
getBusyIndicator
-
information
-
canCreateMenu
-
canCreateMenu
-
getCountry
Description copied from class:Application
Get ISO 2-character the country-code of the user in capital letters. (Examples: "US" for US, "IN" for India). This information is used for formatting the numbers inNumericField
.- Overrides:
getCountry
in classApplication
- Returns:
- ISO country code. (Default is "US").
-
checkDayEnd
public void checkDayEnd() -
addContent
-
addMultiContent
-
getSMSSender
-
getMailSender
-
createInstance
-