com.openfin.desktop
Class Application

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

public class Application
extends 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 Summary
Application(ApplicationOptions options, DesktopConnection connection, AckListener listener)
          Application Constructor
 
Method Summary
 void addEventListener(String type, EventListener listener, AckListener callback)
          Registers an event listener on the specified event.
 void close()
          Closes the application and any child windows created by the application
 void close(AckListener listener)
          Deprecated. use close() instead.
 void close(Boolean force, AckListener listener)
          Closes the application with a listener that gets called if the method succeeds
 void createChildWindow(WindowOptions windowOptions, AckListener callback)
          Create a child window of this application
protected  DesktopConnection getConnection()
          Returns the applications connection object
 void getManifest(AckListener listener)
          Retrieves the JSON manifest that was used to create the application.
 ApplicationOptions getOptions()
          Get the ApplicationOptions object for the application
protected  String getUuid()
          Get UUID of this Application
 Window getWindow()
          Returns an instance to the main Window of the application.
 void removeEventListener(String type, EventListener listener, AckListener callback)
          Removes a previously registered event listener from the specified event
 void removeTrayIcon(AckListener callback)
          Removes the application‚Äôs icon from the tray.
 void restart()
          Restarts the application
 void restart(AckListener listener)
          Restarts the application with a listener that gets called if the method succeeds
 void run()
          Runs the application
 void run(AckListener listener)
          Runs the application with a listener that gets called if the method succeeds
 void setTrayIcon(String iconUrl, EventListener listener, AckListener callback)
          Adds a customizable icon in the system tray and notifies the application when clicked
 void terminate()
          Closes the application by terminating its process.
 void terminate(AckListener listener)
          Closes the application by terminating its process.
 void waitFor()
          Waits for a hanging application.
 void waitFor(AckListener listener)
          Waits for a hanging application.
static Application wrap(String uuid, DesktopConnection connection)
          Attaches an Application object to an application that already exists
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Application

public Application(ApplicationOptions options,
                   DesktopConnection connection,
                   AckListener listener)
Application Constructor

Parameters:
options - Settings of the application
connection - Connection object to the AppDesktop.
listener - function that is called if the method succeeds.
See Also:
ApplicationOptions, DesktopConnection, AckListener
Method Detail

wrap

public static Application wrap(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

run

public void run()
         throws DesktopIOException,
                DesktopException
Runs the application

Throws:
DesktopIOException
DesktopException
See Also:
DesktopIOException, DesktopException

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 DesktopIOException,
                    DesktopException
Restarts the application

Throws:
DesktopIOException
DesktopException
See Also:
DesktopIOException, 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 DesktopIOException,
                  DesktopException
Closes the application and any child windows created by the application

Throws:
DesktopIOException
DesktopException
See Also:
DesktopIOException, DesktopException

close

public void close(AckListener listener)
Deprecated. use close() instead.

Closes 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(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
See Also:
AckListener

terminate

public void terminate()
               throws DesktopIOException,
                      DesktopException
Closes the application by terminating its process.

Throws:
DesktopIOException
DesktopException
See Also:
DesktopIOException, 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 DesktopIOException,
                    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:
DesktopIOException
DesktopException
See Also:
DesktopIOException, 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

protected String getUuid()
Get UUID of this Application

Returns:
UUID

getConnection

protected DesktopConnection getConnection()
Returns the applications connection object

Returns:
DesktopConnection object
See Also:
DesktopConnection

addEventListener

public void addEventListener(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
See Also:
EventListener, ActionEvent

removeEventListener

public void removeEventListener(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
See Also:
EventListener, ActionEvent

setTrayIcon

public void setTrayIcon(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
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

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


Copyright © 2016. All rights reserved.