Package com.openfin.desktop.platform
Class Platform
- java.lang.Object
-
- com.openfin.desktop.platform.Platform
-
public final class Platform extends 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
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddEventListener(String type, EventListener listener)Add a platform event listener.CompletionStage<Platform>applySnapshot(PlatformSnapshot snapshot, PlatformSnapshotOptions opts)Adds a snapshot to a running Platform.CompletionStage<Platform>applySnapshot(String requestedSnapshot, PlatformSnapshotOptions opts)Adds a snapshot to a running Platform.CompletionStage<Void>closeView(PlatformView view)Closes a specified view in a target window.CompletionStage<PlatformView>createView(PlatformViewOptions viewOpts, Identity target)Creates a new view and attaches it to a specified target window.CompletionStage<Window>createWindow(WindowOptions winOpts)Creates a new Window.CompletionStage<ChannelClient>getChannelClient()CompletionStage<PlatformSnapshot>getSnapshot()Returns a snapshot of the platform in its current state.StringgetUuid()Get UUID of this platform object.CompletionStage<Void>quit()Closes current platform, all its windows, and their views.voidremoveEventListener(String type, EventListener listener)Remove the platform event listenerCompletionStage<PlatformView>reparentView(Identity viewIdentity, Identity targetIdentity)Reparents a specified view in a new target window.static CompletionStage<Platform>start(DesktopConnection desktopConnection, PlatformOptions platformOptions)Deprecated.use launchManifest() instead.static CompletionStage<Platform>startFromManifest(DesktopConnection desktopConnection, String manifestUrl)Retrieves platforms's manifest and returns a wrapped and running Platform.static Platformwrap(String uuid, DesktopConnection desktopConnection)Synchronously returns a Platform object that represents an existing platform.
-
-
-
Method Detail
-
start
public static CompletionStage<Platform> start(DesktopConnection desktopConnection, PlatformOptions platformOptions)
Deprecated.use launchManifest() instead.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 CompletionStage<Platform> startFromManifest(DesktopConnection desktopConnection, 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 String getUuid()
Get UUID of this platform object.- Returns:
- UUID of this platform object.
-
addEventListener
public void addEventListener(String type, EventListener listener)
Add a platform event listener.- Parameters:
type- event namelistener- event listener to be added
-
removeEventListener
public void removeEventListener(String type, EventListener listener)
Remove the platform event listener- Parameters:
type- event namelistener- event listener to be removed.
-
applySnapshot
public CompletionStage<Platform> applySnapshot(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 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
public CompletionStage<Void> closeView(PlatformView view)
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 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
public CompletionStage<Window> createWindow(WindowOptions winOpts)
Creates a new Window.- Parameters:
winOpts- Window creation options- Returns:
- new CompletionStage for the platform that had the window created.
-
getSnapshot
public CompletionStage<PlatformSnapshot> 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 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 CompletionStage<Void> quit()
Closes current platform, all its windows, and their views.- Returns:
- new CompletionStage when the command is delivered.
-
wrap
public static Platform wrap(String uuid, DesktopConnection desktopConnection)
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
public CompletionStage<ChannelClient> getChannelClient()
-
-