Class: WindowClient

Window Client

The Window Client is primarily responsible for managing the windowState (the window's bounds) and componentState (data inside of your component). It also injects the window title bar control, which contains controls for minimizing, maximizing, closing, and restoring your window. The reference below is provided in case you'd like to manually trigger events.

This is the Window Client API reference. If you're looking for information about the window title bar, please see the Presentation Component tutorial for more information.

new WindowClient
(params){WindowClient}
clients/windowClient.js, line 81

Name Type Description
params object
Returns:
Type Description
WindowClient

Members

optionsobject

A copy of the finWindow's options value. This is where we store information like monitorDimensions, initialization information, and any other data that needs to be passed from the parent application into the created window.

Methods

bringWindowToFront
()
clients/windowClient.js, line 915

Forces window to sit on top of other windows.

Example
FSBL.Clients.WindowClient.bringWindowToFront();

cancelTilingOrTabbing
(params, cb)
clients/windowClient.js, line 1282

Name Type Description
params *

put windowIdentifier in params.windowIdentifier. If not provided, must set params.waitForIdentifier true

cb *

fitToDOM
(params, cb)
clients/windowClient.js, line 1411

Automatically resizes the height of the window to fit the full DOM of the current window..

Name Type Description
params object optional
Name Type Description
padding object optional
Name Type Description
height number optional
width number optional
cb function optional

Optional callback when complete

getBounds
(cb)
clients/windowClient.js, line 1261

Returns the bounds for the current window.

Name Type Description
cb function

getComponentState
(params, cb)
clients/windowClient.js, line 626

Given a field, this function retrieves app state. If no params are given you get the full state

Name Type Description
params object
Name Type Description
field string optional

field

fields Array.<string> optional

fields

cb function

Callback

Example

The example below shows how we retrieve data to restore the layout in our charts.

FSBL.Clients.WindowClient.getComponentState({
	 field: 'myChartLayout',
}, function (err, state) {
	if (state === null) {
		return;
	}
	importLayout(state);
});
FSBL.Clients.WindowClient.getComponentState({
	 fields: ['myChartLayout', 'chartType'],
}, function (err, state) {
	if (state === null) {
		return;
	}
	var chartType = state['chartType'];
 var myChartLayout = state['myChartLayout'];
});

getCurrentWindow
(){finWindow}
clients/windowClient.js, line 1180

Returns a reference to the current window for the component. For most components this will just return the finWindow, but for a compound component it will return a CompoundWindow.

Returns:
Type Description
finWindow

getSpawnData
(){object}
clients/windowClient.js, line 1167

Retrieves data that was set with LauncherClient#spawn.

Returns:
Type Description
object The data or empty object if no data was set. Note, this will never return null or undefined.

getStackedWindow
(params, cb)
clients/windowClient.js, line 1360

Gets the stackedWindow (if this window is a child of a stacked window).

If no stacked window then returns null. But if null and params.create is set, then the stacked window will be automatically created and this window added as the first child.

(Typically used by Tabbing Presentation component to manage tabs.)

Name Type Description
params object optional
Name Type Description
create array optional

if true and StackedWindow isn't defined, then it will be created

windowIdentifiers array optional

if creating, then can optionally specify an array of other windowIdentifiers to add to stack on creation (in addition to this window).

cb function

cb(err, stackedWindowIdentifier)

Typically used by Tabbing Presentation component.

getWindowIdentifier
(){windowIdentifier}
clients/windowClient.js, line 1233

Returns the window identifier for the current component.

Returns:
Type Description
windowIdentifier

getWindowTitle
(){String}
clients/windowClient.js, line 241

Retrieves the window's title.

Returns:
Type Description
String title
Example
var windowTitle = FSBL.Clients.WindowClient.getWindowTitle();

headerCommandChannel
(commandChannel)
clients/windowClient.js, line 1128

Establishes a command channel with a header. The WindowClient can update header state via this channel.

Name Type Description
commandChannel function

A function callback that receives commands

injectHeader
(params)
clients/windowClient.js, line 941

The Finsemble Window Title Bar is injected if FSBLHeader: true or FSBLHeader is an object with the same items as the properties of params below as this function is in the component's config. If you want to inject the Finsemble header later, you can do so by calling this function

Name Type Description
params object optional
Name Type Description
component string optional

Component to inject. Default is "windowTitleBar"

bumpElements object optional
Name Type Description
fixed boolean | string optional

Either false, "all" or "0Positioned". If all, all fixed elements are moved. 0Positioned only moves elements that have top 0. Default is all.

absolute boolean | string optional

Either false, "all" or "0Positioned". If all, all fixed elements are moved. 0Positioned only moves elements that have top 0. Only applies to children of the body. Default is all.

bumpBy string optional

default is "32px".

bodyMarginTop string optional

Sets the body margin. Default is "30px".

forceHeaderHeight string optional

Sets a height to the main FSBLHeader div.

maximize
(cb)
clients/windowClient.js, line 516

Maximizes the window. Also takes into account the application toolbar.

Name Type Description
cb function optional

Optional callback

Example
FSBL.Clients.WindowClient.maximize();

minimize
(cb)
clients/windowClient.js, line 417

Minmizes window.

Name Type Description
cb function optional

Optional callback

Example
FSBL.Clients.WindowClient.minimize();

restore
(cb)
clients/windowClient.js, line 460

Restores window from a maximized state.

Name Type Description
cb function optional

Optional callback

Example
FSBL.Clients.WindowClient.restore();

saveWindowBounds
(bounds)
clients/windowClient.js, line 355

Saves the window's state. Rarely called manually, as it's called every time your window moves.

Name Type Description
bounds Object

optional param.

Example

The code below is the bulk of our listener for the bounds-changed event from the openFin window. Every time the bounds-changed event is fired (when the window is resized or moved), we save the window's state. The first few lines just prevent the window from being dropped behind the toolbar.

finWindow.addEventListener('disabled-frame-bounds-changed', function (bounds) {
	if (bounds.top < 45) {
		finWindow.moveTo(bounds.left, 45);
		return;
	}
	self.saveWindowBounds(bounds);
});

sendIdentifierForTilingOrTabbing
(params, cb)
clients/windowClient.js, line 1293

Name Type Description
params *

windowIdentifier is required

cb *

setActive
(active)
clients/windowClient.js, line 1249

Highlights the window as active by creating a border around the window.

Name Type Description
active boolean

Set to false to turn off activity

setAlwaysOnTop
(cb)
clients/windowClient.js, line 439

Sets whether window is always on top.

Name Type Description
cb function optional

Optional callback

Example
FSBL.Clients.WindowClient.setAlwaysOnTop(true);

setComponentState
(params, cb)
clients/windowClient.js, line 702

Given a field, this function sets and persists app state.

Name Type Description
params object
Name Type Description
field string optional

field

fields Array.<string> optional

fields

cb function optional

Callback

Example

The example below shows how we save our chart layout when it changes.

var s = stx.exportLayout(true);
//saving layout'
FSBL.Clients.WindowClient.setComponentState({ field: 'myChartLayout', value: s });
FSBL.Clients.WindowClient.setComponentState({ fields: [{field:'myChartLayout', value: s }, {field:'chartType', value: 'mountain'}]);

setWindowTitle
(title)
clients/windowClient.js, line 1156

This function does two things:

  1. It sets the window's title in the windowTitleBar component, and
  2. It sets the title in the DOM.

This is useful if you like to keep the window's title in sync with a piece of data (e.g., a Symbol);

TODO
  • Allow HTML or classes to be injected into the title.
Name Type Description
title String

Window title.

Example

The code shows how you would change your window title.

FSBL.Clients.WindowClient.setWindowTitle("My Component's New Title");

startTilingOrTabbing
(params, cb)
clients/windowClient.js, line 1272

Name Type Description
params *

params.windowIdentifier is required.

cb *

stopTilingOrTabbing
(params, cb)
clients/windowClient.js, line 1303

Name Type Description
params *

params.windowIdentifier is required.

cb *

updateHeaderState
(command, state)
clients/windowClient.js, line 1116

Sends a command to the header. Commands affect the header state, so that the UI reflects what is going on in the component window.

Name Type Description
command string

The state object to set

state object

The new state (merged with existing)

inneronClose
(params, cb)
clients/windowClient.js, line 155

Closes Window.

Name Type Description
params object
Name Type Description
removeFromWorkspace boolean

whether to remove the window from the workspace.

closeWindow boolean

Whether to close the window. On shutdown this method is closed, but we let the launcher close the window. Defaults are to remove the window from the workspace if the user presses the X button, but not if the window is closed via an app-level request (e.g., we need to switch workspaces, so all windows need to close).

cb function optional

callback

Example
//Close window and remove from workspace (e.g., user closes the window).
	FSBL.Clients.WindowClient.close(true);
	//Close window and keep in workspace (e.g., application requests that all windows close themselves).
	FSBL.Clients.WindowClient.close(false);