Class: DialogManagerClient

Dialog Manager Client (Finsemble Flow)

The Dialog Manager Client simplifies interacting with dialog windows by spawning them and getting data back from them. In this context, a dialog window is simply a child window spawned to interact with the user, such as a confirmation dialog. Functions are provided here for both the parent-window side and the dialog/child-window side.

FSBL.Clients.DialogManager is always pre-initialized with one instance of the Dialog Manager in the Finsemble Library (making it essentially, a singleton when referenced in the same window). This means when developing Finsemble components, you directly access the Dialog Manager without using the constructor (e.g., FSBL.Clients.DialogManager.spawnDialog(...);). The constructor is not exposed to components.

Methods

checkIfWindowIsDialog
(cb)

Checks to see whether the window is a dialog.

Name Type Description
cb undefined | Type Literal optional

The callback to be invoked after the method completes successfully.

Name Type Description
N/A Type Literal

getParametersFromInDialog
()

Called from within dialog window to get the parameters passed in spawnDialog as "inputParams". For example, if your dialog has a configurable title, you would pass it in to spawnDialog, and retrieve the value using getParametersFromInDialog.

Example
var dialogData = FSBL.Clients.DialogManager.getParametersFromInDialog();

hideModal
()

Hides the dialog's modal.

open
(type, options, onUserInput)

Retrieves an available dialog. If none are found, one will be created with the options passed.

Resolves to an error string if the dialog could not be opened, or null if it was successfully opened.

Name Type Description
type string

Component type to open. The type must be a key in the finsemble.components configuration object.

options any

Options to pass into the opened window.

onUserInput StandardErrorCallback

registerDialogCallback
(cb)

Used by the window that is opening a dialog. This method sets up a query/responder that the opened dialog will invoke when the user has interacted with the dialog.

Name Type Description
cb StandardErrorCallback

registerModal
()

Registers this window as a modal with the global dialog management store and setting it up as a "scrim" - taking up the entire size of the monitor and being invisible or lightly opaque.

Sometimes, clicking anywhere on this window will dismiss the modal.

registerWithStore
(cb)

Registers the window as a dialog with the global store. If the component is incapable of being used as a dialog (this is set in the component's config), the callback is immediately invoked.

Note: This method will check to see whether the calling window is a dialog.

Name Type Description
cb undefined | Type Literal optional
Name Type Description
N/A Type Literal

respondAndExitFromInDialog
(responseParameters)

Called within the dialog window to pass back a dialog response. This results in the spawnDialog callback function (i.e., dialogResponseCallback) being invoked with responseParameters passed in.

Name Type Description
responseParameters any

The parameters returned to parent (i.e., window that spawned the dialog).

Example
FSBL.Clients.DialogManager.respondAndExitFromInDialog({ choice: response });

respondToOpener
(data)

Sends data back to the window that opened the dialog. Will hide the modal unless { hideModalOnClose: false } is passed in as the first argument.

Name Type Description
data any

Data desired to be handed back to the window that requested the dialog.

sendQueryToDialog
(identifier, options, onUserInput)

Function to initialize and open a dialog.

Name Type Description
identifier WindowIdentifier

An object that includes all the potential identifications for a window. For instance, one can try and obtain a reference for a window if some of these values are known.

Name Type Description
componentType optional

The type of component

uuid optional

Optional uuid of a particular application process

windowName string

The name of the physical HTML window, or a reference to a native window that was launched with Assimilation service

windowType optional
options any

Any data to send to the dialog for its initialization.

onUserInput StandardErrorCallback

showDialog
()

Broadcasts a message to the window that opened the dialog saying "I'm ready, please show me."

showModal
(cb)

Shows a semi-transparent black modal behind the dialog.

Name Type Description
cb undefined | Type Literal optional

The callback to be invoked after the method completes successfully.

Name Type Description
N/A Type Literal

spawnDialog
(params, inputParams, dialogResponseCallback, cb)

Spawns a dialog window.

parameters passed here in params.inputParams can be retrieved in the dialog window by calling getParametersFromInDialog.

Name Type Description
params SpawnParams

The parameters passed to Launcher.Spawn.

For properties duplicated between the top-level and `options`, `options` takes precedence.

Name Type Description
addToWorkspace optional

Defaults to false. Whether to add the new component to the workspace. The addToWorkspace config value set at the component level overwrites this value.

affinity optional

Set a process affinity flag. This allows windows to grouped together under a single process (a.k.a. Application). This flag is only available when your container is Electron.

alias optional

Used when windowType is "native" or "assimilation". Specifies the alias of a bundled asset.

arguments any optional

Used when windowType is "native" or "assimilation". Specifies the arguments to be sent to the application. This is used in conjunction with path. Arguments should be separated by spaces: `--arg1 foo --arg2 bar` except when `params.argumentsAsQueryString` is true, in which case set this parameter to be single string in URI format: `arg=1&arg=2`"

argumentsAsQueryString optional

For native applications launched by URI: 1) the string is passed as the "arguments" parameter if appended as a query string; and 2) the automatically generated arguments described in "path" are appended to the query string

bottom optional

A pixel value representing the distance from the top edge of the viewport as defined by "position". A percentage value may also be used, representing the percentage distance from the top edge of the viewport relative to the viewport's height.

canGroup optional

Whether the component can group with other windows.

claimMonitorSpace optional

For use with permanent toolbars. The available space for other components will be reduced by the amount of space covered by the newly spawned component. Users will be prevented from moving windows to a position that covers the claimed space.

closeComponentsTogether optional

Defaults to false. Whether to close all components within a composite component at the same time.

component any optional

Type of component to spawn.

data any optional

Optional data to pass to the opening window. If set, then the spawned window can use WindowClient#getSpawnData to retrieve the data.

dockOnSpawn optional

If true, will automatically dock the window with the "relative" window (dock to the parent window unless specified in params.relativeWindow). Note that you must also position the window in a valid position for docking, for example, by setting the "left" or "top" parameters to "adjacent".

dockable optional

An array of parts of the monitor that the component can dock to. Valid values are `top` and `bottom`.

docked optional

Which part of the monitor that the component will dock to on spawn. Valid options are `top` and `bottom`. Only valid if combined with the `dockable` property.

dockedHeight optional

Currently, components can only dock to the full width of the monitor. This parameter determines what height the component will be when docked to a monitor.

env any optional

Sets environment variables for a spawned native application. Create a map (JSON) object of names to values. This is only available when running Assimilation.

ephemeral optional

Indicates that this window is ephemeral. An ephemeral window is a dialog, menu, or other window that is temporarily displayed but usually hidden. Ephemeral windows automatically have the following settings assigned: resizable: false, showTaskbarIcon: false, alwaysOnTop: true. Note: Use `options:{autoShow: false}` to prevent an ephemeral widow from showing automatically.

forceOntoMonitor optional

If true, will attempt to make the window have no edges outside the monitor boundary.

groupName optional

Optional group name. Adds windows to a group (unrelated to docking or linking) that is used for window management functions. If the group does not exist it will be created.

groupOnSpawn optional

Groups the window to the `relativeWindow` based on their adjacent position.

height optional

A pixel or percentage value.

launchingWindow any optional

Where the spawn request is coming from.

left optional

A pixel value representing the distance from the left edge of the viewport as defined by "position". A percentage value may also be used, representing the percentage distance from the left edge of the viewport relative to the viewport's width.

"adjacent" will snap to the right edge of the spawning or relative window.

"center" will center the window

If neither left nor right are provided, then the default will be to stagger the window based on the last spawned window.

maxHeight optional

Maximum height window can be resized to.

maxWidth optional

Maximum width window can be resized to.

minHeight optional

Minimum height window can be resized to.

minWidth optional

Minimum width window can be resized to.

monitor optional

Which monitor to place the new window.

"mine" - Place the window on the same monitor as the calling window.

Integer value from 0-n (0 being the primary monitor).

"primary" indicates the user's primary monitor.

"all" - Put a copy of the component on all monitors.

name optional

Name to give the component. If not provided, a random one will be generated.

native optional
options any optional

Properties to merge with the default windowDescriptor. Any value set here will be sent directly to the WebWindow, and will override the effect of relevant parameters to spawn(). By default, all Finsemble windows are frameless. FEA Permissions and window properties (such as always on top) are provided here.

path optional

Used when windowType is "native" or "assimilation". Specifies the path to the application. The path can be: The name of an exe that is on the system path (e.g., notepad.exe). The full path to an executable on the user's machine (e.g., C:\Program Files\app.exe). A system installed URI (e.g., myuri://advancedapplauncher).

When windowType is "native" then additional arguments will be automatically appended to the path or the URI. These arguments can be captured by the native application in order to tie it to Finsemble's window tracking. When building an application with finsemble.dll, this is handled automatically. Those arguments are:

uuid - A generated UUID that uniquely identifies this window.

left - The x coordinate of the new window

top - The y coordinate of the new window

width - The width of the new window

height - The height of the new window

finsembleWindowName - The name of the window in the Finsemble config

componentType - The component type in the Finsemble config

A common troublesome problem is when a native application needs to be launched from an intermediary application (such as a launcher or batch script). That intermediary application can pass these parameters which will allow the final application to connect back to Finsemble.

position PositionTypes optional

Defines a "viewport" for the spawn, with one of the Position Types:

available - Positioned according to the coordinates available on the monitor itself, less space claimed by the operating system (such as the windows toolbar). For instance, `bottom:0` will place the new component with its bottom flush against the windows toolbar.

monitor - Positioned according to the absolute size of the monitor. For instance, top:0 will place the component overlapping the toolbar.

relative - Positioned relative to the relativeWindow. For instance, left:0;top:0 will join the top left corner of the new component with the top left corner of the relative window.

virtual - Deprecated. Positioned against coordinates on the virtual screen. The virtual screen is the full viewing area of all monitors combined into a single theoretical monitor.

absolute - Positioned using native operating system coordinates. Only available with showWindow, not with spawn.

relativeWindow identifier optional

The window to use when calculating any relative launches. If not set then the window from which spawn() was called.

right optional

A pixel value representing the distance from the right edge of the viewport as defined by "position". A percentage value may also be used, representing the percentage distance from the right edge of the viewport relative to the viewport's width.

setBoundsOnly optional

If true, then visibility of window will not be changed. In otherwords, a hidden window will not be made visible.

slave optional

If true then the new window will act as a slave to the relativeWindow (or the launching window if relativeWindow is not specified). Slave windows will automatically close when their parent windows close.

spawnIfNotFound optional

If the component type isn't running then spawn it

spawnedByWorkspaceService optional
staggerPixels optional

Number of pixels to stagger (default when neither left, right, top or bottom are set).

toSpawn optional

An array of objects defining the components to spawn. Each entry may either represent a single component in the form `{componentType, spawnOptions}` or a tabbed window of components in the form `{components, spawnOptions}`, where `components` is an array of single component definitions (again in the form `{componentType, spawnOptions}`). Most arguments that are normally passed to `LauncherClient.spawn` are supported, although positioning will be interpreted as relative to the group's coordinates and dimensions for single components and ignored for tabbed components (as these use the position specified in the group's spawnOptions). Note - This param will only be taken into account if the {@see windowType} param is 'composite'.

top optional

A pixel value representing the distance from the right edge of the viewport as defined by "position". A percentage value may also be used, representing the percentage distance from the bottom edge of the viewport relative to the viewport's width.

url optional

Optional url to launch. Overrides what is passed in "component".

width optional

A pixel or percentage value.

windowIdentifier identifier optional

Component instances are often referred to in Finsemble API calls via a windowIdentifier. A windowIdentifier is an object with both windowName and componentType properties.

windowType WindowTypes optional

Optional. Describes which type of component to spawn.

WebWindow - A normal HTML window.

assimilation - A window that is managed by the Finsemble assimilation process (usually a native window without source code access). Requires "path" to be specified, which may be the name of an executable on the system path, a system file path or system installed URI.

native - A native window that has implemented finsemble.dll. Requires "path" to be specified.

application - A standalone application that will be launched in its own browser process (giving it dedicated CPU and memory). This can also point to a standalone web application (such as from a third party).

composite - A component made of other components, usually group together. See {@see toSpawn} property.

inputParams any

Object or any data type needed by your dialog.

dialogResponseCallback StandardErrorCallback
cb StandardErrorCallback
Example
FSBL.Clients.DialogManager.spawnDialog(
{
	name: "dialogTemplate",
	height:300,
	width:400,
	url:"http://localhost/components/system/dialogs/dialog1.html"
},
{
	someData: 12345
},
(error, responseParameters) => {
	if (!error) {
		console.log(">>>> spawnDialog response: " + JSON.stringify(responseParameters));
	}
});