Class DesktopApplication<C extends org.tentackle.fx.FxController>

  • Type Parameters:
    C - the main controller type
    All Implemented Interfaces:
    org.tentackle.pdo.DomainContextProvider, org.tentackle.session.SessionProvider

    public abstract class DesktopApplication<C extends org.tentackle.fx.FxController>
    extends org.tentackle.app.AbstractClientApplication
    Java FX tentackle desktop application.
    Author:
    harald
    • Constructor Summary

      Constructors 
      Constructor Description
      DesktopApplication​(java.lang.String name)
      Creates an FX desktop application.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void configureMainStage​(javafx.stage.Stage mainStage)
      Configures and sets the main stage.
      protected void configureModificationTracker()  
      protected void configurePreferences()  
      protected void configureSecurityManager()  
      org.tentackle.pdo.DomainContext createDomainContext​(org.tentackle.session.Session session)
      LoginFailedHandler createLoginFailedHandler​(javafx.scene.Parent view, org.tentackle.session.SessionInfo sessionInfo)
      Creates the login failed handler.
      protected void finishStartup()  
      java.lang.Class<? extends FxApplication> getApplicationClass()
      Gets the FX application class.
      static DesktopApplication<?> getDesktopApplication()
      Gets the running desktop application.
      FxApplication getFxApplication()
      Gets the FX application instance.
      This is the instance of the class provided by getApplicationClass().
      The FX-application ususally provides a login-view and is responsible to spawn the main view after successful login.
      C getMainController()
      Gets the main controller.
      abstract java.lang.Class<? extends C> getMainControllerClass()
      Gets the main-controller to be displayed initially.
      Maintains the main-scene of the application.
      javafx.stage.Stage getMainStage()
      Gets the main stage.
      java.lang.Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
      Gets the exception handler.
      void login​(javafx.scene.Parent view, org.tentackle.session.SessionInfo sessionInfo)
      Performs the login and final startup of the application.
      void registerUncaughtExceptionHandler()
      Registers a handler for uncaught exceptions.
      void setFxApplication​(FxApplication fxApplication)
      Sets the FX application instance.
      void setMainController​(C mainController)
      Sets the main controller instance.
      void showApplicationStatus​(java.lang.String msg, double progress)
      Displays a message during login.
      protected void startup()  
      • Methods inherited from class org.tentackle.app.AbstractClientApplication

        detectJNLP, isDeployedByJNLP, isServerImpl, updateSessionInfoAfterLogin
      • Methods inherited from class org.tentackle.app.AbstractApplication

        cleanup, configure, createSession, createSessionInfo, getCommandLine, getCreationTime, getDomainContext, getName, getProperties, getProperty, getRunningApplication, getSession, getSessionInfo, getUser, getUser, initialize, isServer, isSystemExitNecessaryToStop, logStackdump, register, setDomainContext, setName, setProperties, setSessionInfo, start, start, stop, stop, toString, unregister
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.tentackle.pdo.DomainContextProvider

        on, op
    • Constructor Detail

      • DesktopApplication

        public DesktopApplication​(java.lang.String name)
        Creates an FX desktop application.
        Parameters:
        name - the application name
    • Method Detail

      • getDesktopApplication

        public static DesktopApplication<?> getDesktopApplication()
        Gets the running desktop application.
        Returns:
        the application
      • getMainControllerClass

        public abstract java.lang.Class<? extends C> getMainControllerClass()
        Gets the main-controller to be displayed initially.
        Maintains the main-scene of the application.
        Returns:
        the main controller class
      • 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

        public void setMainController​(C mainController)
        Sets the main controller instance.
        Parameters:
        mainController - the main controller
      • getMainController

        public C getMainController()
        Gets the main controller.
        Returns:
        the main controller
      • createLoginFailedHandler

        public LoginFailedHandler createLoginFailedHandler​(javafx.scene.Parent view,
                                                           org.tentackle.session.SessionInfo sessionInfo)
        Creates the login failed handler.
        Parameters:
        view - the view
        sessionInfo - the session info
        Returns:
        the handler
      • login

        public void login​(javafx.scene.Parent view,
                          org.tentackle.session.SessionInfo sessionInfo)
        Performs the login and final startup of the application.

        The method must hide the view when the main application windows 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 application window visible
        sessionInfo - the session info
      • getFxApplication

        public FxApplication getFxApplication()
        Gets the FX application instance.
        This is the instance of the class provided by getApplicationClass().
        The FX-application ususally provides a login-view and is responsible to spawn the main view after successful login.
        Returns:
        the FX application
      • setFxApplication

        public void setFxApplication​(FxApplication fxApplication)
        Sets the FX application instance.
        Parameters:
        fxApplication - the FX application
      • getApplicationClass

        public java.lang.Class<? extends FxApplication> getApplicationClass()
        Gets the FX application class.
        Returns:
        the fx application class
      • showApplicationStatus

        public void showApplicationStatus​(java.lang.String msg,
                                          double progress)
        Displays a message during login.
        Parameters:
        msg - the status message
        progress - the progress, 0 to disable, negative if infinite, 1.0 if done
      • registerUncaughtExceptionHandler

        public void registerUncaughtExceptionHandler()
        Registers a handler for uncaught exceptions.
      • getUncaughtExceptionHandler

        public java.lang.Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
        Gets the exception handler.
        Returns:
        the handler
      • createDomainContext

        public org.tentackle.pdo.DomainContext createDomainContext​(org.tentackle.session.Session session)

        Overridden to create a DomainContext with a thread-local session.

        In deskop client apps there are 2 threads using their own session:

        1. the FX thread
        2. the ModificationTracker thread
        By using the thread-local session, PDOs can be used from both threads without having to worry about the correct session.
        Overrides:
        createDomainContext in class org.tentackle.app.AbstractApplication
        Returns:
        the domain context
      • startup

        protected void startup()
        Specified by:
        startup in class org.tentackle.app.AbstractApplication
      • configurePreferences

        protected void configurePreferences()
        Overrides:
        configurePreferences in class org.tentackle.app.AbstractApplication
      • configureSecurityManager

        protected void configureSecurityManager()
        Overrides:
        configureSecurityManager in class org.tentackle.app.AbstractApplication
      • configureModificationTracker

        protected void configureModificationTracker()
        Overrides:
        configureModificationTracker in class org.tentackle.app.AbstractApplication
      • finishStartup

        protected void finishStartup()
        Overrides:
        finishStartup in class org.tentackle.app.AbstractApplication