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 TypeMethodDescriptionvoidaddContent(long fileId, AbstractContentGenerator content) voidaddMultiContent(long fileId, AbstractContentGenerator content) voidalert(LoginMessage message) voidvoidvoidDisplays an alert dialog with a specified caption, message, and icon.voidalertCountChanged(Object owner) This method is invoked whenever alter count changes for a particular owner.voidattached()Invoked whenever this application is attached to a UI.protected booleancanCreateMenu(Logic logic) protected booleancanCreateMenu(LogicGroup logicGroup) voidvoidclose()Close the application by closing all registered "resources".voidclose(int reason) Closes the application server connection with a specified reason.voidCloses the current session or process and redirects to the specified exit site.voidCloses the current session, releasing resources and optionally triggering client-side behaviors based on the provided parameters.voidcloseAllViews(boolean forShutdown) Close all current views by invokingView.abort()on each of them.voidCloses the application open.voidCloses the currently displayed wait message, if any.protected ApplicationEnvironmentAn "application environment" may be created to specify certain behaviours of the application.static ObjectcreateInstance(String propertyName, boolean showError, boolean raiseError) protected final ApplicationLayoutThis method is invoked only once to determine the layout of the application.protected Runnableprotected PostLoginvoiddetached()Invoked whenever this application is detached from its UI (it may get attached again to another UI if the user just refreshed the browser).voidFor internal use only.voiddownload(ContentProducer producer, Consumer<Long> informMe) voidvoidExit the application after showing a message.final voidforgotPassword(IdentityCheck identityCheck) final booleanforgotPassword(Login login) static Applicationget()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.ComponentRetrieves the alert button component.Retrieves the identifier of the biometric device associated with this instance.intThe reason for closing the application.Get ISO 2-character the country-code of the user in capital letters.static StringRetrieves the default country associated with the application.static CurrencyRetrieves the default currency used by the application.final Stringstatic MediaFileRetrieves the background image used for the home view.static StringgetLogicCaption(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 theLogininstance associated with application.final MessageViewerfinal StringgetName()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 FilterProvidergetUserVisibility(String action) voidinformation(StyledBuilder appDetails) protected voidinit(com.vaadin.flow.server.VaadinRequest request) This method is invoked byApplicationViewclass.protected booleanThis method is invoked when the application comes up.booleanChecks if biometric authentication is available on the device.booleanChecks if biometric authentication is registered on the device.booleanIs the application theme currently in compact mode?booleanDetermines whether the application menu is currently opened.voidloadStyles(String textContentName) voidLog something (goes to the System error stream).voidLog something along with an exception (goes to the System error stream).final booleanfinal voidlogin()Handles the login process for the application.voidlogout()voidopenMenu()Triggers the action to open the aplication menu.voidvoidRemove the alert and speaker buttons from the toolbar.voidsetAbortOnLogicSwitch(boolean abortOnLogicSwitch) voidsetCompactTheme(boolean compactMode) Set the application theme in compact mode.voidvoidsetDeviceLayout(DeviceLayout layout) voidsetRunningLogic(Logic logic) voidsetServer(ApplicationServer server) voidsetSingleLogicMode(boolean singleLogicMode) booleanWhether this application supportsCloseableViewor not.voidDisplays the details of an object with the given identifier.voidview(Id objectId, String actionName, Consumer<StoredObject> action) Performs a view operation for the given object ID and action name, executing the provided action.voidDisplays the specified media file.voidDisplays the given media file in the appropriate view mode.voidview(StoredObject object) Displays or processes a view for the specified stored object.voidview(StoredObject object, ObjectViewerButton<?>... actionButtons) Displays the specified stored object with optional action buttons.voidview(StoredObject object, String actionName, Consumer<StoredObject> action) Displays the given stored object and performs an action based on the provided action name.voidview(String caption, ContentProducer producer, Consumer<Long> timeTracker, boolean windowMode) Displays a view with the specified caption and content producer.voidview(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.voidDisplays the view for a specific object based on its ID with the provided caption.voidview(String caption, Id objectId, ObjectViewerButton<?>... actionButtons) Displays the view for the specified object with the given caption and action buttons.voidOpens a view for the specified object using the provided parameters.voidDisplays the media file with the given caption.voidDisplays the specified media file in the viewer with the given caption.voidview(String caption, StoredObject object) Displays the specified stored object with an optional caption.voidview(String caption, StoredObject object, ObjectViewerButton<?>... actionButtons) Displays the given stored object using the specified caption and action buttons.voidview(String caption, StoredObject object, String actionName, Consumer<StoredObject> action) Displays the given stored object using a specific viewer with an associated action.protected voidviewDetached(View view) This method is invoked whenever a runningViewis 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, warningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:ApplicationThis method is invoked byApplicationViewclass. If you want to override this method, make sure thatsuperis called.- Overrides:
initin classApplication- Parameters:
request- Vaadin Request
-
init
Description copied from class:ApplicationThis method is invoked when the application comes up.- Overrides:
initin 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:ApplicationGet 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:
getUIConfiguratorin 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 supportsCloseableViewor 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:ApplicationInvoked whenever this application is attached to a UI. Default implementation does nothing.- Overrides:
attachedin classApplication
-
loadStyles
-
createLayout
Description copied from class:ApplicationThis method is invoked only once to determine the layout of the application.- Specified by:
createLayoutin classApplication- Returns:
- Application layout.
-
getName
-
createEnvironment
Description copied from class:ApplicationAn "application environment" may be created to specify certain behaviours of the application. If this method returnsnull, a default "environment" will be created.- Overrides:
createEnvironmentin 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:ApplicationInvoked 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:
detachedin 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:ApplicationClose 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:
closein interfaceDevice- Overrides:
closein 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
Currencyof 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:ApplicationLog something (goes to the System error stream).- Specified by:
login interfaceDevice- Specified by:
login interfaceErrorLogger- Overrides:
login classApplication- Parameters:
anything- Message to log, it could be aThrowable
-
log
Description copied from class:ApplicationLog something along with an exception (goes to the System error stream).- Specified by:
login interfaceDevice- Specified by:
login interfaceErrorLogger- Overrides:
login classApplication- Parameters:
anything- Message to log, it could be aThrowableerror- Error to be printed
-
setRunningLogic
- Specified by:
setRunningLogicin interfaceRunningLogic
-
getRunningLogic
- Specified by:
getRunningLogicin 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:
parsein interfaceDevice- Throws:
SOException
-
getMessageViewer
- Specified by:
getMessageViewerin interfaceDevice
-
getDeviceType
- Specified by:
getDeviceTypein interfaceDevice
-
getDisplayVersion
-
getDriverIdentifier
- Specified by:
getDriverIdentifierin interfaceDevice
-
getDeviceLayout
- Specified by:
getDeviceLayoutin interfaceDevice
-
setDeviceLayout
- Specified by:
setDeviceLayoutin 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:
viewin 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:ApplicationThis method is invoked whenever alter count changes for a particular owner.- Overrides:
alertCountChangedin 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:
loginin classApplication
-
createLogin
-
createPostLogin
-
viewDetached
Description copied from class:ApplicationThis method is invoked whenever a runningViewis detached. (Sometimes, the application wants to take some action when a view is detached).- Overrides:
viewDetachedin classApplication- Parameters:
view- View that is detached now.
-
loggedIn
-
forgotPassword
- Specified by:
forgotPasswordin interfaceDevice
-
forgotPassword
-
getUserVisibility
-
getProgressBar
-
getBusyIndicator
-
information
-
canCreateMenu
-
canCreateMenu
-
getCountry
Description copied from class:ApplicationGet 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:
getCountryin classApplication- Returns:
- ISO country code. (Default is "US").
-
checkDayEnd
public void checkDayEnd() -
addContent
-
addMultiContent
-
getSMSSender
-
getMailSender
-
createInstance
-