Class Window

java.lang.Object
com.openfin.desktop.WebContent
com.openfin.desktop.Window

public class Window
extends WebContent
An object representing a window that can be controlled by the AppDesktop API.
  • Constructor Details

    • Window

      protected Window​(Application application)
      Window constructor
      Parameters:
      application - Parent Application
  • Method Details

    • getEventTopicName

      protected java.lang.String getEventTopicName()
      Specified by:
      getEventTopicName in class WebContent
    • getParentApplication

      public Application getParentApplication()
      Returns the wrapped application that this window belongs to
      Returns:
      Parent application
    • getParentWindow

      public Window getParentWindow()
      Get parent window
      Returns:
      Parent window
    • getSnapshot

      public void getSnapshot​(AckListener callback)
      Gets a base64 encoded PN snapshot of the window
      Parameters:
      callback - AckListener for the request
      See Also:
      AckListener
    • show

      public void show() throws DesktopException
      Shows the window if it is hidden
      Throws:
      DesktopException - if the window fails to show
      See Also:
      DesktopException
    • show

      public void show​(AckListener listener)
      Shows the window if it is hidden
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • hide

      public void hide() throws DesktopException
      Hides the window if it is shown
      Throws:
      DesktopException - if the window fails to hide
      See Also:
      DesktopException
    • hide

      public void hide​(AckListener listener)
      Hides the window if it is shown
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • close

      public void close() throws DesktopException
      Closes the window
      Throws:
      DesktopException - if the window fails to close
      See Also:
      DesktopException
    • close

      public void close​(AckListener listener)
      Closes the window
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • close

      public void close​(java.lang.Boolean force, AckListener ackListener)
      Closes the window
      Parameters:
      force - Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for the window
      ackListener - AckListener for the request
      See Also:
      AckListener
    • closeAsync

      public java.util.concurrent.CompletableFuture<Ack> closeAsync​(java.lang.Boolean force)
    • minimize

      public void minimize() throws DesktopException
      Minimizes the window
      Throws:
      DesktopException - if the window fails to minimize
      See Also:
      DesktopException
    • minimize

      public void minimize​(AckListener listener)
      Minimizes the window
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • maximize

      public void maximize() throws DesktopException
      Maximizes the window
      Throws:
      DesktopException - if the window fails to maximize
      See Also:
      DesktopException
    • maximize

      public void maximize​(AckListener listener)
      Maximizes the window
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • restore

      public void restore() throws DesktopException
      Restores the window
      Throws:
      DesktopException - if the window fails to restore
      See Also:
      DesktopException
    • restore

      public void restore​(AckListener listener)
      Restores the window
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • focus

      public void focus() throws DesktopException
      Gives focus to the window
      Throws:
      DesktopException - if the windw fails to gain focus
      See Also:
      DesktopException
    • focus

      public void focus​(AckListener listener)
      Gives focus to the window
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • blur

      public void blur() throws DesktopException
      Removes focus to the window
      Throws:
      DesktopException - if the window fails to lose focus
      See Also:
      DesktopException
    • blur

      public void blur​(AckListener listener)
      Removes focus to the window
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • flash

      public void flash​(AckListener callback)
      Draws attention to the window by flashing the taskbar and window caption. This effect continues until the window receives focus.
      Parameters:
      callback - AckListener for the request
      See Also:
      AckListener
    • stopFlashing

      public void stopFlashing​(AckListener callback)
      Stops flashing of taskbar and window caption
      Parameters:
      callback - AckListener for the request
      See Also:
      AckListener
    • showAt

      public void showAt​(int left, int top, boolean toggle) throws DesktopException
      Shows the window if it is hidden at the specified location
      Parameters:
      left - The left position of the window
      top - The right position of the window
      toggle - If true, the window will alternate between showing and hiding in subsequent calls
      Throws:
      DesktopException - if the window fails to show
      See Also:
      DesktopException
    • showAt

      public void showAt​(int left, int top, boolean toggle, AckListener listener) throws DesktopException
      Shows the window if it is hidden at the specified location
      Parameters:
      left - The left position of the window
      top - The right position of the window
      toggle - If true, the window will alternate between showing and hiding in subsequent calls
      listener - AckListener for the request
      Throws:
      DesktopException - if the window fails to show
      See Also:
      AckListener, DesktopException
    • moveTo

      public void moveTo​(int left, int top) throws DesktopException
      Moves the window to a specified location
      Parameters:
      left - The left position of the window
      top - The right position of the window
      Throws:
      DesktopException - if the window fails to move
      See Also:
      DesktopException
    • moveTo

      public void moveTo​(int left, int top, AckListener listener) throws DesktopException
      Moves the window to a specified location
      Parameters:
      left - The left position of the window
      top - The right position of the window
      listener - AckListener for the request
      Throws:
      DesktopException - if the window fails to move
      See Also:
      AckListener, DesktopException
    • moveBy

      public void moveBy​(int deltaLeft, int deltaTop) throws DesktopException
      Moves the window by a specified amount
      Parameters:
      deltaLeft - The change in the left position of the window
      deltaTop - The change in the top position of the window
      Throws:
      DesktopException - if the window fails to move
      See Also:
      DesktopException
    • moveBy

      public void moveBy​(int deltaLeft, int deltaTop, AckListener listener) throws DesktopException
      Moves the window by a specified amount
      Parameters:
      deltaLeft - The change in the left position of the window
      deltaTop - The change in the top position of the window
      listener - AckListener for the request
      Throws:
      DesktopException - if the window fails to move
      See Also:
      AckListener, DesktopException
    • resizeTo

      public void resizeTo​(int width, int height, java.lang.String anchor) throws DesktopException
      Resizes the window to the specified dimensions
      Parameters:
      width - Width of the window
      height - Height of the window
      anchor - Specifies a corner to remain fixed during the resize. Can take the values: "top-left" "top-right" "bottom-left" "bottom-right" If undefined, the default is "top-left".
      Throws:
      DesktopException - if the windw fails to resize
      See Also:
      DesktopException
    • resizeTo

      public void resizeTo​(int width, int height, java.lang.String anchor, AckListener listener) throws DesktopException
      Resizes the window to the specified dimensions
      Parameters:
      width - Width of the window
      height - Height of the window
      anchor - Specifies a corner to remain fixed during the resize. Can take the values: "top-left" "top-right" "bottom-left" "bottom-right" If undefined, the default is "top-left".
      listener - AckListener for the request
      Throws:
      DesktopException - if the window fails to resize
      See Also:
      AckListener, DesktopException
    • resizeTo

      public void resizeTo​(int width, int height, AckListener listener) throws DesktopException
      Resizes the window to the specified dimensions
      Parameters:
      width - Width of the window
      height - Height of the window
      listener - AckListener for the request
      Throws:
      DesktopException - if the window fails to resize
      See Also:
      AckListener, DesktopException
    • resizeBy

      public void resizeBy​(int deltaWidth, int deltaHeight, java.lang.String anchor) throws DesktopException
      Resizes the window by the specified amount
      Parameters:
      deltaWidth - Width delta of the window
      deltaHeight - Height delta of the window
      anchor - Specifies a corner to remain fixed during the resize. Please check resizeTo method for more information
      Throws:
      DesktopException - if the window fails to resize
      See Also:
      DesktopException
    • resizeBy

      public void resizeBy​(int deltaWidth, int deltaHeight, java.lang.String anchor, AckListener listener) throws DesktopException
      Resizes the window by the specified amount
      Parameters:
      deltaWidth - Width delta of the window
      deltaHeight - Height delta of the window
      anchor - Specifies a corner to remain fixed during the resize. Please check resizeTo method for more information
      listener - AckListener for the request
      Throws:
      DesktopException - if the window fails to resize
      See Also:
      AckListener, DesktopException
    • getState

      public void getState​(AckListener listener)
      Gets the current state ("minimized", "maximized", or "restored") of the window
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • bringToFront

      public void bringToFront​(AckListener listener)
      Brings the window to the front of the window stack
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • isShowing

      public void isShowing​(AckListener listener)
      Determines if the window is currently showing
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • getBounds

      public void getBounds​(AsyncCallback<WindowBounds> callback, AckListener listener)
      Gets the current bounds (top, left, width, height) of the window
      Parameters:
      callback - A function that is called if the method succeeds
      listener - A function that is called if the method fails
      See Also:
      AsyncCallback, AckListener
    • setBounds

      public void setBounds​(int left, int top, int width, int height, AckListener listener)
      Sets the current bounds (top, left, width, height) of the window
      Parameters:
      left - The left position of the window.
      top - The top position of the window.
      width - The width position of the window.
      height - The height position of the window.
      listener - AckListener for the request
      See Also:
      AckListener
    • bringToFront

      public void bringToFront() throws DesktopException
      Brings the window to the front of the window stack
      Throws:
      DesktopException - if the window fails to be brought to front
      See Also:
      DesktopException
    • updateOptions

      public void updateOptions​(WindowOptions options, AckListener listener)
      Changes a window's options that were defined upon creation
      Parameters:
      options - The window options to change
      listener - AckListener for the request
      See Also:
      WindowOptions, AckListener
    • getOptions

      public void getOptions​(AsyncCallback<WindowOptions> callback, AckListener listener)
      Returns the current options as stored in the desktop
      Parameters:
      callback - A function that is called if the method succeeds
      listener - A function that is called if the method fails
      See Also:
      AsyncCallback, AckListener
    • setAsForeground

      public void setAsForeground​(AckListener listener)
      Set's the window as the foreground window The window is activated(focused) and brought to front
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • enableFrame

      public void enableFrame​(AckListener listener)
      Allows a user from changing a window's size/position when using the window's frame
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • disableFrame

      public void disableFrame​(AckListener listener)
      Deprecated.
      use disableUserMovement() instead.
      Prevents a user from changing a window's size/position when using the window's frame
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • disableUserMovement

      public void disableUserMovement​(AckListener listener)
      Prevents a user from changing a window's size/position when using the window's frame
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • updateOptions

      public void updateOptions​(org.json.JSONObject options) throws DesktopException
      Changes a window's options that were defined upon creation
      Parameters:
      options - The window options to change
      Throws:
      DesktopException - if this method fails to update window options
    • getNativeId

      public void getNativeId​(AckListener listener)
      Gets HWND of the current window
      Parameters:
      listener - A function that is called if the method fails
      See Also:
      AsyncCallback, AckListener
    • wrap

      public static Window wrap​(java.lang.String applicationUuid, java.lang.String windowName, DesktopConnection connection)
      Attaches a Window object to an application Window that already exists
      Parameters:
      applicationUuid - UUID of the parent Application
      windowName - name of the Window
      connection - Connection object to the AppDesktop
      Returns:
      Window instance
    • joinGroup

      public void joinGroup​(Window window) throws DesktopException
      Joins the same window group as the specified window When windows are joined, if the user moves one of the windows, all other windows in the same group move too. This function is to be used when docking to other windows. If the window is already within a group, it will leave that group to join the new one. Windows must be owned by the same application in order to be joined.
      Parameters:
      window - The window whose group is to be joined
      Throws:
      DesktopException - if this window fails to join a group
    • joinGroup

      public void joinGroup​(Window window, AckListener listener)
      Joins the same window group as the specified window
      Parameters:
      window - The window whose group is to be joined
      listener - AckListener for the request
      See Also:
      AckListener
    • mergeGroups

      public void mergeGroups​(Window window) throws DesktopException
      Merges the instance's window group with the same window group as the specified window. When windows are joined, if the user moves one of the windows, all other windows in the same group move too. This function is to be used when docking to other windows. If the window is already within a group, The two groups are joined to create a new one. Windows must be owned by the same application in order to be joined.
      Parameters:
      window - The window whose group is to be merged
      Throws:
      DesktopException - if this window fails to merge into a group
      See Also:
      DesktopException
    • mergeGroups

      public void mergeGroups​(Window window, AckListener listener)
      Merges the instance's window group with the same window group as the specified window. When windows are joined, if the user moves one of the windows, all other windows in the same group move too. This function is to be used when docking to other windows. If the window is already within a group, The two groups are joined to create a new one. Windows must be owned by the same application in order to be joined.
      Parameters:
      window - The window whose group is to be merged
      listener - AckListener for the request
      See Also:
      AckListener
    • leaveGroup

      public void leaveGroup() throws DesktopException
      Leaves the current window group so that the window can be move independently of those in the group.
      Throws:
      DesktopException - if this window fails to leave a group
    • leaveGroup

      public void leaveGroup​(AckListener listener)
      Leaves the current window group so that the window can be move independently of those in the group.
      Parameters:
      listener - AckListener for the request
      See Also:
      AckListener
    • animate

      public void animate​(AnimationTransitions transitions, AnimationOptions options, AckListener listener)
      Performs the specified window transitions
      Parameters:
      transitions - Describes the animations to preform
      options - Options for the animation
      listener - AckListener for the request
      See Also:
      AnimationTransitions, AnimationOptions, AckListener
    • getGroup

      public void getGroup​(AsyncCallback<java.util.List<Window>> groupHandler, AckListener listener)
      Passes a list of wrapped windows in the same group 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.
      listener - AckListener for the request
      See Also:
      AsyncCallback, AckListener
    • addEventListener

      public void addEventListener​(java.lang.String type, EventListener listener, AckListener callback)
      Registers an event listener on the specified event. Supported window event types can be found at https://developer.openfin.co/docs/javascript/stable/tutorial-Window.EventEmitter.html.
      Parameters:
      type - Event type
      listener - Listener for the event
      callback - AckListener for the request
      See Also:
      EventListener, AckListener
    • removeEventListener

      public void removeEventListener​(java.lang.String type, EventListener listener, AckListener callback)
      Removes a previously registered event listener from the specified event
      Parameters:
      type - Event type
      listener - Listener for the event
      callback - AckListener for the request
      See Also:
      EventListener, AckListener
    • embedInto

      public void embedInto​(long parentHwndId, int width, int height, AckListener callback)
      Embeds a window in a target window
      Parameters:
      parentHwndId - This will be the parent window handle
      width - width of parent window
      height - height of parent window
      callback - AckListener for the request
      See Also:
      AckListener
    • embedInto

      public void embedInto​(long parentHwndId, int left, int top, int width, int height, AckListener callback)
      Embeds a window in a target window
      Parameters:
      parentHwndId - This will be the parent window handle
      left - The new position of the left side of the window.
      top - The new position of the top of the window.
      width - width of parent window
      height - height of parent window
      callback - AckListener for the request
      See Also:
      AckListener
    • executeJavaScript

      public void executeJavaScript​(java.lang.String code, AsyncCallback<java.lang.Object> callback, AckListener listener)
      Executes Javascript on the window, restricted to windows you own or windows owned by applications you have created.
      Parameters:
      code - JavaScript code to be executed on the window
      callback - A function that is called if the method succeeds
      listener - A function that is called if the method fails
      See Also:
      AsyncCallback, AckListener
    • showDeveloperTools

      public void showDeveloperTools​(AckListener listener)
      Shows window's developer tools
      Parameters:
      listener - A function that is called if the method fails
      See Also:
      AckListener
    • navigate

      public void navigate​(java.lang.String url, AckListener listener)
      Navigates the Widnow to the specified address
      Parameters:
      url - The URL that you want to navigate to
      listener - A function that is called if the method fails
      See Also:
      AckListener
    • navigateForward

      public void navigateForward​(AckListener listener)
      Navigates the window forward one page.
      Parameters:
      listener - A function that is called if the method fails
      See Also:
      AckListener
    • navigateBack

      public void navigateBack​(AckListener listener)
      Navigates the window back one page.
      Parameters:
      listener - A function that is called if the method fails
      See Also:
      AckListener
    • stopWindowNavigation

      public void stopWindowNavigation​(AckListener listener)
      Stops window navigation.
      Parameters:
      listener - A function that is called if the method fails
      See Also:
      AckListener
    • authenticate

      public void authenticate​(java.lang.String username, java.lang.String password, boolean cancel, AckListener listener)
      authenticate a user.
      Parameters:
      username - user name
      password - passwprd
      cancel - true to cancel the request
      listener - A function that is called if the method fails
    • getInfo

      public void getInfo​(java.lang.String code, AsyncCallback<org.json.JSONObject> callback, AckListener listener)
      Gets the window information
      Parameters:
      code - JavaScript code to be executed on the window
      callback - A function that is called if the method succeeds
      listener - A function that is called if the method fails
      See Also:
      AsyncCallback, AckListener
    • embedComponentSizeChange

      public void embedComponentSizeChange​(int width, int height)
      Update width and height of parent window for embedded window
      Parameters:
      width - width of parent window
      height - height of parent window
    • embedComponentSizeChange

      public void embedComponentSizeChange​(int left, int top, int width, int height)
      Update width and height of parent window for embedded window
      Parameters:
      left - The new position of the left side of the window.
      top - The new position of the top of the window.
      width - width of parent window
      height - height of parent window
    • getZoomLevel

      public void getZoomLevel​(AsyncCallback<java.lang.Double> callback, AckListener listener)
      Gets the current zoom level of the window
      Parameters:
      callback - A function that is called if the method succeeds
      listener - A function that is called if the method fails
      See Also:
      AsyncCallback, AckListener
    • setZoomLevel

      public void setZoomLevel​(double level, AckListener listener)
      Sets the zoom level of the window
      Parameters:
      level - The zoom level.
      listener - AckListener for the request
      See Also:
      AckListener
    • reload

      public void reload​(boolean ignoreCache, AckListener listener)
      Reloads the window current page
      Parameters:
      ignoreCache - Specifies if the cache should be ignored during page reload
      listener - AckListener for the request
      See Also:
      AckListener