Class: LauncherClient
Launcher Client (Finsemble Workspaces)
The Launcher Client handles spawning windows of all kinds. Finsemble provides the architecture to launch, resize, and reposition any component, whether native, modern, or third-party.
The Launcher API has capabilities to customize your end user's experience. This includes CSS-like positioning and a fully display-aware positioning that deals with idiosyncrasies such as monitors with different scaling resolutions.
CSS provides higher level abstractions that aid in laying out an application that is composed of constituent parts.
Finsemble has borrowed CSS’s positioning paradigm and applied it to the task of laying out windows on the desktop.
This CSS-style positioning allows windows to be positioned on the left
, right
, top
, or bottom
of the end user’s screen for instance; we also developed new positions, such as adjacent
, which allows a child window to spawn adjacent to their parent.
Components can be positioned and sized by percentage, relative to the monitor or to each other (nested windows).
The Launcher Client frequently uses the parameters windowName
and componentType
. Learn more about them here.
Methods
-
getActiveDescriptors(cb)
-
Gets the windowDescriptor for all open windows.
Note: This returns descriptors even if the window is not part of the workspace.
Name Type Description cb
StandardErrorCallback optional Callback returns an object containing windowDescriptors keyed by name.
Example
FSBL.Clients.LauncherClient.getActiveDescriptors(function (error, response) { if (error) { Logger.system.error("Error getting active descriptors: ", + JSON.stringify(error)); } else { const activeDescriptors = response; //{ // ... // Toolbar-1-Finsemble: {...}, // Welcome-Component-80-6453-Finsemble: {...}, // ... //} } });
-
getComponentDefaultConfig(componentType, cb)
-
Get the component config (from components.json) for a specific component.
Name Type Description componentType
string The type of the component.
cb
StandardErrorCallback optional Callback returns the default config (windowDescriptor) for the requested componentType.
-
getComponentList(cb)
-
Get a list of registered components (those that were entered into components.json).
Name Type Description cb
StandardErrorCallback optional Callback returns an object map of components. Each component object contains the default config for that component.
-
getComponentsThatCanReceiveDataTypes(params, cb)
-
Name Type Description params
Name Type Description dataTypes
string[] An array of data types. Looks for components that can receive those data types.
cb
Function The callback to be invoked after the method completes successfully.
Example
FSBL.Client.LauncherClient.getComponentsThatCanReceiveDataTypes({ dataTypes: ['chartiq.chart', 'salesforce.contact']}, function(err, response) { //Response contains: {'chartiq.chart': ['Advanced Chart'], 'salesforce.contact': ['Salesforce Contact']} })
-
getMonitorInfo(params, cb)
-
Gets monitor information for a given windowIdentifier or for a specific monitor. If neither the identifier or monitor are provided then the monitorInfo for the current window is returned.
The information returned contains:
monitorRect - The full dimensions for the monitor.
availableRect - The dimensions for the available space on the monitor (less the Windows task bar).
position - The position of the monitor, numerically from zero to X. Primary monitor is zero.
whichMonitor - Contains the string "primary" if it is the primary monitor.The dimensions are supplemented with the following additional members:
width - The width as calculated (right - left).
height - The height as calculated (bottom - top).Name Type Description params
Name Type Description monitor
MonitorCommand optional If passed then a specific monitor is identified. Valid values include:
"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.
windowIdentifier
identifier optional The windowIdentifier to get the monitorInfo. If undefined, then the current window.
cb
StandardErrorCallback optional Returns a monitorInfo object containing the monitorRect and availableRect.
-
getMonitorInfoAll(cb)
-
Gets monitorInfo (dimensions and position) for all monitors. Returns an array of monitorInfo objects. See LauncherClient#getMonitorInfo for the format of a monitorInfo object.
Name Type Description cb
StandardErrorCallback optional Returns an array of monitorInfo objects.
-
getMyWindowIdentifier(cb)
-
Returns a windowIdentifier for the current window.
Name Type Description cb
undefined | Type Literal optional Callback function returns windowIdentifier for this window (optional or use the returned Promise)
Name Type Description N/A
Type Literal -
registerComponent(params, cb)
-
Dynamically registers a component with the Launcher Service for the current Finsemble session. This method registers a given component in a component manifest, making it available to an app launcher component. Note: Components registered in this way are removed at the end of Finsemble's current session.
Name Type Description params
Name Type Description componentType
string The key of the component in the component's config.
manifest
ComponentDescriptor This should be a component manifest, i.e., a component configuration file like components.json.
cb
StandardErrorCallback The callback to be invoked after the method completes successfully.
-
showWindow(windowLocator, params, cb)
-
Displays a window and relocates/resizes it according to the values contained in parameters. If the specified window is in a group or tabbed, it will be unsnapped/ungrouped/untabbed from the other windows. If invoked on a tabbed window or a window in a group, the window will be removed from the tab/group.
Caution: A window can inherit parameters only once, at the time when it’s spawned. When the component already exists, changing parameters other than positioning arguments (monitor, relativeWindow, top, bottom, left, right, width, height) has no effect.
Name Type Description windowLocator
Type Literal | Type Literal Name Type Description N/A
Type Literal Name Type Description windowName
string The name of the physical HTML window, or a reference to a native window that was launched with Assimilation service
N/A
Type Literal Name Type Description componentType
string The type of component
uuid
Optional uuid of a particular application process
params
ShowWindowParams Configuration settings from the finsemble.appd[].manifest.window section of the application manifest may be used as parameters to this function, except for the `options` element. These are the same as
LauncherClient#spawn
with the following exceptions:- monitor - Same as spawn() except that null or undefined means don't move the window to a different monitor.
- left - Same as spawn() except that null or undefined means don't move the window from current horizontal location.
- top - Same as spawn() except that null or undefined means don't move the window from current vertical location.
- slave - Cannot be set for an existing window. Will only go into effect if the window is spawned. (In other words, only use this in conjunction with spawnIfNotFound).
- spawnIfNotFound - If true, then spawns a new window if the requested one cannot be found. Note: only works if the windowIdentifier contains a componentType.
- autoFocus - Whether or not the window should be focused when shown.
cb
StandardErrorCallback optional Callback to be invoked after the function is completed regardless if the call fails or succeeds. Callback contains two arguments in the following order.
- error: an object containing details related to the reason the call failed and where the exception occurred. This object will be null if the call has succeeded.
- data: an object with the following information:
- windowIdentifier - The WindowIdentifier for the new window.
- windowDescriptor - The WindowDescriptor of the new window.
- finWindow - A
finWindow
object referencing the new window.
Example
FSBL.Clients.LauncherClient.showWindow({windowName: "Welcome Component-86-3416-Finsemble", componentType: "Welcome Component"}, {spawnIfNotFound: true}, (err, data)=> {});
-
spawn(component, params, cb)
-
Asks the Launcher service to spawn a new component. Any parameter below can also be specified in public/config/components.json, which will then operate as the default for that value.
The launcher parameters mimic CSS window positioning. For instance, to set a full screen window use `{left: 0, top: 0, right: 0, bottom: 0}`. This is functionally equivalent to: `{left: 0, top: 0, width: "100%", height: "100%"}`.
You can also spawn more than one component at a time by using a single action, such as clicking a button on a menu. See https://github.com/ChartIQ/finsemble-seed/tree/recipes/SpawnComponentGroup for an example of spawning a component group.
Name Type Description component
string The application or component to spawn.
params
SpawnParams Configuration settings from the finsemble.appd[].manifest.window section of the application manifest may be used as parameters to this function, except for the `options` element.
cb
StandardErrorCallback optional Function invoked after the window is created
Example
FSBL.Clients.LauncherClient.spawn("Welcome Component", {left: 0, top: 0, position: "relative"}, (err, data)=> {});
-
toggleWindowOnClick(element, windowLocator, params)
-
A convenient method for dealing with a common use-case, which is toggling the appearance and disappearance of a child window when a button is pressed, aka drop down menus. Call this method from the click handler for your element. Your child window will need to close itself on blur events. Caution: A window can inherit parameters only once, at the time when it’s spawned. When the component already exists, changing parameters other than positioning arguments (monitor, relativeWindow, top, bottom, left, right, width, height) has no effect.
Name Type Description element
HTMLElement The DOM element, or selector, clicked by the end user.
windowLocator
Type Literal | Type Literal Name Type Description N/A
Type Literal Name Type Description windowName
string The name of the physical HTML window, or a reference to a native window that was launched with Assimilation service
N/A
Type Literal Name Type Description componentType
string The type of component
uuid
Optional uuid of a particular application process
params
ShowWindowParams Parameters to be passed to
LauncherClient#showWindow
if the child window is allowed to open -
unRegisterComponent(params, cb)
-
Unregisters a component with the Launcher Service.
Name Type Description params
Name Type Description componentType
string The key of the component in the component's config.
cb
StandardErrorCallback optional