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. UseAppManagerinstead.For Glisten-based applications, the MobileApplication class should be considered as the base class, in a similar fashion to theApplicationclass 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_VIEWpublic 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
Supplierimplementation that, when called by Glisten, should return a new instance of this particularView. Note that the returned object is aViewinstance.
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 theGlassPaneto 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
AppBarandNavigationDrawer. 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>swatchDeprecated.StringPropertytitleDeprecated.ReadOnlyObjectProperty<View>viewDeprecated.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMobileApplication.MobileEventDeprecated.UseAppManager.MobileEventinstead.-
Nested classes/interfaces inherited from class javafx.application.Application
Application.Parameters
-
-
Field Summary
Fields Modifier and Type Field Description static StringHOME_VIEWDeprecated.UseAppManager.HOME_VIEWinstead.static StringSPLASH_VIEWDeprecated.UseAppManager.SPLASH_VIEWinstead-
Fields inherited from class javafx.application.Application
STYLESHEET_CASPIAN, STYLESHEET_MODENA
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMobileApplication()Deprecated.Creates a new instance of MobileApplication.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddLayerFactory(String layerName, Supplier<Layer> supplier)Deprecated.UseAppManager.addLayerFactory(String, Supplier)instead.voidaddViewFactory(String viewName, Supplier<View> supplier)Deprecated.UseAppManager.addViewFactory(String, Supplier)instead.protected URLStreamHandlerFactorycreateUserURLStreamHandlerFactory()Deprecated.URL handling is under control of mobile application.AppBargetAppBar()Deprecated.UseAppManager.getAppBar()instead.NavigationDrawergetDrawer()Deprecated.UseAppManager.getDrawer()instead.GlassPanegetGlassPane()Deprecated.UseAppManager.getGlassPane()instead.static MobileApplicationgetInstance()Deprecated.Returns the single instance of the MobileApplication.doublegetScreenHeight()Deprecated.UseAppManager.getScreenHeight()instead.doublegetScreenWidth()Deprecated.UseAppManager.getScreenWidth()instead.StatusBargetStatusBar()Deprecated.UseAppManager.getStatusBar()instead.SwatchgetSwatch()Deprecated.Gets the value of the property swatch.StringgetTitle()Deprecated.Gets the value of the property title.ViewgetView()Deprecated.Gets the value of the property view.<T extends View>
Optional<T>goHome()Deprecated.UseAppManager.goHome()instead.voidhideAllLayers(boolean hideAllLayers)Deprecated.UseAppManager.hideAllLayers(boolean)instead.voidhideLayer(String layerName)Deprecated.UseAppManager.hideLayer(String)instead.booleanisLayerPresent(String layerName)Deprecated.UseAppManager.isLayerPresent(String)instead.booleanisViewPresent(String viewName)Deprecated.UseAppManager.isViewPresent(String)instead.voidpostInit(Scene scene)Deprecated.Intended for adding additional initialization code.booleanremoveLayerFactory(String layerName)Deprecated.UseAppManager.removeLayerFactory(String)instead.booleanremoveViewFactory(String viewName)Deprecated.UseAppManager.removeViewFactory(String)instead.Optional<View>retrieveView(String viewName)Deprecated.UseAppManager.retrieveView(String)instead.voidsetSwatch(Swatch swatch)Deprecated.Sets the value of the property swatch.voidsetTitle(String title)Deprecated.Sets the value of the property title.voidshowLayer(String layerName)Deprecated.UseAppManager.showLayer(String)instead.voidshowMessage(String message)Deprecated.UseAppManager.showMessage(String)instead.voidshowMessage(String message, String buttonText, EventHandler<ActionEvent> evtHandler)Deprecated.UseAppManager.showMessage(String, String, EventHandler)instead.voidstart(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.StringPropertytitleProperty()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 showingViewwithin this application.- See Also:
getView()
-
swatch
public final ObjectProperty<Swatch> swatchProperty
Specifies theSwatchthat 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_VIEWinstead.All Glisten-based applications should define oneViewwith 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_VIEWinsteadA Glisten-based application defines aViewwith its name specified asSPLASH_VIEWintended 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_VIEWor 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:
startin 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 showingViewwithin this application.- See Also:
getView()
-
getView
public final View getView()
Deprecated.Gets the value of the property view.- Property description:
- The currently showing
Viewwithin this application.
-
swatchProperty
public final ObjectProperty<Swatch> swatchProperty()
Deprecated.Specifies theSwatchthat 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
Swatchthat 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
Swatchthat 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 theGlassPaneinstance that is part of this application.- Returns:
- the
GlassPaneinstance of this application.
-
getAppBar
public final AppBar getAppBar()
Deprecated.UseAppManager.getAppBar()instead.Returns theAppBarinstance that is a part of this application.- Returns:
- the
AppBarinstance of the current application.
-
getDrawer
public final NavigationDrawer getDrawer()
Deprecated.UseAppManager.getDrawer()instead.Returns theNavigationDrawerinstance that is a part of this application.- Returns:
- the
NavigationDrawerinstance of the current application. - Since:
- 5.0.0
-
getStatusBar
public final StatusBar getStatusBar()
Deprecated.UseAppManager.getStatusBar()instead.Returns theStatusBarinstance that is a part of this application. Note that not all platforms have a status bar.- Returns:
- The
StatusBarinstance 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
Optionalwith 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- ASupplierinstance 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:
trueif the view name is present and is successfully removed from the application.falseif the view name contained no mapping for a view factory.
-
isViewPresent
public final boolean isViewPresent(String viewName)
Deprecated.UseAppManager.isViewPresent(String)instead.Returnstrueif 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:
trueif 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- ASupplierinstance 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:
trueif the layer name is present and is successfully removed from the application.falseif the layer name contained no mapping for a layer factory.
-
isLayerPresent
public final boolean isLayerPresent(String layerName)
Deprecated.UseAppManager.isLayerPresent(String)instead.Returnstrueif 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:
trueif 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 tofalseand 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 aSnackbarwith the supplied message.- Parameters:
message- AStringmessage
-
showMessage
public void showMessage(String message, String buttonText, EventHandler<ActionEvent> evtHandler)
Deprecated.UseAppManager.showMessage(String, String, EventHandler)instead.Shows aSnackbarwith the supplied message and an action text.- Parameters:
message- AStringmessage.buttonText- AStringtext to set action text caption.evtHandler- AnEventHandlerwith 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
-
-