Class DesktopApplication<C extends FxController>

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

    public abstract class DesktopApplication<C extends FxController>
    extends AbstractClientApplication
    implements org.tentackle.reflect.ClassMappedListener
    Java FX tentackle desktop application.
    Author:
    harald
    • Constructor Detail

      • DesktopApplication

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

      • getDesktopApplication

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

        public abstract 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 Class<? extends FxApplication> getApplicationClass()
        Gets the FX application class.
        Returns:
        the fx application class
      • showApplicationStatus

        public void showApplicationStatus​(String msg,
                                          double progress,
                                          long minMillis)
        Displays a message during login.
        Parameters:
        msg - the status message
        progress - the progress, 0 to disable, negative if infinite, 1.0 if done
        minMillis - minimum milliseconds the previous message must have been visible
      • showApplicationStatus

        public void showApplicationStatus​(String msg,
                                          double progress)
        Displays a message during login.
        Makes sure that the message is shown at least 100ms.
        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.
      • createDomainContext

        public 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 AbstractApplication
        Returns:
        the domain context
      • classMapped

        public void classMapped​(String name,
                                Class<?> clazz)

        Whenever a PDO class is used the first time, pre-compile all validator scripts in background, if any. This usually improves UX snappiness.

        The default implementation adds a Task to the ModificationTracker.

        Specified by:
        classMapped in interface org.tentackle.reflect.ClassMappedListener