Class MobileApplication


  • @Deprecated
    public class MobileApplication
    extends Application
    Deprecated.
    This class is deprecated. Use AppManager instead.
    For Glisten-based applications, the MobileApplication class should be considered as the base class, in a similar fashion to the Application class is to JavaFX applications. In fact, MobileApplication extends from Application, so the importance of this class should be clear.

    Unlike Application, MobileApplication does not require any specific methods to be implemented. There are requirements on the developer, however. In particular, the developer of a mobile application has to specify the views and layers in their application, and provide these to the MobileApplication instance as factories that can be called on-demand.

    The most important view factory is the one that specifies the 'home view', which is shown when the application first starts. For example, here is the code to create a view factory for the home view:

     
     addViewFactory(MobileApplication.HOME_VIEW, () -> {
         // normal JavaFX code to create a scenegraph of nodes
         Node homeViewContent = ...;
    
         return new View(homeViewContent);
     });

    Note in the code above that we call the addViewFactory(String, Supplier) method of the MobileApplication class, and we provide two arguments:

    1. The name of the view. In this case, we are using the HOME_VIEW public static field, but this can be any String, as long as it is unique to your application (i.e. don't add multiple view factories with the same name!).
    2. We provide a Supplier implementation that, when called by Glisten, should return a new instance of this particular View. Note that the returned object is a View instance.

    With this view defined (along with other views relevant to your application), switching between views is simply a matter of calling MobileApplication.getInstance().switchView("view-name"), which "view-name" is replaced by the name of the view you wish to go to (or, if you wish to return home, simply HOME_VIEW).

    Similar functionality exists for layers, which make use of the GlassPane to appear above the rest of your application user interface.

    Once the start(javafx.stage.Stage) method is called, the stage, the scene and the glasspane are initialized, so the developer can use the method to select a Swatch, add an stylesheet or switch to a view, among others.

    MobileApplication also installs application wide AppBar and NavigationDrawer. A developer can simply call getAppBar() or getDrawer() to access these controls.

    Since:
    1.0.0
    See Also:
    GlassPane, View, Layer
    • Field Detail

      • HOME_VIEW

        public static final String HOME_VIEW
        Deprecated.
        All Glisten-based applications should define one View with its name specified as HOME_VIEW. This View will then become the default view of the user interface.
        See Also:
        Constant Field Values
      • SPLASH_VIEW

        public static final String SPLASH_VIEW
        Deprecated.
        A Glisten-based application defines a View with its name specified as SPLASH_VIEW intended to be a one-time splash view. After a given amount of time or certain event, this view will be dismissed giving access to the HOME_VIEW or any other view.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MobileApplication

        protected MobileApplication()
        Deprecated.
        Creates a new instance of MobileApplication.
    • Method Detail

      • getInstance

        public static MobileApplication getInstance()
        Deprecated.
        Returns the single instance of the MobileApplication.
        Returns:
        the MobileApplication single instance
      • start

        public final void start​(Stage primaryStage)
        Deprecated.
        Specified by:
        start in class Application
      • postInit

        public void postInit​(Scene scene)
        Deprecated.
        Intended for adding additional initialization code.
        Parameters:
        scene - application scene.
      • titleProperty

        public final StringProperty titleProperty()
        Deprecated.
        The title of the application. If this software is run on a desktop machine, this title will appear in the standard title area for applications. On other platforms, it is likely that this title will not be visible.
        See Also:
        getTitle(), setTitle(String)
      • setTitle

        public final void setTitle​(String title)
        Deprecated.
        Sets the value of the property title.
        Property description:
        The title of the application. If this software is run on a desktop machine, this title will appear in the standard title area for applications. On other platforms, it is likely that this title will not be visible.
      • getTitle

        public final String getTitle()
        Deprecated.
        Gets the value of the property title.
        Property description:
        The title of the application. If this software is run on a desktop machine, this title will appear in the standard title area for applications. On other platforms, it is likely that this title will not be visible.
      • getView

        public final View getView()
        Deprecated.
        Gets the value of the property view.
        Property description:
        The currently showing View within this application.
      • getSwatch

        public final Swatch getSwatch()
        Deprecated.
        Gets the value of the property swatch.
        Property description:
        Specifies the Swatch that should be used for the whole scene. If this property has a null value the default swatch will be used.
      • setSwatch

        public final void setSwatch​(Swatch swatch)
        Deprecated.
        Sets the value of the property swatch.
        Property description:
        Specifies the Swatch that should be used for the whole scene. If this property has a null value the default swatch will be used.
      • getAppBar

        public final AppBar getAppBar()
        Deprecated.
        Returns the AppBar instance that is a part of this application.
        Returns:
        the AppBar instance of the current application.
      • getStatusBar

        public final StatusBar getStatusBar()
        Deprecated.
        Returns the StatusBar instance that is a part of this application. Note that not all platforms have a status bar.
        Returns:
        The StatusBar instance of the current application.
        Since:
        4.0.0
      • switchView

        public final <T extends ViewOptional<T> switchView​(String viewName)
        Deprecated.
        Attempts to switch the view from the current view to a view represented by the given view name. If the view name does not exist, then the current view remains visible to users. If the view name does exist, then the view will be switched to the new view represented by this name. Previous view will be pushed on top of the view stack.
        Type Parameters:
        T - the view type
        Parameters:
        viewName - name of the view to switch to.
        Returns:
        optional view for which switch was requested
      • switchView

        public final <T extends ViewOptional<T> switchView​(String viewName,
                                                             ViewStackPolicy viewStackPolicy)
        Attempts to switch the view from the current view to a view represented by the given view name. If the view name does not exist, then the current view remains visible to users. If the view name does exist, then the view will be switched to the new view represented by this name. The viewStackPolicy that is passed in will dictate what happens to the view stack.
        Type Parameters:
        T - the view type
        Parameters:
        viewName - name of the view to switch to.
        viewStackPolicy - ViewStackPolicy.
        Returns:
        optional view for which switch was requested
      • switchToPreviousView

        public final <T extends ViewOptional<T> switchToPreviousView()
        Deprecated.
        Attempts to switch to a previously used view if one exists.
        Type Parameters:
        T - the view type
        Returns:
        optional previous view
      • goHome

        public final <T extends ViewOptional<T> goHome()
        Deprecated.
        Use AppManager.goHome() instead.
        Returns to the home view and clears view stack.
        Type Parameters:
        T - the view type
        Returns:
        optional view for which switch was requested
      • retrieveView

        public final Optional<View> retrieveView​(String viewName)
        Deprecated.
        Attempts to retrieve the view represented by the given view name. The result is wrapped in an Optional, to prevent null pointer exceptions.
        Parameters:
        viewName - The name of the View - this will be used at other points in the application lifecycle to reference this view, and to switch to it.
        Returns:
        an Optional with the View, if not empty
      • addViewFactory

        public final void addViewFactory​(String viewName,
                                         Supplier<View> supplier)
        Adds a new view factory to this application, if the given view name is unique (otherwise an IllegalArgumentException is thrown).
        Parameters:
        viewName - The name of the view - this will be used at other points in the application lifecycle to reference this view, and to switch to it.
        supplier - A Supplier instance that, when called, should return the view. This view is cached inside the mobile application, and as such is reused throughout the life of the application instance.
      • removeViewFactory

        public final boolean removeViewFactory​(String viewName)
        Deprecated.
        Removes a view factory with the given view name from this application, if it is present (optional operation).
        Parameters:
        viewName - The name of the view which is mapped to the view factory.
        Returns:
        true if the view name is present and is successfully removed from the application. false if the view name contained no mapping for a view factory.
      • isViewPresent

        public final boolean isViewPresent​(String viewName)
        Deprecated.
        Returns true if a view factory with the view name exists in the application.
        Parameters:
        viewName - The name of the view which is mapped to the view factory.
        Returns:
        true if a view factory with the view name exists in the application.
      • addLayerFactory

        public final void addLayerFactory​(String layerName,
                                          Supplier<Layer> supplier)
        Adds a new layer factory to this application, if the given layer name is unique (otherwise an IllegalArgumentException is thrown).
        Parameters:
        layerName - The name of the layer - this will be used at other points in the application lifecycle to reference this layer, and to show it.
        supplier - A Supplier instance that, when called, should return the Layer. This layer is cached inside the mobile application, and as such is reused throughout the life of the application instance.
      • removeLayerFactory

        public final boolean removeLayerFactory​(String layerName)
        Deprecated.
        Removes a layer factory with the given layer name from this application, if it is present (optional operation).
        Parameters:
        layerName - The name of the layer which is mapped to the layer factory.
        Returns:
        true if the layer name is present and is successfully removed from the application. false if the layer name contained no mapping for a layer factory.
      • isLayerPresent

        public final boolean isLayerPresent​(String layerName)
        Deprecated.
        Returns true if a layer factory with the layer name exists in the application.
        Parameters:
        layerName - The name of the layer which is mapped to the layer factory.
        Returns:
        true if a layer factory with the layer name exists in the application.
      • showLayer

        public final void showLayer​(String layerName)
        Deprecated.
        Attempts to show a layer with the given name. Is equivalent to calling Layer.show().
        Parameters:
        layerName - The name of the layer which is mapped to the layer factory.
      • hideLayer

        public final void hideLayer​(String layerName)
        Deprecated.
        Attempts to hide a layer with the given name. Is equivalent to calling Layer.hide().
        Parameters:
        layerName - The name of the layer which is mapped to the layer factory.
      • hideAllLayers

        public final void hideAllLayers​(boolean hideAllLayers)
        Deprecated.
        If set to true, all visible layers, starting from top-most layer, are hidden when user interacts with the opaque region. By default, the value is set to false and only the top most layer is hidden on user interaction.
        Default value:
        false
        Parameters:
        hideAllLayers - boolean argument to hide all layers when user interacts with opaque layer
        Since:
        6.0.7
      • getScreenHeight

        public final double getScreenHeight()
        Deprecated.
        Returns the height of the screen that this application is running on.
        Returns:
        a double value with the height of the screen
      • getScreenWidth

        public final double getScreenWidth()
        Deprecated.
        Returns the width of the screen that this application is running on.
        Returns:
        a double value with the width of the screen
      • createUserURLStreamHandlerFactory

        protected URLStreamHandlerFactory createUserURLStreamHandlerFactory()
        Deprecated.
        URL handling is under control of mobile application. If custom URL handling is required this method should return a URL handler factory.
        Returns:
        the URLStreamHandlerFactory