Package com.smartgwt.client.browser.window

# Class MultiWindow

java.lang.Object
com.smartgwt.client.browser.window.MultiWindow

public class MultiWindow extends Object
Note: this is currently an experimental feature and not covered by normal support guarantees. See `Experimental Features` for more information.
Provides tracking of other Smart GWT browser windows opened by the original window, as `RemoteWindows`.

Includes APIs for:

- Registering event listeners for events on other windows
- Opening a new window and finding a window by name
- Moving, activating, or deactiving a window by name
- Sharing DataSources and their caches between Smart GWT windows
- Sharing `Messaging` channels between Smart GWT windows

Within the OpenFin environment, the underlying implementation is actually via the OpenFin class.

Reloading of child windows is in general supported (but see `autoCopyDataSources`), while reloading the `main window` currently is not.

See Also:
  - `Experimental Features`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MultiWindow()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `activate(String name)`
  Activates (focuses) the existing window with the specified name,
  `static void`
  `activate(String name, RemoteWindowCallback callback)`
  Activates (focuses) the existing window with the specified name,
  `static void`
  `bringToFront(String name)`
  Brings the existing window with the specified name to the top of the window stack.
  `static void`
  `bringToFront(String name, RemoteWindowCallback callback)`
  Brings the existing window with the specified name to the top of the window stack.
  `static void`
  `clearEvent(MultiWindowEvent eventType)`
  Unregisters a previously registered window event listener.
  `static void`
  `clearEvent(MultiWindowEvent eventType, int ID)`
  Unregisters a previously registered window event listener.
  `static void`
  `close(String name)`
  Closes the existing window with the specified name,
  `static void`
  `close(String name, boolean force)`
  `static void`
  `close(String name, boolean force, RemoteWindowCallback callback)`
  Closes the existing window with the specified name,
  `static void`
  `deactivate(String name)`
  Deactivates (blurs) the existing window with the specified name,
  `static void`
  `deactivate(String name, RemoteWindowCallback callback)`
  Deactivates (blurs) the existing window with the specified name,
  `static RemoteWindow`
  `find(String name)`
  Returns window with the specified name, if it exists in the application.
  `static Boolean`
  `getAutoCopyDataSources()`
  Should `DataSources` from other OpenFin windows with Smart GWT loaded be copied by reference into this window? Such DataSources will be copied: when a page in another window is loaded (potentially several DataSources at once) at the moment DataSources are created in a page loaded in another window (just that DataSource)
  `static DataContext`
  `getDataContext()`
  Returns the `DataContext` provided by the `open()` call that opened this window, or a newly created (on demand) `DataContext` if this is the main application window, or no DataContext was provided.
  `static RemoteWindow`
  `getLocalWindow()`
  Returns the `RemoteWindow` instance for the current window (where the method was called).
  `static RemoteWindow[]`
  `getOtherWindows()`
  Returns a list of `RemoteWindow` for the other currently known windows (excluding the `local window`).
  `static RemoteWindow`
  `getParentWindow()`
  Returns the parent `RemoteWindow` instance that opened this window.
  `static Boolean`
  `getShareMessageChannels()`
  Should this window share `Realtime Messaging` channels with other windows?
  `static void`
  `hide(String name)`
  Hides the existing window with the specified name,
  `static void`
  `hide(String name, RemoteWindowCallback callback)`
  Hides the existing window with the specified name,
  `static boolean`
  `isMainWindow()`
  Returns whether this `RemoteWindow` wraps the main application window.
  `static void`
  `isShowing(String name, RemoteWindowBooleanCallback callback)`
  Checks whether a window with the specified name is showing.
  `static void`
  `maximize(String name)`
  Maximizes the existing window with the specified name,
  `static void`
  `maximize(String name, RemoteWindowCallback callback)`
  Maximizes the existing window with the specified name,
  `static void`
  `minimize(String name)`
  Minimizes the existing window with the specified name,
  `static void`
  `minimize(String name, RemoteWindowCallback callback)`
  Minimizes the existing window with the specified name,
  `static void`
  `move(String name, int x, int y)`
  Moves the existing window with the specified name,
  `static void`
  `move(String name, int x, int y, RemoteWindowCallback callback)`
  Moves the existing window with the specified name,
  `static void`
  `open(String url, String name)`
  Opens a new window with the specified URL, name, and `DataContext`.
  `static void`
  `open(String url, String name, DataContext dataContext)`
  `static void`
  `open(String url, String name, DataContext dataContext, RemoteWindowBooleanCallback callback)`
  `static void`
  `open(String url, String name, DataContext dataContext, RemoteWindowBooleanCallback callback, BrowserWindowSettings windowSettings)`
  `static void`
  `open(String url, String name, DataContext dataContext, RemoteWindowBooleanCallback callback, BrowserWindowSettings windowSettings, MultiWindowSettings classSettings)`
  Opens a new window with the specified URL, name, and `DataContext`.
  `static void`
  `resize(String name, int width, int height)`
  Resizes e existing window with the specified name,
  `static void`
  `resize(String name, int width, int height, RemoteWindowCallback callback)`
  Resizes e existing window with the specified name,
  `static void`
  `restore(String name)`
  Restores the existing window with the specified name,
  `static void`
  `restore(String name, RemoteWindowCallback callback)`
  Restores the existing window with the specified name,
  `static void`
  `setAutoCopyDataSources(Boolean autoCopyDataSources)`
  Should `DataSources` from other OpenFin windows with Smart GWT loaded be copied by reference into this window? Such DataSources will be copied: when a page in another window is loaded (potentially several DataSources at once) at the moment DataSources are created in a page loaded in another window (just that DataSource)
  `static int`
  `setEvent(MultiWindowEvent eventType, MultiWindowEventCallback listener)`
  Registers a window event listener to be called whenever the event type occurs for any window in the application.
  `static void`
  `setShareMessageChannels(Boolean shareMessageChannels)`
  Should this window share `Realtime Messaging` channels with other windows?
  `static void`
  `show(String name)`
  Shows the existing window with the specified name,
  `static void`
  `show(String name, RemoteWindowCallback callback)`
  Shows the existing window with the specified name,

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MultiWindow

    public MultiWindow()

- ## Method Details

  - ### setAutoCopyDataSources

    public static void setAutoCopyDataSources(Boolean autoCopyDataSources)
    Should `DataSources` from other OpenFin windows with Smart GWT loaded be copied by reference into this window? Such DataSources will be copied:
    - when a page in another window is loaded (potentially several DataSources at once)
    - at the moment DataSources are created in a page loaded in another window (just that DataSource)

    This property will default to true if OpenFin is present; otherwise, false.

    Note that reloading a page that created DataSources copied by reference into other windows (via this property) is not supported.

    Parameters:
      `autoCopyDataSources` - new autoCopyDataSources. Default value is varies.

  - ### getAutoCopyDataSources

    public static Boolean getAutoCopyDataSources()
    Should `DataSources` from other OpenFin windows with Smart GWT loaded be copied by reference into this window? Such DataSources will be copied:
    - when a page in another window is loaded (potentially several DataSources at once)
    - at the moment DataSources are created in a page loaded in another window (just that DataSource)

    This property will default to true if OpenFin is present; otherwise, false.

    Note that reloading a page that created DataSources copied by reference into other windows (via this property) is not supported.

    Returns:
      current value of autoCopyDataSources

  - ### setShareMessageChannels

    public static void setShareMessageChannels(Boolean shareMessageChannels)
    Should this window share `Realtime Messaging` channels with other windows?

    This property will default to true if OpenFin is present; otherwise, false.

    Parameters:
      `shareMessageChannels` - new shareMessageChannels. Default value is varies.

  - ### getShareMessageChannels

    public static Boolean getShareMessageChannels()
    Should this window share `Realtime Messaging` channels with other windows?

    This property will default to true if OpenFin is present; otherwise, false.

    Returns:
      current value of shareMessageChannels

  - ### activate

    public static void activate(String name)
    Activates (focuses) the existing window with the specified name,
    Parameters:
      `name` - unique window name

  - ### activate

    public static void activate(String name, RemoteWindowCallback callback)
    Activates (focuses) the existing window with the specified name,
    Parameters:
      `name` - unique window name
      `callback` - callback run after `RemoteWindow` activated

  - ### bringToFront

    public static void bringToFront(String name)
    Brings the existing window with the specified name to the top of the window stack.
    Parameters:
      `name` - unique window name

  - ### bringToFront

    public static void bringToFront(String name, RemoteWindowCallback callback)
    Brings the existing window with the specified name to the top of the window stack.
    Parameters:
      `name` - unique window name
      `callback` - callback run after `RemoteWindow` is brought to the front

  - ### clearEvent

    public static void clearEvent(MultiWindowEvent eventType)
    Unregisters a previously registered window event listener. The event type and ID returned by the original `setEvent()` call should be passed.
    Parameters:
      `eventType` - event type to register
    See Also:
      - `setEvent(com.smartgwt.client.types.MultiWindowEvent, com.smartgwt.client.browser.window.MultiWindowEventCallback)`

  - ### clearEvent

    public static void clearEvent(MultiWindowEvent eventType, int ID)
    Unregisters a previously registered window event listener. The event type and ID returned by the original `setEvent()` call should be passed.
    Parameters:
      `eventType` - event type to register
      `ID` - ID of the event to clear. If not specified, all events of eventType will be cleared.
    See Also:
      - `setEvent(com.smartgwt.client.types.MultiWindowEvent, com.smartgwt.client.browser.window.MultiWindowEventCallback)`

  - ### close

    public static void close(String name)
    Closes the existing window with the specified name,
    Parameters:
      `name` - unique window name

  - ### close

    public static void close(String name, boolean force)
    See Also:
      - `close(java.lang.String)`

  - ### close

    public static void close(String name, boolean force, RemoteWindowCallback callback)
    Closes the existing window with the specified name,
    Parameters:
      `name` - unique window name
      `force` - whether to force it closed
      `callback` - callback run after `RemoteWindow` closed

  - ### deactivate

    public static void deactivate(String name)
    Deactivates (blurs) the existing window with the specified name,
    Parameters:
      `name` - unique window name

  - ### deactivate

    public static void deactivate(String name, RemoteWindowCallback callback)
    Deactivates (blurs) the existing window with the specified name,
    Parameters:
      `name` - unique window name
      `callback` - callback run after `RemoteWindow` deactivated

  - ### find

    public static RemoteWindow find(String name)
    Returns window with the specified name, if it exists in the application. Note that, without OpenFin, only windows created with `open()` (and the base window) can be found with this method.
    Parameters:
      `name` - unique window name
    Returns:
      requested window

  - ### getDataContext

    public static DataContext getDataContext()
    Returns the `DataContext` provided by the `open()` call that opened this window, or a newly created (on demand) `DataContext` if this is the main application window, or no DataContext was provided.
    Returns:
      `DataContext` for this window

  - ### getLocalWindow

    public static RemoteWindow getLocalWindow()
    Returns the `RemoteWindow` instance for the current window (where the method was called).
    Returns:
      instance wrapping the current window

  - ### getOtherWindows

    public static RemoteWindow[] getOtherWindows()
    Returns a list of `RemoteWindow` for the other currently known windows (excluding the `local window`). This would typically only be used to initialize logic dependent on other windows. You'd want to add a handler for the {@link package com.smartgwt.client.browser.window.events.OtherWindowsChangedEvent}. to ensure you keep things updated as windows are opened or closed.
    Returns:
      current set of other RemoteWindows.

  - ### getParentWindow

    public static RemoteWindow getParentWindow()
    Returns the parent `RemoteWindow` instance that opened this window.
    Returns:
      instance wrapping the parent window or null

  - ### hide

    public static void hide(String name)
    Hides the existing window with the specified name,
    Parameters:
      `name` - unique window name

  - ### hide

    public static void hide(String name, RemoteWindowCallback callback)
    Hides the existing window with the specified name,
    Parameters:
      `name` - unique window name
      `callback` - callback run after `RemoteWindow` hidden

  - ### isMainWindow

    public static boolean isMainWindow()
    Returns whether this `RemoteWindow` wraps the main application window.
    Returns:
      whether this instance wraps the main application window

  - ### isShowing

    public static void isShowing(String name, RemoteWindowBooleanCallback callback)
    Checks whether a window with the specified name is showing. Callback returns null if the window cannot be found; otherwise returns true or false according as it's showing.
    Parameters:
      `name` - unique window name
      `callback` - callback to receive output

  - ### maximize

    public static void maximize(String name)
    Maximizes the existing window with the specified name,
    Parameters:
      `name` - unique window name

  - ### maximize

    public static void maximize(String name, RemoteWindowCallback callback)
    Maximizes the existing window with the specified name,
    Parameters:
      `name` - unique window name
      `callback` - callback run after `RemoteWindow` maximized

  - ### minimize

    public static void minimize(String name)
    Minimizes the existing window with the specified name,
    Parameters:
      `name` - unique window name

  - ### minimize

    public static void minimize(String name, RemoteWindowCallback callback)
    Minimizes the existing window with the specified name,
    Parameters:
      `name` - unique window name
      `callback` - callback run after `RemoteWindow` minimized

  - ### move

    public static void move(String name, int x, int y)
    Moves the existing window with the specified name,
    Parameters:
      `name` - unique window name
      `x` - desired x-offset of left edge
      `y` - desired y-offset of top edge

  - ### move

    public static void move(String name, int x, int y, RemoteWindowCallback callback)
    Moves the existing window with the specified name,
    Parameters:
      `name` - unique window name
      `x` - desired x-offset of left edge
      `y` - desired y-offset of top edge
      `callback` - callback run after `RemoteWindow` moved

  - ### open

    public static void open(String url, String name)
    Opens a new window with the specified URL, name, and `DataContext`.

    Note that if the provided window name already exists, that window will just be `activated`, and though the callback will be run, the supplied url, dataContext, windowSettings, and classSettings will be ignored.

    Support for passing POJOs (Java Object references) to the child window in the `DataContext` via APIs such as `DataContext.setSharedJavaObject()` is "super experimental" (beyond the feature itself, which is experimental).

    Parameters:
      `url` - url to open in the window or null to reuse the current url. See `URL`
      `name` - unique window name to open as a new window

  - ### open

    public static void open(String url, String name, DataContext dataContext)
    See Also:
      - `open(java.lang.String, java.lang.String)`

  - ### open

    public static void open(String url, String name, DataContext dataContext, RemoteWindowBooleanCallback callback)
    See Also:
      - `open(java.lang.String, java.lang.String)`

  - ### open

    public static void open(String url, String name, DataContext dataContext, RemoteWindowBooleanCallback callback, BrowserWindowSettings windowSettings)
    See Also:
      - `open(java.lang.String, java.lang.String)`

  - ### open

    public static void open(String url, String name, DataContext dataContext, RemoteWindowBooleanCallback callback, BrowserWindowSettings windowSettings, MultiWindowSettings classSettings)
    Opens a new window with the specified URL, name, and `DataContext`.

    Note that if the provided window name already exists, that window will just be `activated`, and though the callback will be run, the supplied url, dataContext, windowSettings, and classSettings will be ignored.

    Support for passing POJOs (Java Object references) to the child window in the `DataContext` via APIs such as `DataContext.setSharedJavaObject()` is "super experimental" (beyond the feature itself, which is experimental).

    Parameters:
      `url` - url to open in the window or null to reuse the current url. See `URL`
      `name` - unique window name to open as a new window
      `dataContext` - dataContext to apply to window
      `callback` - callback run after `RemoteWindow` created or activated (parameter true if created)
      `windowSettings` - settings applied to child browser window
      `classSettings` - settings for child `MultiWindow` class

  - ### resize

    public static void resize(String name, int width, int height)
    Resizes e existing window with the specified name,
    Parameters:
      `name` - unique window name
      `width` - desired new width
      `height` - desired new height

  - ### resize

    public static void resize(String name, int width, int height, RemoteWindowCallback callback)
    Resizes e existing window with the specified name,
    Parameters:
      `name` - unique window name
      `width` - desired new width
      `height` - desired new height
      `callback` - callback run after `RemoteWindow` moved

  - ### restore

    public static void restore(String name)
    Restores the existing window with the specified name,
    Parameters:
      `name` - unique window name

  - ### restore

    public static void restore(String name, RemoteWindowCallback callback)
    Restores the existing window with the specified name,
    Parameters:
      `name` - unique window name
      `callback` - callback run after `RemoteWindow` restored

  - ### setEvent

    public static int setEvent(MultiWindowEvent eventType, MultiWindowEventCallback listener)
    Registers a window event listener to be called whenever the event type occurs for any window in the application.
    Parameters:
      `eventType` - event type to register
      `listener` - function to be called when event fires
    Returns:
      ID number of this event, may be used to remove the event
    See Also:
      - `clearEvent(com.smartgwt.client.types.MultiWindowEvent)`

  - ### show

    public static void show(String name)
    Shows the existing window with the specified name,
    Parameters:
      `name` - unique window name

  - ### show

    public static void show(String name, RemoteWindowCallback callback)
    Shows the existing window with the specified name,
    Parameters:
      `name` - unique window name
      `callback` - callback run after `RemoteWindow` shown