Package com.openfin.desktop.platform
Class Platform
java.lang.Object
com.openfin.desktop.platform.Platform
public final class Platform
extends java.lang.Object
Platform manages the life cycle of windows and views in the application.
It enables taking snapshots of itself and applying them to restore a previous configuration as well as listen to platform events.
- Author:
- Anthony
-
Method Summary
Modifier and Type Method Description void
addEventListener(java.lang.String type, EventListener listener)
Add a platform event listener.java.util.concurrent.CompletionStage<Platform>
applySnapshot(PlatformSnapshot snapshot, PlatformSnapshotOptions opts)
Adds a snapshot to a running Platform.java.util.concurrent.CompletionStage<Platform>
applySnapshot(java.lang.String requestedSnapshot, PlatformSnapshotOptions opts)
Adds a snapshot to a running Platform.java.util.concurrent.CompletionStage<java.lang.Void>
closeView(PlatformView view)
Closes a specified view in a target window.java.util.concurrent.CompletionStage<PlatformView>
createView(PlatformViewOptions viewOpts, Identity target)
Creates a new view and attaches it to a specified target window.java.util.concurrent.CompletionStage<Window>
createWindow(WindowOptions winOpts)
Creates a new Window.java.util.concurrent.CompletionStage<ChannelClient>
getChannelClient()
java.util.concurrent.CompletionStage<PlatformSnapshot>
getSnapshot()
Returns a snapshot of the platform in its current state.java.lang.String
getUuid()
Get UUID of this platform object.java.util.concurrent.CompletionStage<java.lang.Void>
quit()
Closes current platform, all its windows, and their views.void
removeEventListener(java.lang.String type, EventListener listener)
Remove the platform event listenerjava.util.concurrent.CompletionStage<PlatformView>
reparentView(Identity viewIdentity, Identity targetIdentity)
Reparents a specified view in a new target window.static java.util.concurrent.CompletionStage<Platform>
start(DesktopConnection desktopConnection, PlatformOptions platformOptions)
Creates and starts a Platform and returns a wrapped and running Platform instance.static java.util.concurrent.CompletionStage<Platform>
startFromManifest(DesktopConnection desktopConnection, java.lang.String manifestUrl)
Retrieves platforms's manifest and returns a wrapped and running Platform.static Platform
wrap(java.lang.String uuid, DesktopConnection desktopConnection)
Synchronously returns a Platform object that represents an existing platform.
-
Method Details
-
start
public static java.util.concurrent.CompletionStage<Platform> start(DesktopConnection desktopConnection, PlatformOptions platformOptions)Creates and starts a Platform and returns a wrapped and running Platform instance. The wrapped Platform methods can be used to launch content into the platform. Promise will reject if the platform is already running.- Parameters:
desktopConnection
- Connection object to the AppDesktop.platformOptions
- The required options object, also any Application option is also a valid platform option.- Returns:
- new CompletionStage for the platform that was started.
-
startFromManifest
public static java.util.concurrent.CompletionStage<Platform> startFromManifest(DesktopConnection desktopConnection, java.lang.String manifestUrl)Retrieves platforms's manifest and returns a wrapped and running Platform. If there is a snapshot in the manifest, it will be launched into the platform.- Parameters:
desktopConnection
- Connection object to the AppDesktop.manifestUrl
- The URL of platform's manifest.- Returns:
- new CompletionStage for the platform that was started.
-
getUuid
public java.lang.String getUuid()Get UUID of this platform object.- Returns:
- UUID of this platform object.
-
addEventListener
Add a platform event listener.- Parameters:
type
- event namelistener
- event listener to be added
-
removeEventListener
Remove the platform event listener- Parameters:
type
- event namelistener
- event listener to be removed.
-
applySnapshot
public java.util.concurrent.CompletionStage<Platform> applySnapshot(java.lang.String requestedSnapshot, PlatformSnapshotOptions opts)Adds a snapshot to a running Platform. Can optionally close existing windows and overwrite current platform state with that of a snapshot.- Parameters:
requestedSnapshot
- Url or filepath to a snapshot JSON object.opts
- Optional parameters to specify whether existing windows should be closed.- Returns:
- new CompletionStage for the platform that had the snapshot applied.
-
applySnapshot
public java.util.concurrent.CompletionStage<Platform> applySnapshot(PlatformSnapshot snapshot, PlatformSnapshotOptions opts)Adds a snapshot to a running Platform. Can optionally close existing windows and overwrite current platform state with that of a snapshot.- Parameters:
snapshot
- snapshot object.opts
- Optional parameters to specify whether existing windows should be closed.- Returns:
- new CompletionStage for the platform that had the snapshot applied.
-
closeView
Closes a specified view in a target window.- Parameters:
view
- the view to be closed.- Returns:
- new CompletionStage when the command is delivered.
-
createView
public java.util.concurrent.CompletionStage<PlatformView> createView(PlatformViewOptions viewOpts, Identity target)Creates a new view and attaches it to a specified target window.- Parameters:
viewOpts
- View creation optionstarget
- The window to which the new view is to be attached. If no target, create a view in a new window.- Returns:
- new CompletionStage for the platform that had the view created.
-
createWindow
Creates a new Window.- Parameters:
winOpts
- Window creation options- Returns:
- new CompletionStage for the platform that had the window created.
-
getSnapshot
Returns a snapshot of the platform in its current state. Can be used to restore an application to a previous state.- Returns:
- new CompletionStage for the platform snapshot.
-
reparentView
public java.util.concurrent.CompletionStage<PlatformView> reparentView(Identity viewIdentity, Identity targetIdentity)Reparents a specified view in a new target window.- Parameters:
viewIdentity
- View identitytargetIdentity
- New owner window identity- Returns:
- new CompletionStage for the reparented view.
-
quit
public java.util.concurrent.CompletionStage<java.lang.Void> quit()Closes current platform, all its windows, and their views.- Returns:
- new CompletionStage when the command is delivered.
-
wrap
Synchronously returns a Platform object that represents an existing platform.- Parameters:
uuid
- UUID of the platform.desktopConnection
- Connection object to the AppDesktop.- Returns:
- Platform object with given UUID.
-
getChannelClient
-