Class Application

java.lang.Object
com.openfin.desktop.Application

public class Application
extends java.lang.Object
An object representing the Application. Allows the developer to execute, show and close an application, as well as show and hide an icon on Desktop. Also provides access to the Window object for the main application window to control window state such as the ability to minimize, maximize, restore, etc.
Since:
10/29/12
  • Constructor Details

  • Method Details

    • wrap

      public static Application wrap​(java.lang.String uuid, DesktopConnection connection)
      Attaches an Application object to an application that already exists
      Parameters:
      uuid - The UUID of the Application to wrap
      connection - Connection object to the AppDesktop
      Returns:
      Application Object
      See Also:
      DesktopConnection
    • createApplication

      public static java.util.concurrent.CompletableFuture<Application> createApplication​(ApplicationOptions options, DesktopConnection connection)
    • run

      public void run() throws DesktopException
      Runs the application
      Throws:
      DesktopException - if application fails to run
      See Also:
      DesktopException
    • runAsync

      public java.util.concurrent.CompletableFuture<Application> runAsync()
    • run

      public void run​(AckListener listener)
      Runs the application with a listener that gets called if the method succeeds
      Parameters:
      listener - The listener that gets called if the method succeeds
      See Also:
      AckListener
    • restart

      public void restart() throws DesktopException
      Restarts the application
      Throws:
      DesktopException - if application fails to restart
      See Also:
      DesktopException
    • restart

      public void restart​(AckListener listener)
      Restarts the application with a listener that gets called if the method succeeds
      Parameters:
      listener - The listener that gets called if the method succeeds
      See Also:
      AckListener
    • close

      public void close() throws DesktopException
      Closes the application and any child windows created by the application
      Throws:
      DesktopException - if application fails to close
      See Also:
      DesktopException
    • close

      public void close​(java.lang.Boolean force, AckListener listener) throws DesktopException
      Closes the application with a listener that gets called if the method succeeds
      Parameters:
      force - When true the close can not be prevented through the window event 'close-requested'. If force is false, AckListener is being ignored
      listener - The listener that gets called if the method succeeds
      Throws:
      DesktopException - if application fails to close
      See Also:
      AckListener
    • terminate

      public void terminate() throws DesktopException
      Closes the application by terminating its process.
      Throws:
      DesktopException - if application fails to terminate
      See Also:
      DesktopException
    • terminate

      public void terminate​(AckListener listener)
      Closes the application by terminating its process.
      Parameters:
      listener - The listener that gets called if the method succeeds
      See Also:
      AckListener
    • waitFor

      public void waitFor() throws DesktopException
      Waits for a hanging application. This method can be called in response to an application "not-responding" to allow the application to continue and to generate another "not-responding" message after a certain period of time.
      Throws:
      DesktopException - if application fails to wait for a hanging application
      See Also:
      DesktopException
    • waitFor

      public void waitFor​(AckListener listener)
      Waits for a hanging application. This method can be called in response to an application "not-responding" to allow the application to continue and to generate another "not-responding" message after a certain period of time.
      Parameters:
      listener - The listener that gets called if the method succeeds
      See Also:
      AckListener
    • getManifest

      public void getManifest​(AckListener listener)
      Retrieves the JSON manifest that was used to create the application. Invokes the error callback if the application was not created from a manifest. AckListener is called and passed an Ack containing the JSONObject manifest that was used to create the application.
      Parameters:
      listener - The listener that gets called if the method succeeds
      See Also:
      AckListener
    • getWindow

      public Window getWindow()
      Returns an instance to the main Window of the application.
      Returns:
      the main Window
    • getOptions

      public ApplicationOptions getOptions()
      Get the ApplicationOptions object for the application
      Returns:
      ApplicationOptions object
    • getUuid

      public java.lang.String getUuid()
      Get UUID of this Application
      Returns:
      UUID
    • getConnection

      public DesktopConnection getConnection()
      Returns the applications connection object
      Returns:
      DesktopConnection object
      See Also:
      DesktopConnection
    • addEventListener

      public void addEventListener​(java.lang.String type, EventListener listener, AckListener callback) throws DesktopException
      Registers an event listener on the specified event. Supported system event types are: closed crashed error not-responding out-of-memory responding started run-requested
      Parameters:
      type - Event type
      listener - A listener that is called whenever an event of the specified type occurs
      callback - A function that is called if the method succeeds
      Throws:
      DesktopException - if this methos fails to add event listener
      See Also:
      EventListener, ActionEvent
    • removeEventListener

      public void removeEventListener​(java.lang.String type, EventListener listener, AckListener callback) throws DesktopException
      Removes a previously registered event listener from the specified event
      Parameters:
      type - Event type
      listener - A listener to remove
      callback - AckListener for the request
      Throws:
      DesktopException - if this methd fails to remove an event listener
      See Also:
      EventListener, ActionEvent
    • setTrayIcon

      public void setTrayIcon​(java.lang.String iconUrl, EventListener listener, AckListener callback) throws DesktopException
      Adds a customizable icon in the system tray and notifies the application when clicked
      Parameters:
      iconUrl - Image URL to be used as the icon
      listener - will be called whenever an event of the specified type occurs. It is passed an event object containing information related to the event
      callback - AckListener for the request
      Throws:
      DesktopException - if this methed fails to set tray icon
      See Also:
      EventListener, ActionEvent
    • removeTrayIcon

      public void removeTrayIcon​(AckListener callback) throws DesktopException
      Removes the application’s icon from the tray.
      Parameters:
      callback - AckListener for the request
      Throws:
      DesktopException - if this method fails to remove tray icn
    • createChildWindow

      public void createChildWindow​(WindowOptions windowOptions, AckListener callback) throws DesktopException
      Create a child window of this application
      Parameters:
      windowOptions - WindowOptions object for the requested child window.
      callback - AckListener for the request
      Throws:
      DesktopException - if this method fails to create a child window
    • getGroups

      public void getGroups​(AsyncCallback<java.util.List<java.util.List<Window>>> groupHandler, AckListener callback)
      Retrieves an array of active window groups for all of the application's windows. Each group is represented as an array of wrapped fin.desktop.Windows. An empty list is returned if the window is not in a group. The calling window is included in the resulting List.
      Parameters:
      groupHandler - A class that receives a list of wrapped windows in the same group.
      callback - AckListener for the request
      See Also:
      AsyncCallback, AckListener
    • wrapWindow

      public Window wrapWindow​(java.lang.String name)
      Wraps an existing window using the specified name
      Parameters:
      name - The name of the window that is being wrapped
      Returns:
      The wrapped window
      See Also:
      Window
    • createFromManifestAsync

      public static java.util.concurrent.CompletableFuture<Application> createFromManifestAsync​(java.lang.String manifestUrl, DesktopConnection connection)
    • createFromManifest

      public static void createFromManifest​(java.lang.String manifestUrl, AsyncCallback<Application> callback, AckListener listener, DesktopConnection connection) throws DesktopException
      Retrieves application's manifest and returns a wrapped application.
      Parameters:
      manifestUrl - The URL of app's manifest
      callback - The callback that receives the wrapped Application object
      listener - The AckListener for the request
      connection - The connection to openfin Runtime
      Throws:
      DesktopException - if application fails to be created
      See Also:
      AsyncCallback, AckListener, DesktopException
    • getChildWindows

      public void getChildWindows​(AsyncCallback<java.util.List<Window>> callback, AckListener listener)
      Retrieves an list of wrapped fin.desktop.Windows for each of the application’s child windows
      Parameters:
      callback - The callback that receives a list of wrapped Window objects
      listener - AckListener for the request
      See Also:
      AsyncCallback, AckListener
    • getChildWindows

      public java.util.concurrent.CompletableFuture<java.util.List<Window>> getChildWindows()
    • getInfo

      public void getInfo​(AsyncCallback<org.json.JSONObject> callback, AckListener listener)
      Retrieves information about the application.
      Parameters:
      callback - The callback that receives the information about the application
      listener - AckListener for the request
      See Also:
      AsyncCallback, AckListener
    • getParentUuid

      public void getParentUuid​(AsyncCallback<java.lang.String> callback, AckListener listener)
      Retrieves UUID of the application that launches this application.
      Parameters:
      callback - The UUID of the parent application
      listener - AckListener for the request
      See Also:
      AsyncCallback, AckListener
    • getTrayIconInfo

      public void getTrayIconInfo​(AsyncCallback<org.json.JSONObject> callback, AckListener listener)
      Retrieves information about the custom icon the application previously set in the system tray via setTrayIcon().
      Parameters:
      callback - tray icon info
      listener - AckListener for the request
      See Also:
      AsyncCallback, AckListener
    • isRunning

      public void isRunning​(AsyncCallback<java.lang.Boolean> callback, AckListener listener)
      Determines if the application is currently running.
      Parameters:
      callback - if the application is currently running
      listener - AckListener for the request
      See Also:
      AsyncCallback, AckListener
    • registerUser

      public void registerUser​(java.lang.String username, java.lang.String appName, AckListener listener)
      Manually registers a user with the licensing service. The only data sent by this call is userName and appName.
      Parameters:
      username - username to be passed to the RVM.
      appName - app name to be passed to the RVM.
      listener - AckListener for the request
      See Also:
      AckListener