Package com.openfin.desktop
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 Summary
Constructors Constructor Description Application(ApplicationOptions options, DesktopConnection connection, AckListener listener)
Application Constructor -
Method Summary
Modifier and Type Method Description void
addEventListener(java.lang.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 applicationvoid
close(java.lang.Boolean force, AckListener listener)
Closes the application with a listener that gets called if the method succeedsstatic java.util.concurrent.CompletableFuture<Application>
createApplication(ApplicationOptions options, DesktopConnection connection)
void
createChildWindow(WindowOptions windowOptions, AckListener callback)
Create a child window of this applicationstatic void
createFromManifest(java.lang.String manifestUrl, AsyncCallback<Application> callback, AckListener listener, DesktopConnection connection)
Retrieves application's manifest and returns a wrapped application.static java.util.concurrent.CompletableFuture<Application>
createFromManifestAsync(java.lang.String manifestUrl, DesktopConnection connection)
java.util.concurrent.CompletableFuture<java.util.List<Window>>
getChildWindows()
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 windowsDesktopConnection
getConnection()
Returns the applications connection objectvoid
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.void
getInfo(AsyncCallback<org.json.JSONObject> callback, AckListener listener)
Retrieves information about the application.void
getManifest(AckListener listener)
Retrieves the JSON manifest that was used to create the application.ApplicationOptions
getOptions()
Get the ApplicationOptions object for the applicationvoid
getParentUuid(AsyncCallback<java.lang.String> callback, AckListener listener)
Retrieves UUID of the application that launches this application.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().java.lang.String
getUuid()
Get UUID of this ApplicationWindow
getWindow()
Returns an instance to the main Window of the application.void
isRunning(AsyncCallback<java.lang.Boolean> callback, AckListener listener)
Determines if the application is currently running.void
registerUser(java.lang.String username, java.lang.String appName, AckListener listener)
Manually registers a user with the licensing service.void
removeEventListener(java.lang.String type, EventListener listener, AckListener callback)
Removes a previously registered event listener from the specified eventvoid
removeTrayIcon(AckListener callback)
Removes the application’s icon from the tray.void
restart()
Restarts the applicationvoid
restart(AckListener listener)
Restarts the application with a listener that gets called if the method succeedsvoid
run()
Runs the applicationvoid
run(AckListener listener)
Runs the application with a listener that gets called if the method succeedsjava.util.concurrent.CompletableFuture<Application>
runAsync()
void
setTrayIcon(java.lang.String iconUrl, EventListener listener, AckListener callback)
Adds a customizable icon in the system tray and notifies the application when clickedvoid
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(java.lang.String uuid, DesktopConnection connection)
Attaches an Application object to an application that already existsWindow
wrapWindow(java.lang.String name)
Wraps an existing window using the specified name
-
Constructor Details
-
Application
Application Constructor- Parameters:
options
- Settings of the applicationconnection
- Connection object to the AppDesktop.listener
- function that is called if the method succeeds.- See Also:
ApplicationOptions
,DesktopConnection
,AckListener
-
-
Method Details
-
wrap
Attaches an Application object to an application that already exists- Parameters:
uuid
- The UUID of the Application to wrapconnection
- 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
Runs the application- Throws:
DesktopException
- if application fails to run- See Also:
DesktopException
-
runAsync
-
run
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
Restarts the application- Throws:
DesktopException
- if application fails to restart- See Also:
DesktopException
-
restart
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
Closes the application and any child windows created by the application- Throws:
DesktopException
- if application fails to close- See Also:
DesktopException
-
close
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 ignoredlistener
- The listener that gets called if the method succeeds- Throws:
DesktopException
- if application fails to close- See Also:
AckListener
-
terminate
Closes the application by terminating its process.- Throws:
DesktopException
- if application fails to terminate- See Also:
DesktopException
-
terminate
Closes the application by terminating its process.- Parameters:
listener
- The listener that gets called if the method succeeds- See Also:
AckListener
-
waitFor
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
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
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
Returns an instance to the main Window of the application.- Returns:
- the main Window
-
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
Returns the applications connection object- Returns:
- DesktopConnection object
- See Also:
DesktopConnection
-
addEventListener
public void addEventListener(java.lang.String type, EventListener listener, AckListener callback) throws DesktopExceptionRegisters 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 typelistener
- A listener that is called whenever an event of the specified type occurscallback
- 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 DesktopExceptionRemoves a previously registered event listener from the specified event- Parameters:
type
- Event typelistener
- A listener to removecallback
- 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 DesktopExceptionAdds a customizable icon in the system tray and notifies the application when clicked- Parameters:
iconUrl
- Image URL to be used as the iconlistener
- will be called whenever an event of the specified type occurs. It is passed an event object containing information related to the eventcallback
- AckListener for the request- Throws:
DesktopException
- if this methed fails to set tray icon- See Also:
EventListener
,ActionEvent
-
removeTrayIcon
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 DesktopExceptionCreate 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
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 DesktopExceptionRetrieves application's manifest and returns a wrapped application.- Parameters:
manifestUrl
- The URL of app's manifestcallback
- The callback that receives the wrappedApplication
objectlistener
- The AckListener for the requestconnection
- The connection to openfin Runtime- Throws:
DesktopException
- if application fails to be created- See Also:
AsyncCallback
,AckListener
,DesktopException
-
getChildWindows
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 wrappedWindow
objectslistener
- AckListener for the request- See Also:
AsyncCallback
,AckListener
-
getChildWindows
-
getInfo
Retrieves information about the application.- Parameters:
callback
- The callback that receives the information about the applicationlistener
- AckListener for the request- See Also:
AsyncCallback
,AckListener
-
getParentUuid
Retrieves UUID of the application that launches this application.- Parameters:
callback
- The UUID of the parent applicationlistener
- AckListener for the request- See Also:
AsyncCallback
,AckListener
-
getTrayIconInfo
Retrieves information about the custom icon the application previously set in the system tray via setTrayIcon().- Parameters:
callback
- tray icon infolistener
- AckListener for the request- See Also:
AsyncCallback
,AckListener
-
isRunning
Determines if the application is currently running.- Parameters:
callback
- if the application is currently runninglistener
- 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
-