Class DesktopApplication<C extends FxController>
- Type Parameters:
C- the main controller type
- All Implemented Interfaces:
Application, DomainContextProvider, ClassMappedListener, SessionProvider
- Direct Known Subclasses:
UpdatableDesktopApplication
- Author:
- harald
-
Field Summary
Fields inherited from class AbstractApplication
DISABLE_MODIFICATION_TRACKER, DISABLE_SECURITY_MANAGER, ENABLE_STATISTICS, LOCALE, SCRIPTING -
Constructor Summary
ConstructorsConstructorDescriptionDesktopApplication(String name, String version) Creates an FX desktop application. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyProperties(Properties properties) Applies the given properties.
If the given properties are different from the application properties, they will be copied to the application properties.voidclassMapped(String name, Class<?> clazz) A class was mapped the first time.protected voidcleanup()Cleans up resources.
Invoked fromAbstractApplication.stop(int, java.lang.Throwable)voidconfigureMainStage(javafx.stage.Stage mainStage) Configures and sets the main stage.protected voidConfigures the modification tracker singleton.protected voidConfigures the preferences.protected voidConfigures the security manager.createDomainContext(Session session) Creates the domain context.
Override this method if the application uses a subclass of DomainContext.createLoginFailedHandler(javafx.scene.Parent view, SessionInfo sessionInfo) Creates the login failed handler.createSessionInfo(String username, char[] password, String sessionPropertiesBaseName) Creates the sessionInfo.
Presets the attributes like locale, timezone, vm-, os- and host-info.protected voidFinishes the startup.
The default implementation starts the modification tracker, unless the property "notracker" is given.
The property "statistics" activates the statistics.Class<? extends FxApplication> Gets the FX application class.Gets the FX application instance.
This is the instance of the class provided bygetApplicationClass().
The FX-application usually provides a login-view and is responsible to spawn the main view after successful login.Gets the main controller.Gets the main-controller to be displayed initially.
Maintains the main-scene of the application.javafx.stage.StageGets the main stage.Gets the configured dark mode and theme preferences.
It can be configured via command line or user preferences.Gets the exception handler.protected voidInitializes the scripting.booleanReturns the autologin flag.booleanReturns whether the running application is interactive.voidlogin(javafx.scene.Parent view, SessionInfo sessionInfo) Performs the login and final startup of the application.protected voidRegisters a listener to update the dark mode of all windows if configuration is automatic.voidRegisters a handler for uncaught exceptions.voidsetFxApplication(FxApplication fxApplication) Sets the FX application instance.voidsetMainController(C mainController) Sets the main controller instance.voidshowApplicationStatus(String msg, double progress) Displays a message during login.
Makes sure that the message is shown at least 100ms.voidshowApplicationStatus(String msg, double progress, long minMillis) Displays a message during login.protected voidstartup()Invokes all steps to start up the application.
Invoked fromAbstractApplication.start(java.lang.String[]).Methods inherited from class AbstractClientApplication
updateSessionInfoAfterLoginMethods inherited from class AbstractApplication
activateStatistics, configure, createSession, filterName, filterVersion, getCommandLine, getCreationTime, getDomainContext, getName, getProperties, getProperty, getPropertyAsChars, getPropertyAsCharsIgnoreCase, getPropertyIgnoreCase, getSession, getSessionInfo, getVersion, initialize, isServer, isSystemExitNecessaryToStop, logStackdump, logStatistics, setDomainContext, setProperties, setSessionInfo, start, stop, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Application
getUser, register, start, stop, unregisterMethods inherited from interface DomainContextProvider
isWithinContext, isWithinContext, on, on, op, op
-
Constructor Details
-
DesktopApplication
-
-
Method Details
-
isInteractive
public boolean isInteractive()Description copied from class:AbstractApplicationReturns whether the running application is interactive.- Specified by:
isInteractivein interfaceApplication- Overrides:
isInteractivein classAbstractApplication- Returns:
- true if interaction with user, false if server, daemon or whatever
-
getMainControllerClass
-
configureMainStage
public void configureMainStage(javafx.stage.Stage mainStage) Configures and sets the main stage.If overridden, make sure to invoke super.configureMainStage!
- Parameters:
mainStage- the main stage
-
getMainStage
public javafx.stage.Stage getMainStage()Gets the main stage.- Returns:
- the stage
-
setMainController
Sets the main controller instance.- Parameters:
mainController- the main controller
-
getMainController
-
isAutoLogin
public boolean isAutoLogin()Returns the autologin flag.- Returns:
- true if the user is logged w/o being asked for username/password, default is false
- See Also:
-
createLoginFailedHandler
public LoginFailedHandler createLoginFailedHandler(javafx.scene.Parent view, SessionInfo sessionInfo) Creates the login failed handler.- Parameters:
view- the viewsessionInfo- the session info- Returns:
- the handler
-
createSessionInfo
public SessionInfo createSessionInfo(String username, char[] password, String sessionPropertiesBaseName) Description copied from class:AbstractApplicationCreates the sessionInfo.
Presets the attributes like locale, timezone, vm-, os- and host-info.- Overrides:
createSessionInfoin classAbstractApplication- Parameters:
username- is the name of the userpassword- is the password, null if nonesessionPropertiesBaseName- the resource bundle basename of the property file, null if default- Returns:
- the sessionInfo
-
login
Performs the login and final startup of the application.The method must hide the view when the main application window is displayed after successful login.
Notice that this method is invoked from within the FX thread.
- Parameters:
view- the view to hide if login succeeded and the application window is visiblesessionInfo- the session info
-
getFxApplication
Gets the FX application instance.
This is the instance of the class provided bygetApplicationClass().
The FX-application usually provides a login-view and is responsible to spawn the main view after successful login.- Returns:
- the FX application
-
setFxApplication
Sets the FX application instance.- Parameters:
fxApplication- the FX application
-
getApplicationClass
Gets the FX application class.- Returns:
- the fx application class
-
showApplicationStatus
Displays a message during login.- Parameters:
msg- the status messageprogress- the progress, 0 to disable, negative if infinite, 1.0 if doneminMillis- minimum milliseconds the previous message must have been visible
-
showApplicationStatus
Displays a message during login.
Makes sure that the message is shown at least 100ms.- Parameters:
msg- the status messageprogress- the progress, 0 to disable, negative if infinite, 1.0 if done
-
registerUncaughtExceptionHandler
public void registerUncaughtExceptionHandler()Registers a handler for uncaught exceptions. -
getUncaughtExceptionHandler
Gets the exception handler.- Returns:
- the handler
-
createDomainContext
Creates the domain context.
Override this method if the application uses a subclass of DomainContext.Overridden to create a DomainContext with a thread-local session.
In desktop client apps there are 2 threads using their own session:
- the FX thread
- the ModificationTracker thread
- Overrides:
createDomainContextin classAbstractApplication- Parameters:
session- the session, null if thread-local- Returns:
- the domain context
-
applyProperties
Description copied from class:AbstractApplicationApplies the given properties.
If the given properties are different from the application properties, they will be copied to the application properties.The default implementation first parses the properties for system properties and replaces any system properties according to
StringHelper.evaluate(String, Function).
System properties start withSYSTEM_or^followed by the property name.Other well-known properties that can be set:
scripting=...sets the default scripting languagenosecuritydisables the tentackle security managerlocale=...sets the default locale.- Specified by:
applyPropertiesin interfaceApplication- Overrides:
applyPropertiesin classAbstractApplication- Parameters:
properties- the properties, null if none
-
getThemePreferences
Gets the configured dark mode and theme preferences.
It can be configured via command line or user preferences. If such configuration is missing, the mode is considered to be determined automatically according to the desktop settings.- Returns:
- null if automatic, TRUE if fixed dark mode, FALSE if fixed light mode
-
startup
protected void startup()Description copied from class:AbstractApplicationInvokes all steps to start up the application.
Invoked fromAbstractApplication.start(java.lang.String[]).- Specified by:
startupin classAbstractApplication
-
configurePreferences
protected void configurePreferences()Description copied from class:AbstractApplicationConfigures the preferences.If the property
"readonlyprefs"is set, any write attempt to the preferences will be silently ignored.
The property"noprefsync"turns off preferences auto sync between jvms.
The property"systemprefs"restricts to system preferences. Default is user and system prefs.- Overrides:
configurePreferencesin classAbstractApplication
-
configureSecurityManager
protected void configureSecurityManager()Description copied from class:AbstractApplicationConfigures the security manager.- Overrides:
configureSecurityManagerin classAbstractApplication
-
configureModificationTracker
protected void configureModificationTracker()Description copied from class:AbstractApplicationConfigures the modification tracker singleton.- Overrides:
configureModificationTrackerin classAbstractApplication
-
finishStartup
protected void finishStartup()Description copied from class:AbstractApplicationFinishes the startup.
The default implementation starts the modification tracker, unless the property "notracker" is given.
The property "statistics" activates the statistics.- Overrides:
finishStartupin classAbstractApplication
-
registerColorSchemeListener
protected void registerColorSchemeListener()Registers a listener to update the dark mode of all windows if configuration is automatic. -
initializeScripting
protected void initializeScripting()Description copied from class:AbstractApplicationInitializes the scripting.- Overrides:
initializeScriptingin classAbstractApplication
-
classMapped
A class was mapped the first time.Whenever a PDO class is used the first time, pre-compile all validator scripts in the background, if any. This usually improves UX snappiness.
The default implementation adds a
Taskto theModificationTracker.- Specified by:
classMappedin interfaceClassMappedListener- Parameters:
name- the mapped nameclazz- the class associated with that name
-
cleanup
protected void cleanup()Description copied from class:AbstractApplicationCleans up resources.
Invoked fromAbstractApplication.stop(int, java.lang.Throwable)- Overrides:
cleanupin classAbstractApplication
-