Class MobileApplication
- java.lang.Object
-
- javafx.application.Application
-
- com.gluonhq.charm.glisten.application.MobileApplication
-
@Deprecated public class MobileApplication extends Application
Deprecated.This class is deprecated. UseAppManager
instead.For Glisten-based applications, the MobileApplication class should be considered as the base class, in a similar fashion to theApplication
class is to JavaFX applications. In fact, MobileApplication extends fromApplication
, 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:- 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!). - We provide a
Supplier
implementation that, when called by Glisten, should return a new instance of this particularView
. Note that the returned object is aView
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, simplyHOME_VIEW
).Similar functionality exists for
layers
, which make use of theGlassPane
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 aSwatch
, add an stylesheet or switch to a view, among others.MobileApplication also installs application wide
AppBar
andNavigationDrawer
. A developer can simply callgetAppBar()
orgetDrawer()
to access these controls. - The name of the view. In this case, we are using the
-
-
Property Summary
Properties Type Property Description ObjectProperty<Swatch>
swatch
Deprecated.StringProperty
title
Deprecated.ReadOnlyObjectProperty<View>
view
Deprecated.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MobileApplication.MobileEvent
Deprecated.UseAppManager.MobileEvent
instead.-
Nested classes/interfaces inherited from class javafx.application.Application
Application.Parameters
-
-
Field Summary
Fields Modifier and Type Field Description static String
HOME_VIEW
Deprecated.UseAppManager.HOME_VIEW
instead.static String
SPLASH_VIEW
Deprecated.UseAppManager.SPLASH_VIEW
instead-
Fields inherited from class javafx.application.Application
STYLESHEET_CASPIAN, STYLESHEET_MODENA
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
MobileApplication()
Deprecated.Creates a new instance of MobileApplication.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addLayerFactory(String layerName, Supplier<Layer> supplier)
Deprecated.UseAppManager.addLayerFactory(String, Supplier)
instead.void
addViewFactory(String viewName, Supplier<View> supplier)
Deprecated.UseAppManager.addViewFactory(String, Supplier)
instead.protected URLStreamHandlerFactory
createUserURLStreamHandlerFactory()
Deprecated.URL handling is under control of mobile application.AppBar
getAppBar()
Deprecated.UseAppManager.getAppBar()
instead.NavigationDrawer
getDrawer()
Deprecated.UseAppManager.getDrawer()
instead.GlassPane
getGlassPane()
Deprecated.UseAppManager.getGlassPane()
instead.static MobileApplication
getInstance()
Deprecated.Returns the single instance of the MobileApplication.double
getScreenHeight()
Deprecated.UseAppManager.getScreenHeight()
instead.double
getScreenWidth()
Deprecated.UseAppManager.getScreenWidth()
instead.StatusBar
getStatusBar()
Deprecated.UseAppManager.getStatusBar()
instead.Swatch
getSwatch()
Deprecated.Gets the value of the property swatch.String
getTitle()
Deprecated.Gets the value of the property title.View
getView()
Deprecated.Gets the value of the property view.<T extends View>
Optional<T>goHome()
Deprecated.UseAppManager.goHome()
instead.void
hideAllLayers(boolean hideAllLayers)
Deprecated.UseAppManager.hideAllLayers(boolean)
instead.void
hideLayer(String layerName)
Deprecated.UseAppManager.hideLayer(String)
instead.boolean
isLayerPresent(String layerName)
Deprecated.UseAppManager.isLayerPresent(String)
instead.boolean
isViewPresent(String viewName)
Deprecated.UseAppManager.isViewPresent(String)
instead.void
postInit(Scene scene)
Deprecated.Intended for adding additional initialization code.boolean
removeLayerFactory(String layerName)
Deprecated.UseAppManager.removeLayerFactory(String)
instead.boolean
removeViewFactory(String viewName)
Deprecated.UseAppManager.removeViewFactory(String)
instead.Optional<View>
retrieveView(String viewName)
Deprecated.UseAppManager.retrieveView(String)
instead.void
setSwatch(Swatch swatch)
Deprecated.Sets the value of the property swatch.void
setTitle(String title)
Deprecated.Sets the value of the property title.void
showLayer(String layerName)
Deprecated.UseAppManager.showLayer(String)
instead.void
showMessage(String message)
Deprecated.UseAppManager.showMessage(String)
instead.void
showMessage(String message, String buttonText, EventHandler<ActionEvent> evtHandler)
Deprecated.UseAppManager.showMessage(String, String, EventHandler)
instead.void
start(Stage primaryStage)
Deprecated.ObjectProperty<Swatch>
swatchProperty()
Deprecated.<T extends View>
Optional<T>switchToPreviousView()
Deprecated.UseAppManager.switchToPreviousView()
instead.<T extends View>
Optional<T>switchView(String viewName)
Deprecated.UseAppManager.switchView(String)
instead.<T extends View>
Optional<T>switchView(String viewName, ViewStackPolicy viewStackPolicy)
Deprecated.UseAppManager.switchView(String, ViewStackPolicy)
instead.StringProperty
titleProperty()
Deprecated.ReadOnlyObjectProperty<View>
viewProperty()
Deprecated.-
Methods inherited from class javafx.application.Application
getHostServices, getParameters, getUserAgentStylesheet, init, launch, launch, notifyPreloader, setUserAgentStylesheet, stop
-
-
-
-
Property Detail
-
title
public final StringProperty titleProperty
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)
-
view
public final ReadOnlyObjectProperty<View> viewProperty
The currently showingView
within this application.- See Also:
getView()
-
swatch
public final ObjectProperty<Swatch> swatchProperty
Specifies theSwatch
that should be used for the whole scene. If this property has a null value the default swatch will be used.- See Also:
getSwatch()
,setSwatch(Swatch)
-
-
Field Detail
-
HOME_VIEW
public static final String HOME_VIEW
Deprecated.UseAppManager.HOME_VIEW
instead.All Glisten-based applications should define oneView
with its name specified asHOME_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.UseAppManager.SPLASH_VIEW
insteadA Glisten-based application defines aView
with its name specified asSPLASH_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 theHOME_VIEW
or any other view.- See Also:
- Constant Field Values
-
-
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 classApplication
-
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.
-
viewProperty
public final ReadOnlyObjectProperty<View> viewProperty()
Deprecated.The currently showingView
within this application.- See Also:
getView()
-
getView
public final View getView()
Deprecated.Gets the value of the property view.- Property description:
- The currently showing
View
within this application.
-
swatchProperty
public final ObjectProperty<Swatch> swatchProperty()
Deprecated.Specifies theSwatch
that should be used for the whole scene. If this property has a null value the default swatch will be used.- See Also:
getSwatch()
,setSwatch(Swatch)
-
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.
-
getGlassPane
public final GlassPane getGlassPane()
Deprecated.UseAppManager.getGlassPane()
instead.Returns theGlassPane
instance that is part of this application.- Returns:
- the
GlassPane
instance of this application.
-
getAppBar
public final AppBar getAppBar()
Deprecated.UseAppManager.getAppBar()
instead.Returns theAppBar
instance that is a part of this application.- Returns:
- the
AppBar
instance of the current application.
-
getDrawer
public final NavigationDrawer getDrawer()
Deprecated.UseAppManager.getDrawer()
instead.Returns theNavigationDrawer
instance that is a part of this application.- Returns:
- the
NavigationDrawer
instance of the current application. - Since:
- 5.0.0
-
getStatusBar
public final StatusBar getStatusBar()
Deprecated.UseAppManager.getStatusBar()
instead.Returns theStatusBar
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 View> Optional<T> switchView(String viewName)
Deprecated.UseAppManager.switchView(String)
instead.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 View> Optional<T> switchView(String viewName, ViewStackPolicy viewStackPolicy)
Deprecated.UseAppManager.switchView(String, ViewStackPolicy)
instead.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 View> Optional<T> switchToPreviousView()
Deprecated.UseAppManager.switchToPreviousView()
instead.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 View> Optional<T> goHome()
Deprecated.UseAppManager.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.UseAppManager.retrieveView(String)
instead.Attempts to retrieve the view represented by the given view name. The result is wrapped in anOptional
, to prevent null pointer exceptions.- Parameters:
viewName
- The name of theView
- this will be used at other points in the application lifecycle to reference this view, and toswitch to it
.- Returns:
- an
Optional
with theView
, if not empty
-
addViewFactory
public final void addViewFactory(String viewName, Supplier<View> supplier)
Deprecated.UseAppManager.addViewFactory(String, Supplier)
instead.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 toswitch to it
.supplier
- ASupplier
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.UseAppManager.removeViewFactory(String)
instead.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.UseAppManager.isViewPresent(String)
instead.Returnstrue
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)
Deprecated.UseAppManager.addLayerFactory(String, Supplier)
instead.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 toshow it
.supplier
- ASupplier
instance that, when called, should return theLayer
. 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.UseAppManager.removeLayerFactory(String)
instead.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.UseAppManager.isLayerPresent(String)
instead.Returnstrue
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.UseAppManager.showLayer(String)
instead.Attempts to show a layer with the given name. Is equivalent to callingLayer.show()
.- Parameters:
layerName
- The name of the layer which is mapped to the layer factory.
-
hideLayer
public final void hideLayer(String layerName)
Deprecated.UseAppManager.hideLayer(String)
instead.Attempts to hide a layer with the given name. Is equivalent to callingLayer.hide()
.- Parameters:
layerName
- The name of the layer which is mapped to the layer factory.
-
hideAllLayers
public final void hideAllLayers(boolean hideAllLayers)
Deprecated.UseAppManager.hideAllLayers(boolean)
instead.If set totrue
, all visible layers, starting from top-most layer, are hidden when user interacts with the opaque region. By default, the value is set tofalse
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.UseAppManager.getScreenHeight()
instead.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.UseAppManager.getScreenWidth()
instead.Returns the width of the screen that this application is running on.- Returns:
- a double value with the width of the screen
-
showMessage
public void showMessage(String message)
Deprecated.UseAppManager.showMessage(String)
instead.Shows aSnackbar
with the supplied message.- Parameters:
message
- AString
message
-
showMessage
public void showMessage(String message, String buttonText, EventHandler<ActionEvent> evtHandler)
Deprecated.UseAppManager.showMessage(String, String, EventHandler)
instead.Shows aSnackbar
with the supplied message and an action text.- Parameters:
message
- AString
message.buttonText
- AString
text to set action text caption.evtHandler
- AnEventHandler
with the action to be invoked when the user clicks the action text.
-
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
-
-